File tree Expand file tree Collapse file tree 4 files changed +19
-0
lines changed
Expand file tree Collapse file tree 4 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,10 @@ v0.24 + 1
1212
1313### API additions
1414
15+ * You can now get the user-agent used by libgit2 using the
16+ ` GIT_OPT_GET_USER_AGENT ` option with ` git_libgit2_opts() ` .
17+ It is the counterpart to ` GIT_OPT_SET_USER_AGENT ` .
18+
1519* ` git_commit_create_buffer() ` creates a commit and writes it into a
1620 user-provided buffer instead of writing it into the object db.
1721
Original file line number Diff line number Diff line change @@ -158,6 +158,7 @@ typedef enum {
158158 GIT_OPT_SET_USER_AGENT ,
159159 GIT_OPT_ENABLE_STRICT_OBJECT_CREATION ,
160160 GIT_OPT_SET_SSL_CIPHERS ,
161+ GIT_OPT_GET_USER_AGENT ,
161162} git_libgit2_opt_t ;
162163
163164/**
Original file line number Diff line number Diff line change @@ -209,6 +209,14 @@ int git_libgit2_opts(int key, ...)
209209#endif
210210 break ;
211211
212+ case GIT_OPT_GET_USER_AGENT :
213+ {
214+ git_buf * out = va_arg (ap , git_buf * );
215+ git_buf_sanitize (out );
216+ error = git_buf_sets (out , git__user_agent );
217+ }
218+ break ;
219+
212220 default :
213221 giterr_set (GITERR_INVALID , "invalid option key" );
214222 error = -1 ;
Original file line number Diff line number Diff line change 44void test_core_useragent__get (void )
55{
66 const char * custom_name = "super duper git" ;
7+ git_buf buf = GIT_BUF_INIT ;
78
89 cl_assert_equal_p (NULL , git_libgit2__user_agent ());
910 cl_git_pass (git_libgit2_opts (GIT_OPT_SET_USER_AGENT , custom_name ));
1011 cl_assert_equal_s (custom_name , git_libgit2__user_agent ());
12+
13+ cl_git_pass (git_libgit2_opts (GIT_OPT_GET_USER_AGENT , & buf ));
14+ cl_assert_equal_s (custom_name , buf .ptr );
15+
16+ git_buf_free (& buf );
1117}
You can’t perform that action at this time.
0 commit comments