summary refs log tree commit diff
path: root/parse-options.h
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2019-05-19 16:45:28 +0900
committerJunio C Hamano <gitster@pobox.com>2019-05-19 16:45:28 +0900
commit2cfab6087790ceeb81eb91eeb1300500cfa4c948 (patch)
tree12b60cadde36404d455a1adc53bc626af4704565 /parse-options.h
parent4ac8371a1ce0df07a2c3389d6acf6c35207a54fa (diff)
parent5c387428f10c27c24d3adb890cd466e2300518fa (diff)
Merge branch 'nd/parse-options-aliases'
Attempt to use an abbreviated option in "git clone --recurs" is
responded by a request to disambiguate between --recursive and
--recurse-submodules, which is bad because these two are synonyms.
The parse-options API has been extended to define such synonyms
more easily and not produce an unnecessary failure.

* nd/parse-options-aliases:
  parse-options: don't emit "ambiguous option" for aliases
Diffstat (limited to 'parse-options.h')
-rw-r--r--parse-options.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/parse-options.h b/parse-options.h
index bd00cf0049..98ea42ffd9 100644
--- a/parse-options.h
+++ b/parse-options.h
@@ -7,6 +7,7 @@ enum parse_opt_type {
 	OPTION_ARGUMENT,
 	OPTION_GROUP,
 	OPTION_NUMBER,
+	OPTION_ALIAS,
 	/* options with no arguments */
 	OPTION_BIT,
 	OPTION_NEGBIT,
@@ -183,6 +184,9 @@ struct option {
 	  N_("no-op (backward compatibility)"),		\
 	  PARSE_OPT_HIDDEN | PARSE_OPT_NOARG, parse_opt_noop_cb }
 
+#define OPT_ALIAS(s, l, source_long_name) \
+	{ OPTION_ALIAS, (s), (l), (source_long_name) }
+
 /*
  * parse_options() will filter out the processed options and leave the
  * non-option arguments in argv[]. argv0 is assumed program name and
@@ -258,6 +262,8 @@ struct parse_opt_ctx_t {
 	const char *opt;
 	int flags;
 	const char *prefix;
+	const char **alias_groups; /* must be in groups of 3 elements! */
+	struct option *updated_options;
 };
 
 void parse_options_start(struct parse_opt_ctx_t *ctx,