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 <avarab@gmail.com> Reviewed-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ævar Arnfjörð Bjarmason committed Aug 23, 2021 at 14:30 UTC 070e7c5619bfaca2b1e93255d892b68ed455aaa6
1 file changed +7 -6
builtin/commit-graph.c
+7 -6
@@ -331,16 +331,17 @@ int cmd_commit_graph(int argc, const char **argv, const char *prefix)
331 builtin_commit_graph_options,
332 builtin_commit_graph_usage,
333 PARSE_OPT_STOP_AT_NON_OPTION);
334 + if (!argc)
335 + goto usage;
336
337 save_commit_buffer = 0;
338
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);
343
344 +usage:
345 usage_with_options(builtin_commit_graph_usage,
346 builtin_commit_graph_options);
347 }