multi-pack-index: provide more helpful usage info
authorDerrick Stolee <dstolee@microsoft.com>
Mon, 20 Aug 2018 16:51:53 +0000 (16:51 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 20 Aug 2018 22:31:39 +0000 (15:31 -0700)
The multi-pack-index builtin has a very simple command-line
interface. Instead of simply reporting usage, give the user a
hint to why the arguments failed.

Reported-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/multi-pack-index.c
index 6a7aa00cf2e7b1af5597e3cc53b55a14e03eed54..2633efd95d01cd2d3440b203985eab997941a5f6 100644 (file)
@@ -32,16 +32,16 @@ int cmd_multi_pack_index(int argc, const char **argv,
                opts.object_dir = get_object_directory();
 
        if (argc == 0)
-               goto usage;
+               usage_with_options(builtin_multi_pack_index_usage,
+                                  builtin_multi_pack_index_options);
 
-       if (!strcmp(argv[0], "write")) {
-               if (argc > 1)
-                       goto usage;
+       if (argc > 1) {
+               die(_("too many arguments"));
+               return 1;
+       }
 
+       if (!strcmp(argv[0], "write"))
                return write_midx_file(opts.object_dir);
-       }
 
-usage:
-       usage_with_options(builtin_multi_pack_index_usage,
-                          builtin_multi_pack_index_options);
+       die(_("unrecognized verb: %s"), argv[0]);
 }