]> git.ipfire.org Git - thirdparty/git.git/commitdiff
bundle verify: error out if called without an object database
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Mon, 27 May 2019 19:59:14 +0000 (12:59 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 28 May 2019 20:04:14 +0000 (13:04 -0700)
The deal with bundles is: they really are thin packs, 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 <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
bundle.c
t/t5607-clone-bundle.sh

index b45666c49b1c19a63d816527a761d0177d9633ce..b5d21cd80f1cd009a8113ceb34c9a834ddbdbe3a 100644 (file)
--- a/bundle.c
+++ b/bundle.c
@@ -142,6 +142,9 @@ int verify_bundle(struct repository *r,
        int i, ret = 0, req_nr;
        const char *message = _("Repository lacks these prerequisite commits:");
 
+       if (!r || !r->objects || !r->objects->odb)
+               return error(_("need a repository to verify a bundle"));
+
        repo_init_revisions(r, &revs, NULL);
        for (i = 0; i < p->nr; i++) {
                struct ref_list_entry *e = p->list + i;
index cf39e9e2437f06b4725b61ad2194dd65b4857f82..2a0fb15cf175251df0a140aa4f5c56fd7885292d 100755 (executable)
@@ -14,6 +14,12 @@ test_expect_success 'setup' '
        git tag -d third
 '
 
+test_expect_success '"verify" needs a worktree' '
+       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 &&