Merge pull request #3629 from ethomson/set_user_agent_doc git_libgit2_opts: minor documentation & usage fixes
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
diff --git a/include/git2/common.h b/include/git2/common.h
index ee230df..c260308 100644
--- a/include/git2/common.h
+++ b/include/git2/common.h
@@ -245,6 +245,12 @@ typedef enum {
*
* * opts(GIT_OPT_SET_USER_AGENT, const char *user_agent)
*
+ * > Set the value of the User-Agent header. This value will be
+ * > appended to "git/1.0", for compatibility with other git clients.
+ * >
+ * > - `user_agent` is the value that will be delivered as the
+ * > User-Agent header on HTTP requests.
+ *
* @param option Option key
* @param ... value to set the option
* @return 0 on success, <0 on failure
diff --git a/src/settings.c b/src/settings.c
index da99b59..d7341ab 100644
--- a/src/settings.c
+++ b/src/settings.c
@@ -181,6 +181,9 @@ int git_libgit2_opts(int key, ...)
}
break;
+ default:
+ giterr_set(GITERR_INVALID, "invalid option key");
+ error = -1;
}
va_end(ap);
diff --git a/tests/core/opts.c b/tests/core/opts.c
index 3173c64..72408cb 100644
--- a/tests/core/opts.c
+++ b/tests/core/opts.c
@@ -17,3 +17,9 @@ void test_core_opts__readwrite(void)
cl_assert(new_val == old_val);
}
+
+void test_core_opts__invalid_option(void)
+{
+ cl_git_fail(git_libgit2_opts(-1, "foobar"));
+}
+