From b471c5cd4660fda49eeea6402b6525e4e0cedf8d Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Mon, 27 May 2019 21:26:17 +0200 Subject: [PATCH] bundle verify: error out if called without an object database Bundles really are thin packs (i.e. in general, they require an object database to reconstruct deltified objects), with very little sugar on top. So we really need a repository (or more appropriately, an object database) to work with, when asked to verify a bundle. Let's error out with a useful error message if `git bundle verify` is called without such an object database to work with. Reported by Konstantin Ryabitsev. Signed-off-by: Johannes Schindelin --- builtin/bundle.c | 2 ++ t/t5607-clone-bundle.sh | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/builtin/bundle.c b/builtin/bundle.c index 1ea4bfdfc19868..4eb051f74610c9 100644 --- a/builtin/bundle.c +++ b/builtin/bundle.c @@ -40,6 +40,8 @@ int cmd_bundle(int argc, const char **argv, const char *prefix) usage(builtin_bundle_usage); return 1; } + if (!startup_info->have_repository) + die(_("Need a repository to create a bundle.")); if (verify_bundle(the_repository, &header, 1)) return 1; fprintf(stderr, _("%s is okay\n"), bundle_file); diff --git a/t/t5607-clone-bundle.sh b/t/t5607-clone-bundle.sh index cf39e9e2437f06..4281147c0c577d 100755 --- a/t/t5607-clone-bundle.sh +++ b/t/t5607-clone-bundle.sh @@ -14,6 +14,12 @@ test_expect_success 'setup' ' git tag -d third ' +test_expect_success '"verify" needs a repository' ' + git bundle create tip.bundle -1 master && + test_must_fail nongit git bundle verify ../tip.bundle 2>err && + test_i18ngrep "Need a repository" err +' + test_expect_success 'annotated tags can be excluded by rev-list options' ' git bundle create bundle --all --since=7.Apr.2005.15:14:00.-0700 && git ls-remote bundle > output &&