diff options
author | Junio C Hamano <gitster@pobox.com> | 2014-03-31 16:30:59 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2014-03-31 16:30:59 -0700 |
commit | 24b9cb100214adb0c5ebe574924c3acf6c61f214 (patch) | |
tree | 0abe244944a66189a96d18e5d0bf963288bc0b5f /builtin | |
parent | a79cbc1368505bc02639b1b423a1132324cb5853 (diff) | |
parent | ce7f8745aa773dfe2fc0a1b8c327b50c7ce4a31e (diff) | |
download | git-24b9cb100214adb0c5ebe574924c3acf6c61f214.tar.gz |
Merge branch 'ib/rev-parse-parseopt-argh'
Teaches the "rev-parse --parseopt" mechanism used by scripted
Porcelains to parse command line options and give help text how to
supply argv-help (the placeholder string for an option parameter,
e.g. "key-id" in "--gpg-sign=<key-id>").
* ib/rev-parse-parseopt-argh:
t1502: protect runs of SPs used in the indentation
rev-parse --parseopt: option argument name hints
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/rev-parse.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c index 45901df371..1a6122d3ae 100644 --- a/builtin/rev-parse.c +++ b/builtin/rev-parse.c @@ -395,9 +395,10 @@ static int cmd_parseopt(int argc, const char **argv, const char *prefix) usage[unb++] = strbuf_detach(&sb, NULL); } - /* parse: (<short>|<short>,<long>|<long>)[=?]? SP+ <help> */ + /* parse: (<short>|<short>,<long>|<long>)[*=?!]*<arghint>? SP+ <help> */ while (strbuf_getline(&sb, stdin, '\n') != EOF) { const char *s; + const char *end; struct option *o; if (!sb.len) @@ -419,6 +420,16 @@ static int cmd_parseopt(int argc, const char **argv, const char *prefix) o->value = &parsed; o->flags = PARSE_OPT_NOARG; o->callback = &parseopt_dump; + + /* Possible argument name hint */ + end = s; + while (s > sb.buf && strchr("*=?!", s[-1]) == NULL) + --s; + if (s != sb.buf && s != end) + o->argh = xmemdupz(s, end - s); + if (s == sb.buf) + s = end; + while (s > sb.buf && strchr("*=?!", s[-1])) { switch (*--s) { case '=': |