Skip to content

Commit daf7d86

Browse files
peffgitster
authored andcommitted
silence broken link warnings with revs->ignore_missing_links
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 9cc2b07 commit daf7d86

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

list-objects.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ static void process_tree(struct rev_info *revs,
8181
die("bad tree object");
8282
if (obj->flags & (UNINTERESTING | SEEN))
8383
return;
84-
if (parse_tree(tree) < 0) {
84+
if (parse_tree_gently(tree, revs->ignore_missing_links) < 0) {
8585
if (revs->ignore_missing_links)
8686
return;
8787
die("bad tree object %s", sha1_to_hex(obj->sha1));

revision.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -834,7 +834,7 @@ static int add_parents_to_list(struct rev_info *revs, struct commit *commit,
834834
for (parent = commit->parents; parent; parent = parent->next) {
835835
struct commit *p = parent->item;
836836

837-
if (parse_commit(p) < 0)
837+
if (parse_commit_gently(p, revs->ignore_missing_links) < 0)
838838
return -1;
839839
if (revs->show_source && !p->util)
840840
p->util = commit->util;

t/t6501-freshen-objects.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,4 +129,19 @@ for repack in '' true; do
129129
'
130130
done
131131

132+
test_expect_success 'do not complain about existing broken links' '
133+
cat >broken-commit <<-\EOF &&
134+
tree 0000000000000000000000000000000000000001
135+
parent 0000000000000000000000000000000000000002
136+
author whatever <[email protected]> 1234 -0000
137+
committer whatever <[email protected]> 1234 -0000
138+
139+
some message
140+
EOF
141+
commit=$(git hash-object -t commit -w broken-commit) &&
142+
git gc 2>stderr &&
143+
verbose git cat-file -e $commit &&
144+
test_must_be_empty stderr
145+
'
146+
132147
test_done

0 commit comments

Comments
 (0)