All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: git@vger.kernel.org
Cc: "Stefan Näwe" <stefan.naewe@atlas-elektronik.com>
Subject: [PATCH 2/3] silence broken link warnings with revs->ignore_missing_links
Date: Mon, 1 Jun 2015 05:56:37 -0400	[thread overview]
Message-ID: <20150601095636.GB31389@peff.net> (raw)
In-Reply-To: <20150601095410.GA16976@peff.net>

We set revs->ignore_missing_links to instruct the
revision-walking machinery that we know the history graph
may be incomplete. For example, we use it when walking
unreachable but recent objects; we want to add what we can,
but it's OK if the history is incomplete.

However, we still print error messages for the missing
objects, which can be confusing. This is not an error, but
just a normal situation when transitioning from a repository
last pruned by an older git (which can leave broken segments
of history) to a more recent one (where we try to preserve
whole reachable segments).

Signed-off-by: Jeff King <peff@peff.net>
---
 list-objects.c             |  2 +-
 revision.c                 |  2 +-
 t/t6501-freshen-objects.sh | 15 +++++++++++++++
 3 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/list-objects.c b/list-objects.c
index 2a139b6..41736d2 100644
--- a/list-objects.c
+++ b/list-objects.c
@@ -81,7 +81,7 @@ static void process_tree(struct rev_info *revs,
 		die("bad tree object");
 	if (obj->flags & (UNINTERESTING | SEEN))
 		return;
-	if (parse_tree(tree) < 0) {
+	if (parse_tree_gently(tree, revs->ignore_missing_links) < 0) {
 		if (revs->ignore_missing_links)
 			return;
 		die("bad tree object %s", sha1_to_hex(obj->sha1));
diff --git a/revision.c b/revision.c
index 7ddbaa0..29e5143 100644
--- a/revision.c
+++ b/revision.c
@@ -844,7 +844,7 @@ static int add_parents_to_list(struct rev_info *revs, struct commit *commit,
 	for (parent = commit->parents; parent; parent = parent->next) {
 		struct commit *p = parent->item;
 
-		if (parse_commit(p) < 0)
+		if (parse_commit_gently(p, revs->ignore_missing_links) < 0)
 			return -1;
 		if (revs->show_source && !p->util)
 			p->util = commit->util;
diff --git a/t/t6501-freshen-objects.sh b/t/t6501-freshen-objects.sh
index 157f3f9..2adf825 100755
--- a/t/t6501-freshen-objects.sh
+++ b/t/t6501-freshen-objects.sh
@@ -129,4 +129,19 @@ for repack in '' true; do
 	'
 done
 
+test_expect_success 'do not complain about existing broken links' '
+	cat >broken-commit <<-\EOF &&
+	tree 0000000000000000000000000000000000000001
+	parent 0000000000000000000000000000000000000002
+	author whatever <whatever@example.com> 1234 -0000
+	committer whatever <whatever@example.com> 1234 -0000
+
+	some message
+	EOF
+	commit=$(git hash-object -t commit -w broken-commit) &&
+	git gc 2>stderr &&
+	verbose git cat-file -e $commit &&
+	test_must_be_empty stderr
+'
+
 test_done
-- 
2.4.2.690.g2a79674

  parent reply	other threads:[~2015-06-01  9:57 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-01  7:37 git gc gives "error: Could not read..." Stefan Näwe
2015-06-01  8:14 ` Jeff King
2015-06-01  8:40   ` Stefan Näwe
2015-06-01  8:52     ` Jeff King
2015-06-01  9:14       ` Stefan Näwe
2015-06-01  9:58         ` Jeff King
2015-06-01 10:08           ` Stefan Näwe
2015-06-01 10:22             ` Jeff King
2015-06-01  9:54       ` [RFC/PATCH 0/3] silence missing-link warnings in some cases Jeff King
2015-06-01  9:56         ` [PATCH 1/3] add quieter versions of parse_{tree,commit} Jeff King
2015-06-01  9:56         ` Jeff King [this message]
2015-06-01  9:56         ` [PATCH 3/3] suppress errors on missing UNINTERESTING links Jeff King
2015-06-01 15:03         ` [RFC/PATCH 0/3] silence missing-link warnings in some cases Junio C Hamano
2015-06-01 15:41           ` Jeff King
2015-06-01 16:11             ` Junio C Hamano

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

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

  git send-email \
    --in-reply-to=20150601095636.GB31389@peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=stefan.naewe@atlas-elektronik.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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.