Skip to content

Commit fb96b28

Browse files
author
Vicent Marti
committed
Merge pull request libgit2#3629 from ethomson/set_user_agent_doc
git_libgit2_opts: minor documentation & usage fixes
2 parents 305c4f9 + 7bab2e8 commit fb96b28

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

include/git2/common.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,12 @@ typedef enum {
245245
*
246246
* * opts(GIT_OPT_SET_USER_AGENT, const char *user_agent)
247247
*
248+
* > Set the value of the User-Agent header. This value will be
249+
* > appended to "git/1.0", for compatibility with other git clients.
250+
* >
251+
* > - `user_agent` is the value that will be delivered as the
252+
* > User-Agent header on HTTP requests.
253+
*
248254
* @param option Option key
249255
* @param ... value to set the option
250256
* @return 0 on success, <0 on failure

src/settings.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,9 @@ int git_libgit2_opts(int key, ...)
181181
}
182182

183183
break;
184+
default:
185+
giterr_set(GITERR_INVALID, "invalid option key");
186+
error = -1;
184187
}
185188

186189
va_end(ap);

tests/core/opts.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,9 @@ void test_core_opts__readwrite(void)
1717

1818
cl_assert(new_val == old_val);
1919
}
20+
21+
void test_core_opts__invalid_option(void)
22+
{
23+
cl_git_fail(git_libgit2_opts(-1, "foobar"));
24+
}
25+

0 commit comments

Comments
 (0)