summaryrefslogtreecommitdiff
path: root/parse-options-cb.c
diff options
context:
space:
mode:
authorMichael Haggerty <mhagger@alum.mit.edu>2016-09-05 11:44:52 +0200
committerJunio C Hamano <gitster@pobox.com>2016-09-19 10:25:11 -0700
commitce564eb1bd541a87152e3546fb7d7a2b460df7ed (patch)
treec9036ec33eff913fffc97cff7dc985f5cd2a5e24 /parse-options-cb.c
parent433860f3d0beb0c6f205290bd16cda413148f098 (diff)
downloadgit-ce564eb1bd541a87152e3546fb7d7a2b460df7ed.tar.gz
parse-options: add parse_opt_unknown_cb()
Add a new callback function, parse_opt_unknown_cb(), which returns -2 to indicate that the corresponding option is unknown. This can be used to add "-h" documentation for an option that will be handled externally to parse_options(). Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'parse-options-cb.c')
-rw-r--r--parse-options-cb.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/parse-options-cb.c b/parse-options-cb.c
index ba5acf3111..9f2f9b3df6 100644
--- a/parse-options-cb.c
+++ b/parse-options-cb.c
@@ -154,6 +154,18 @@ int parse_opt_noop_cb(const struct option *opt, const char *arg, int unset)
}
/**
+ * Report that the option is unknown, so that other code can handle
+ * it. This can be used as a callback together with
+ * OPTION_LOWLEVEL_CALLBACK to allow an option to be documented in the
+ * "-h" output even if it's not being handled directly by
+ * parse_options().
+ */
+int parse_opt_unknown_cb(const struct option *opt, const char *arg, int unset)
+{
+ return -2;
+}
+
+/**
* Recreates the command-line option in the strbuf.
*/
static int recreate_opt(struct strbuf *sb, const struct option *opt,