Skip to content

Commit 9ddf612

Browse files
authored
Merge pull request libgit2#6788 from libgit2/ethomson/user_agent
Allow more control over the user-agent
2 parents 72d36a4 + 4839f4f commit 9ddf612

File tree

10 files changed

+600
-445
lines changed

10 files changed

+600
-445
lines changed

include/git2/common.h

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,9 @@ typedef enum {
228228
GIT_OPT_SET_SERVER_CONNECT_TIMEOUT,
229229
GIT_OPT_GET_SERVER_CONNECT_TIMEOUT,
230230
GIT_OPT_SET_SERVER_TIMEOUT,
231-
GIT_OPT_GET_SERVER_TIMEOUT
231+
GIT_OPT_GET_SERVER_TIMEOUT,
232+
GIT_OPT_SET_USER_AGENT_PRODUCT,
233+
GIT_OPT_GET_USER_AGENT_PRODUCT
232234
} git_libgit2_opt_t;
233235

234236
/**
@@ -337,11 +339,35 @@ typedef enum {
337339
*
338340
* * opts(GIT_OPT_SET_USER_AGENT, const char *user_agent)
339341
*
340-
* > Set the value of the User-Agent header. This value will be
341-
* > appended to "git/1.0", for compatibility with other git clients.
342+
* > Set the value of the comment section of the User-Agent header.
343+
* > This can be information about your product and its version.
344+
* > By default this is "libgit2" followed by the libgit2 version.
342345
* >
343-
* > - `user_agent` is the value that will be delivered as the
344-
* > User-Agent header on HTTP requests.
346+
* > This value will be appended to User-Agent _product_, which
347+
* > is typically set to "git/2.0".
348+
* >
349+
* > Set to the empty string ("") to not send any information in the
350+
* > comment section, or set to NULL to restore the default.
351+
*
352+
* * opts(GIT_OPT_GET_USER_AGENT, git_buf *out)
353+
*
354+
* > Get the value of the User-Agent header.
355+
* > The User-Agent is written to the `out` buffer.
356+
*
357+
* * opts(GIT_OPT_SET_USER_AGENT_PRODUCT, const char *user_agent_product)
358+
*
359+
* > Set the value of the product portion of the User-Agent header.
360+
* > This defaults to "git/2.0", for compatibility with other git
361+
* > clients. It is recommended to keep this as git/<version> for
362+
* > compatibility with servers that do user-agent detection.
363+
* >
364+
* > Set to the empty string ("") to not send any user-agent string,
365+
* > or set to NULL to restore the default.
366+
*
367+
* * opts(GIT_OPT_GET_USER_AGENT_PRODUCT, git_buf *out)
368+
*
369+
* > Get the value of the User-Agent product header.
370+
* > The User-Agent product is written to the `out` buffer.
345371
*
346372
* * opts(GIT_OPT_SET_WINDOWS_SHAREMODE, unsigned long value)
347373
*
@@ -377,11 +403,6 @@ typedef enum {
377403
* >
378404
* > - `ciphers` is the list of ciphers that are eanbled.
379405
*
380-
* * opts(GIT_OPT_GET_USER_AGENT, git_buf *out)
381-
*
382-
* > Get the value of the User-Agent header.
383-
* > The User-Agent is written to the `out` buffer.
384-
*
385406
* * opts(GIT_OPT_ENABLE_OFS_DELTA, int enabled)
386407
*
387408
* > Enable or disable the use of "offset deltas" when creating packfiles,

0 commit comments

Comments
 (0)