Skip to content

Commit 070e7c5

Browse files
avargitster
authored andcommitted
commit-graph: early exit to "usage" on !argc
Rather than guarding all of the !argc with an additional "if" arm let's do an early goto to "usage". This also makes it clear that "save_commit_buffer" is not needed in this case. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Reviewed-by: Taylor Blau <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 92f4809 commit 070e7c5

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

builtin/commit-graph.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -331,16 +331,17 @@ int cmd_commit_graph(int argc, const char **argv, const char *prefix)
331331
builtin_commit_graph_options,
332332
builtin_commit_graph_usage,
333333
PARSE_OPT_STOP_AT_NON_OPTION);
334+
if (!argc)
335+
goto usage;
334336

335337
save_commit_buffer = 0;
336338

337-
if (argc > 0) {
338-
if (!strcmp(argv[0], "verify"))
339-
return graph_verify(argc, argv);
340-
if (!strcmp(argv[0], "write"))
341-
return graph_write(argc, argv);
342-
}
339+
if (!strcmp(argv[0], "verify"))
340+
return graph_verify(argc, argv);
341+
else if (argc && !strcmp(argv[0], "write"))
342+
return graph_write(argc, argv);
343343

344+
usage:
344345
usage_with_options(builtin_commit_graph_usage,
345346
builtin_commit_graph_options);
346347
}

0 commit comments

Comments
 (0)