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 <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Johannes Schindelin committed
May 27, 2019 at 12:59 UTC
3bbbe467f294fae8a286e47af676fa783ad970c1
2 files changed
+9
bundle.c
+3
@@ -142,6 +142,9 @@ int verify_bundle(struct repository *r,
142
int i, ret = 0, req_nr;
143
const char *message = _("Repository lacks these prerequisite commits:");
144
145
+ if (!r || !r->objects || !r->objects->odb)
146
+ return error(_("need a repository to verify a bundle"));
147
+
148
repo_init_revisions(r, &revs, NULL);
149
for (i = 0; i < p->nr; i++) {
150
struct ref_list_entry *e = p->list + i;
t/t5607-clone-bundle.sh
+6
@@ -14,6 +14,12 @@ test_expect_success 'setup' '
14
git tag -d third
15
'
16
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
+
23
test_expect_success 'annotated tags can be excluded by rev-list options' '
24
git bundle create bundle --all --since=7.Apr.2005.15:14:00.-0700 &&
25
git ls-remote bundle > output &&