Skip to content

Commit e169b97

Browse files
bebarinogitster
authored andcommitted
show-branch: don't use LASTARG_DEFAULT with OPTARG
5734365 (show-branch: migrate to parse-options API 2009-05-21) incorrectly set the --more option's flags to be PARSE_OPT_LASTARG_DEFAULT and PARSE_OPT_OPTARG. These two flags shouldn't be used together. An option taking a default should just set the default value desired and parse options will take care of the rest. Update the header comment to better convey this information. Signed-off-by: Stephen Boyd <[email protected]> Acked-by: René Scharfe <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d1fff6f commit e169b97

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

builtin-show-branch.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -657,8 +657,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
657657
"color '*!+-' corresponding to the branch"),
658658
{ OPTION_INTEGER, 0, "more", &extra, "n",
659659
"show <n> more commits after the common ancestor",
660-
PARSE_OPT_OPTARG | PARSE_OPT_LASTARG_DEFAULT,
661-
NULL, (intptr_t)1 },
660+
PARSE_OPT_OPTARG, NULL, (intptr_t)1 },
662661
OPT_SET_INT(0, "list", &extra, "synonym to more=-1", -1),
663662
OPT_BOOLEAN(0, "no-name", &no_name, "suppress naming strings"),
664663
OPT_BOOLEAN(0, "current", &with_current_branch,

parse-options.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,11 @@ typedef int parse_opt_cb(const struct option *, const char *arg, int unset);
7171
* PARSE_OPT_NONEG: says that this option cannot be negated
7272
* PARSE_OPT_HIDDEN: this option is skipped in the default usage, and
7373
* shown only in the full usage.
74-
* PARSE_OPT_LASTARG_DEFAULT: if no argument is given, the default value
75-
* is used.
74+
* PARSE_OPT_LASTARG_DEFAULT: says that this option will take the default
75+
* value if no argument is given when the option
76+
* is last on the command line. If the option is
77+
* not last it will require an argument.
78+
* Should not be used with PARSE_OPT_OPTARG.
7679
* PARSE_OPT_NODASH: this option doesn't start with a dash.
7780
* PARSE_OPT_LITERAL_ARGHELP: says that argh shouldn't be enclosed in brackets
7881
* (i.e. '<argh>') in the help message.

0 commit comments

Comments
 (0)