git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: "Konstantin Ryabitsev" <konstantin@linuxfoundation.org>,
	"SZEDER Gábor" <szeder.dev@gmail.com>,
	"Junio C Hamano" <gitster@pobox.com>,
	"Johannes Schindelin" <johannes.schindelin@gmx.de>
Subject: [PATCH 1/1] bundle verify: error out if called without an object database
Date: Mon, 27 May 2019 12:59:14 -0700 (PDT)	[thread overview]
Message-ID: <f0545e872344dd25e11db7fe095cde1578b26748.1558987152.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.226.git.gitgitgadget@gmail.com>

From: Johannes Schindelin <johannes.schindelin@gmx.de>

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>
---
 bundle.c                | 3 +++
 t/t5607-clone-bundle.sh | 6 ++++++
 2 files changed, 9 insertions(+)

diff --git a/bundle.c b/bundle.c
index b45666c49b..b5d21cd80f 100644
--- 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;
diff --git a/t/t5607-clone-bundle.sh b/t/t5607-clone-bundle.sh
index cf39e9e243..2a0fb15cf1 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 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 &&
-- 
gitgitgadget

  reply	other threads:[~2019-05-27 19:59 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-27 19:59 [PATCH 0/1] bundle verify: improve the user experience when called without a .git/ directory Johannes Schindelin via GitGitGadget
2019-05-27 19:59 ` Johannes Schindelin via GitGitGadget [this message]
2019-05-27 20:08   ` [PATCH 1/1] bundle verify: error out if called without an object database brian m. carlson
2019-05-27 20:20     ` Johannes Schindelin
2019-05-28  1:51   ` Jeff King
2019-05-28 11:17     ` Johannes Schindelin
2019-05-28 20:58       ` Jeff King
2019-05-28 20:03     ` Junio C Hamano
2019-05-28 21:04       ` Jeff King
2019-05-28 21:09         ` Junio C Hamano
     [not found] ` <pull.226.v2.git.gitgitgadget@gmail.com>
     [not found]   ` <8467593c158ffac56897cf02e165173d9c0b5880.1558988458.git.gitgitgadget@gmail.com>
2019-05-27 20:25     ` [PATCH v2 " brian m. carlson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f0545e872344dd25e11db7fe095cde1578b26748.1558987152.git.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=johannes.schindelin@gmx.de \
    --cc=konstantin@linuxfoundation.org \
    --cc=szeder.dev@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).