Skip to content

Commit 1c7c25a

Browse files
szedergitster
authored andcommitted
notes: simplify default operation mode arguments check
'git notes' has a default operation mode, but when invoked without a subcommand it doesn't accept any arguments (although the 'list' subcommand implementing the default operation mode does accept arguments). The condition checking this ended up a bit awkward, so let's make it clearer. Signed-off-by: SZEDER Gábor <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 45bec2e commit 1c7c25a

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

builtin/notes.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -995,7 +995,7 @@ static int get_ref(int argc, const char **argv, const char *prefix)
995995
int cmd_notes(int argc, const char **argv, const char *prefix)
996996
{
997997
const char *override_notes_ref = NULL;
998-
parse_opt_subcommand_fn *fn = list;
998+
parse_opt_subcommand_fn *fn = NULL;
999999
struct option options[] = {
10001000
OPT_STRING(0, "ref", &override_notes_ref, N_("notes-ref"),
10011001
N_("use notes from <notes-ref>")),
@@ -1015,9 +1015,12 @@ int cmd_notes(int argc, const char **argv, const char *prefix)
10151015
git_config(git_default_config, NULL);
10161016
argc = parse_options(argc, argv, prefix, options, git_notes_usage,
10171017
PARSE_OPT_SUBCOMMAND_OPTIONAL);
1018-
if (fn == list && argc && strcmp(argv[0], "list")) {
1019-
error(_("unknown subcommand: %s"), argv[0]);
1020-
usage_with_options(git_notes_usage, options);
1018+
if (!fn) {
1019+
if (argc) {
1020+
error(_("unknown subcommand: %s"), argv[0]);
1021+
usage_with_options(git_notes_usage, options);
1022+
}
1023+
fn = list;
10211024
}
10221025

10231026
if (override_notes_ref) {

0 commit comments

Comments
 (0)