Skip to content

Commit cd57bc4

Browse files
ttaylorrgitster
authored andcommitted
builtin/multi-pack-index.c: display usage on unrecognized command
When given a sub-command that it doesn't understand, 'git multi-pack-index' dies with the following message: $ git multi-pack-index bogus fatal: unrecognized subcommand: bogus Instead of 'die()'-ing, we can display the usage text, which is much more helpful: $ git.compile multi-pack-index bogus error: unrecognized subcommand: bogus usage: git multi-pack-index [<options>] write or: git multi-pack-index [<options>] verify or: git multi-pack-index [<options>] expire or: git multi-pack-index [<options>] repack [--batch-size=<size>] --object-dir <file> object directory containing set of packfile and pack-index pairs --progress force progress reporting While we're at it, clean up some duplication between the "no sub-command" and "unrecognized sub-command" conditionals. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Taylor Blau <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 690eb05 commit cd57bc4

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

builtin/multi-pack-index.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,7 @@ int cmd_multi_pack_index(int argc, const char **argv,
152152
opts.object_dir = get_object_directory();
153153

154154
if (argc == 0)
155-
usage_with_options(builtin_multi_pack_index_usage,
156-
builtin_multi_pack_index_options);
155+
goto usage;
157156

158157
if (!strcmp(argv[0], "repack"))
159158
return cmd_multi_pack_index_repack(argc, argv);
@@ -163,6 +162,10 @@ int cmd_multi_pack_index(int argc, const char **argv,
163162
return cmd_multi_pack_index_verify(argc, argv);
164163
else if (!strcmp(argv[0], "expire"))
165164
return cmd_multi_pack_index_expire(argc, argv);
166-
else
167-
die(_("unrecognized subcommand: %s"), argv[0]);
165+
else {
166+
usage:
167+
error(_("unrecognized subcommand: %s"), argv[0]);
168+
usage_with_options(builtin_multi_pack_index_usage,
169+
builtin_multi_pack_index_options);
170+
}
168171
}

0 commit comments

Comments
 (0)