Fix documentation syntax of optional arguments in short options.
PATCH 1/1 Fix documentation syntax of optional arguments in short options.
When an argument for an option is optional, like in -n from git-tag, putting a space between the option and the argument is interpreted as a missing argument for the option plus an isolated argument. Documentation now reflects the need to write the parameter following the option -n, as in "git tag -nARG", for instance.
--- Documentation/git-tag.txt | 4 ++-- parse-options.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
Documentation/git-tag.txt +2 -2
@@ -11,7 +11,7 @@ SYNOPSIS [verse] 'git-tag' [-a | -s | -u <key-id>] [-f] [-m <msg> | -F <file>] <name> [<head>] 'git-tag' -d <name>... -'git-tag' [-n [<num>]] -l [<pattern>] +'git-tag' [-n[<num>]] -l [<pattern>] 'git-tag' -v <name>... DESCRIPTION
@@ -57,7 +57,7 @@ OPTIONS -v:: Verify the gpg signature of the given tag names. --n <num>:: +-n<num>:: <num> specifies how many lines from the annotation, if any, are printed when using -l. The default is not to print any annotation lines.
parse-options.c +1 -1
@@ -344,7 +344,7 @@ void usage_with_options_internal(const char * const *usagestr,break ;case OPTION_INTEGER :if (opts->flags &PARSE_OPT_OPTARG ) - pos +=fprintf (stderr," [<n>]" ); + pos +=fprintf (stderr,"[<n>]" );else pos +=fprintf (stderr," <n>" );break ;
Signature · 1 line
1.5.3.4
When an argument for an option is optional, like in -n from git-tag, puting a space between the option and the argument is interpreted as a missing argument for the option plus an isolated argument. Documentation now reflects the need to write the parameter following the option -n, as in "git tag -nARG", for instance.
---
I forgot to make the same change to the command's syntax in builtin-tag.c.
I didn't check if this also happens for OPTION_STRING, this is only for OPTION_INTEGER, which seems to be only used in git-tag. I must note that all this is related to the PARSE_OPT_OPTARG option, which is used only (apart from builtin-tag.c) in builtin-rev-parse.c but in a different way.
Documentation/git-tag.txt | 4 ++-- builtin-tag.c | 2 +- parse-options.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
Documentation/git-tag.txt +2 -2
@@ -11,7 +11,7 @@ SYNOPSIS [verse] 'git-tag' [-a | -s | -u <key-id>] [-f] [-m <msg> | -F <file>] <name> [<head>] 'git-tag' -d <name>... -'git-tag' [-n [<num>]] -l [<pattern>] +'git-tag' [-n[<num>]] -l [<pattern>] 'git-tag' -v <name>... DESCRIPTION
@@ -57,7 +57,7 @@ OPTIONS -v:: Verify the gpg signature of the given tag names. --n <num>:: +-n<num>:: <num> specifies how many lines from the annotation, if any, are printed when using -l. The default is not to print any annotation lines.
builtin-tag.c +1 -1
@@ -16,7 +16,7 @@static const char *const git_tag_usage[] = {"git-tag [-a|-s|-u <key-id>] [-f] [-m <msg>|-F <file>] <tagname> [<head>]" ,"git-tag -d <tagname>..." , -"git-tag -l [-n [<num>]] [<pattern>]" , +"git-tag -l [-n[<num>]] [<pattern>]" ,"git-tag -v <tagname>..." ,NULL };
parse-options.c +1 -1
@@ -344,7 +344,7 @@ void usage_with_options_internal(const char * const *usagestr,break ;case OPTION_INTEGER :if (opts->flags &PARSE_OPT_OPTARG ) - pos +=fprintf (stderr," [<n>]" ); + pos +=fprintf (stderr,"[<n>]" );else pos +=fprintf (stderr," <n>" );break ;
Signature · 1 line
1.5.3.4