From: Junio C Hamano Date: Mon, 23 Jun 2008 01:39:37 +0000 (-0700) Subject: Merge branch 'maint' X-Git-Tag: v1.6.0-rc0~227 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/0bd64f82ba38013799d1d999de5fc3c079bd8014?ds=inline;hp=-c Merge branch 'maint' * maint: Extend parse-options test suite api-parse-options.txt: Introduce documentation for parse options API parse-options.c: fix documentation syntax of optional arguments api-builtin.txt: update and fix typo --- 0bd64f82ba38013799d1d999de5fc3c079bd8014 diff --combined parse-options.c index 8071711e5d,f8d52e21fe..b8bde2b04a --- a/parse-options.c +++ b/parse-options.c @@@ -312,12 -312,8 +312,12 @@@ void usage_with_options_internal(const fprintf(stderr, "usage: %s\n", *usagestr++); while (*usagestr && **usagestr) fprintf(stderr, " or: %s\n", *usagestr++); - while (*usagestr) - fprintf(stderr, " %s\n", *usagestr++); + while (*usagestr) { + fprintf(stderr, "%s%s\n", + **usagestr ? " " : "", + *usagestr); + usagestr++; + } if (opts->type != OPTION_GROUP) fputc('\n', stderr); @@@ -348,7 -344,10 +348,10 @@@ break; case OPTION_INTEGER: if (opts->flags & PARSE_OPT_OPTARG) - pos += fprintf(stderr, "[]"); + if (opts->long_name) + pos += fprintf(stderr, "[=]"); + else + pos += fprintf(stderr, "[]"); else pos += fprintf(stderr, " "); break; @@@ -359,12 -358,18 +362,18 @@@ case OPTION_STRING: if (opts->argh) { if (opts->flags & PARSE_OPT_OPTARG) - pos += fprintf(stderr, " [<%s>]", opts->argh); + if (opts->long_name) + pos += fprintf(stderr, "[=<%s>]", opts->argh); + else + pos += fprintf(stderr, "[<%s>]", opts->argh); else pos += fprintf(stderr, " <%s>", opts->argh); } else { if (opts->flags & PARSE_OPT_OPTARG) - pos += fprintf(stderr, " [...]"); + if (opts->long_name) + pos += fprintf(stderr, "[=...]"); + else + pos += fprintf(stderr, "[...]"); else pos += fprintf(stderr, " ..."); } diff --combined t/t1502-rev-parse-parseopt.sh index 7cdd70a188,3508d0a612..997002d4c4 --- a/t/t1502-rev-parse-parseopt.sh +++ b/t/t1502-rev-parse-parseopt.sh @@@ -5,7 -5,7 +5,7 @@@ test_description='test git rev-parse -- cat > expect.err <... - + some-command does foo and bar! -h, --help show the help @@@ -13,7 -13,7 +13,7 @@@ --bar ... some cool option --bar with an argument An option group Header - -C [...] option C with an optional argument + -C[...] option C with an optional argument Extras --extra1 line above used to cause a segfault but no longer does