Skip to content

Commit

Permalink
bundle: verify arguments more strictly
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Patrick Steinhardt authored and Junio C Hamano committed May 8, 2015
1 parent 282616c commit 7886cfa
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions builtin/bundle.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ int cmd_bundle(int argc, const char **argv, const char *prefix)

if (!strcmp(cmd, "verify")) {
close(bundle_fd);
if (argc != 1) {
usage(builtin_bundle_usage);
return 1;
}
if (verify_bundle(&header, 1))
return 1;
fprintf(stderr, _("%s is okay\n"), bundle_file);
Expand All @@ -52,6 +56,10 @@ int cmd_bundle(int argc, const char **argv, const char *prefix)
return !!list_bundle_refs(&header, argc, argv);
}
if (!strcmp(cmd, "create")) {
if (argc < 2) {
usage(builtin_bundle_usage);
return 1;
}
if (!startup_info->have_repository)
die(_("Need a repository to create a bundle."));
return !!create_bundle(&header, bundle_file, argc, argv);
Expand Down

0 comments on commit 7886cfa

Please sign in to comment.