bundle: verify arguments more strictly
The `verify` and `create` subcommands of the bundle builtin do not properly verify the command line arguments that have been passed in. While the `verify` subcommand accepts an arbitrary amount of ignored arguments the `create` subcommand does not complain about being passed too few arguments, resulting in a bogus call to `git rev-list`. Fix these errors by verifying that the correct amount of arguments has been passed in. Signed-off-by: Patrick Steinhardt <ps@pks.im> Acked-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Patrick Steinhardt committed
May 8, 2015 at 10:02 UTC
7886cfa08054046a7a82726be4b8c109b2ba1344
1 file changed
+8
builtin/bundle.c
+8
@@ -42,6 +42,10 @@ int cmd_bundle(int argc, const char **argv, const char *prefix)
42
43
if (!strcmp(cmd, "verify")) {
44
close(bundle_fd);
45
+ if (argc != 1) {
46
+ usage(builtin_bundle_usage);
47
+ return 1;
48
+ }
49
if (verify_bundle(&header, 1))
50
return 1;
51
fprintf(stderr, _("%s is okay\n"), bundle_file);
@@ -52,6 +56,10 @@ int cmd_bundle(int argc, const char **argv, const char *prefix)
56
return !!list_bundle_refs(&header, argc, argv);
57
}
58
if (!strcmp(cmd, "create")) {
59
+ if (argc < 2) {
60
+ usage(builtin_bundle_usage);
61
+ return 1;
62
+ }
63
if (!startup_info->have_repository)
64
die(_("Need a repository to create a bundle."));
65
return !!create_bundle(&header, bundle_file, argc, argv);