Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2020-03-16 23:22:54 +0300
committerJunio C Hamano <gitster@pobox.com>2020-03-17 00:27:07 +0300
commit7c280589cffa6f55f6bef0496776334f1e3cdcb5 (patch)
tree33b308fa00d049ef167ac531d606d994e7c7539d /parse-options.c
parent6c85aac65fb455af85745130ce35ddae4678db84 (diff)
parse-options: teach "git cmd -h" to show alias as alias
There is a long-standing NEEDSWORK comment that complains about inconsistency between how an aliased option ("git clone --recurse" which is the only one that currently exists) gives a help text in a usage-error message vs "git cmd -h"). Get rid of it and then make sure we say an option is an alias for another, instead of repeating the same short help text for both, which leads to "they seem to do the same---is there any subtle difference?" puzzlement to end-users. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'parse-options.c')
-rw-r--r--parse-options.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/parse-options.c b/parse-options.c
index 63d6bab60c..c57618d537 100644
--- a/parse-options.c
+++ b/parse-options.c
@@ -648,6 +648,7 @@ static struct option *preprocess_options(struct parse_opt_ctx_t *ctx,
int short_name;
const char *long_name;
const char *source;
+ struct strbuf help = STRBUF_INIT;
int j;
if (newopt[i].type != OPTION_ALIAS)
@@ -659,6 +660,7 @@ static struct option *preprocess_options(struct parse_opt_ctx_t *ctx,
if (!long_name)
BUG("An alias must have long option name");
+ strbuf_addf(&help, _("alias of --%s"), source);
for (j = 0; j < nr; j++) {
const char *name = options[j].long_name;
@@ -669,15 +671,10 @@ static struct option *preprocess_options(struct parse_opt_ctx_t *ctx,
if (options[j].type == OPTION_ALIAS)
BUG("No please. Nested aliases are not supported.");
- /*
- * NEEDSWORK: this is a bit inconsistent because
- * usage_with_options() on the original options[] will print
- * help string as "alias of %s" but "git cmd -h" will
- * print the original help string.
- */
memcpy(newopt + i, options + j, sizeof(*newopt));
newopt[i].short_name = short_name;
newopt[i].long_name = long_name;
+ newopt[i].help = strbuf_detach(&help, NULL);
break;
}