diff options
| author | Junio C Hamano <gitster@pobox.com> | 2022-09-13 11:38:24 -0700 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2022-09-13 11:38:24 -0700 |
| commit | 76ffa818c792cf3508502f78909c3b7eb3c72dbc (patch) | |
| tree | a8df035dcafeea7c95ee6405b0bdd536a2393b75 /builtin | |
| parent | 655e49404792a302b16fa640e1fa6041052996f9 (diff) | |
| parent | dd834d75caabd436e306c136f753c801220db2df (diff) | |
| download | git-76ffa818c792cf3508502f78909c3b7eb3c72dbc.tar.xz | |
Merge branch 'sg/parse-options-subcommand'
The codepath for the OPT_SUBCOMMAND facility has been cleaned up.
* sg/parse-options-subcommand:
notes, remote: show unknown subcommands between `'
notes: simplify default operation mode arguments check
test-parse-options.c: fix style of comparison with zero
test-parse-options.c: don't use for loop initial declaration
t0040-parse-options: remove leftover debugging
Diffstat (limited to 'builtin')
| -rw-r--r-- | builtin/notes.c | 11 | ||||
| -rw-r--r-- | builtin/remote.c | 2 |
2 files changed, 8 insertions, 5 deletions
diff --git a/builtin/notes.c b/builtin/notes.c index 42cbae4659..be51f69225 100644 --- a/builtin/notes.c +++ b/builtin/notes.c @@ -995,7 +995,7 @@ static int get_ref(int argc, const char **argv, const char *prefix) int cmd_notes(int argc, const char **argv, const char *prefix) { const char *override_notes_ref = NULL; - parse_opt_subcommand_fn *fn = list; + parse_opt_subcommand_fn *fn = NULL; struct option options[] = { OPT_STRING(0, "ref", &override_notes_ref, N_("notes-ref"), N_("use notes from <notes-ref>")), @@ -1015,9 +1015,12 @@ int cmd_notes(int argc, const char **argv, const char *prefix) git_config(git_default_config, NULL); argc = parse_options(argc, argv, prefix, options, git_notes_usage, PARSE_OPT_SUBCOMMAND_OPTIONAL); - if (fn == list && argc && strcmp(argv[0], "list")) { - error(_("unknown subcommand: %s"), argv[0]); - usage_with_options(git_notes_usage, options); + if (!fn) { + if (argc) { + error(_("unknown subcommand: `%s'"), argv[0]); + usage_with_options(git_notes_usage, options); + } + fn = list; } if (override_notes_ref) { diff --git a/builtin/remote.c b/builtin/remote.c index 272c7b8d9e..07117e4c9a 100644 --- a/builtin/remote.c +++ b/builtin/remote.c @@ -1768,7 +1768,7 @@ int cmd_remote(int argc, const char **argv, const char *prefix) return !!fn(argc, argv, prefix); } else { if (argc) { - error(_("unknown subcommand: %s"), argv[0]); + error(_("unknown subcommand: `%s'"), argv[0]); usage_with_options(builtin_remote_usage, options); } return !!show_all(); |
