Skip to content

Commit 3bbbe46

Browse files
dschogitster
authored andcommitted
bundle verify: error out if called without an object database
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent aeb582a commit 3bbbe46

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

bundle.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,9 @@ int verify_bundle(struct repository *r,
142142
int i, ret = 0, req_nr;
143143
const char *message = _("Repository lacks these prerequisite commits:");
144144

145+
if (!r || !r->objects || !r->objects->odb)
146+
return error(_("need a repository to verify a bundle"));
147+
145148
repo_init_revisions(r, &revs, NULL);
146149
for (i = 0; i < p->nr; i++) {
147150
struct ref_list_entry *e = p->list + i;

t/t5607-clone-bundle.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ test_expect_success 'setup' '
1414
git tag -d third
1515
'
1616

17+
test_expect_success '"verify" needs a worktree' '
18+
git bundle create tip.bundle -1 master &&
19+
test_must_fail nongit git bundle verify ../tip.bundle 2>err &&
20+
test_i18ngrep "need a repository" err
21+
'
22+
1723
test_expect_success 'annotated tags can be excluded by rev-list options' '
1824
git bundle create bundle --all --since=7.Apr.2005.15:14:00.-0700 &&
1925
git ls-remote bundle > output &&

0 commit comments

Comments
 (0)