diff options
author | Ævar Arnfjörð Bjarmason <avarab@gmail.com> | 2021-08-23 14:30:20 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-08-30 17:06:18 -0700 |
commit | 6d209a01f89fd27d42e0a74a5ada29cef1dcac29 (patch) | |
tree | 65607f1d7506502d19a4d3d6e9e6ff3d319cd76d /builtin | |
parent | commit-graph: early exit to "usage" on !argc (diff) | |
download | tgif-6d209a01f89fd27d42e0a74a5ada29cef1dcac29.tar.xz |
commit-graph: show usage on "commit-graph [write|verify] garbage"
Change the parse_options() invocation in the commit-graph code to
error on unknown leftover argv elements, in addition to the existing
and implicit erroring via parse_options() on unknown options.
We'd already error in cmd_commit_graph() on e.g.:
git commit-graph unknown verify
git commit-graph --unknown verify
But here we're calling parse_options() twice more for the "write" and
"verify" subcommands. We did not do the same checking for leftover
argv elements there. As a result we'd silently accept garbage in these
subcommands, let's not do that.
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>
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/commit-graph.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/builtin/commit-graph.c b/builtin/commit-graph.c index bf34aa43f2..0457903f18 100644 --- a/builtin/commit-graph.c +++ b/builtin/commit-graph.c @@ -105,6 +105,8 @@ static int graph_verify(int argc, const char **argv) argc = parse_options(argc, argv, NULL, options, builtin_commit_graph_verify_usage, 0); + if (argc) + usage_with_options(builtin_commit_graph_verify_usage, options); if (!opts.obj_dir) opts.obj_dir = get_object_directory(); @@ -262,6 +264,8 @@ static int graph_write(int argc, const char **argv) argc = parse_options(argc, argv, NULL, options, builtin_commit_graph_write_usage, 0); + if (argc) + usage_with_options(builtin_commit_graph_write_usage, options); if (opts.reachable + opts.stdin_packs + opts.stdin_commits > 1) die(_("use at most one of --reachable, --stdin-commits, or --stdin-packs")); |