diff options
author | Taylor Blau <me@ttaylorr.com> | 2021-07-19 13:18:49 -0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-07-19 15:24:01 -0700 |
commit | 88617d11f9d2ee1ea726cef4527d676a9a46fa63 (patch) | |
tree | af4a1eb9295906c3127654c51cc7a75b4433f153 /builtin/multi-pack-index.c | |
parent | midx.c: improve cache locality in midx_pack_order_cmp() (diff) | |
download | tgif-88617d11f9d2ee1ea726cef4527d676a9a46fa63.tar.xz |
multi-pack-index: fix potential segfault without sub-command
Since cd57bc41bb (builtin/multi-pack-index.c: display usage on
unrecognized command, 2021-03-30) we have used a "usage" label to avoid
having two separate callers of usage_with_options (one when no arguments
are given, and another for unrecognized sub-commands).
But the first caller has been broken since cd57bc41bb, since it will
happily jump to usage without arguments, and then pass argv[0] to the
"unrecognized subcommand" error.
Many compilers will save us from a segfault here, but the end result is
ugly, since it mentions an unrecognized subcommand when we didn't even
pass one, and (on GCC) includes "(null)" in its output.
Move the "usage" label down past the error about unrecognized
subcommands so that it is only triggered when it should be. While we're
at it, bulk up our test coverage in this area, too.
Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/multi-pack-index.c')
-rw-r--r-- | builtin/multi-pack-index.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/builtin/multi-pack-index.c b/builtin/multi-pack-index.c index 5d3ea445fd..8ff0dee2ec 100644 --- a/builtin/multi-pack-index.c +++ b/builtin/multi-pack-index.c @@ -176,8 +176,8 @@ int cmd_multi_pack_index(int argc, const char **argv, else if (!strcmp(argv[0], "expire")) return cmd_multi_pack_index_expire(argc, argv); else { -usage: error(_("unrecognized subcommand: %s"), argv[0]); +usage: usage_with_options(builtin_multi_pack_index_usage, builtin_multi_pack_index_options); } |