Skip to content

Commit a3ba6bf

Browse files
peffgitster
authored andcommitted
revision.c: ignore broken tags with ignore_missing_links
When peeling a tag for prepare_revision_walk(), we do not respect the ignore_missing_links flag. This can lead to a bogus error when pack-objects walks the possibly-broken unreachable-but-recent part of the object graph. The other link-following all happens via traverse_commit_list(), which explains why this case was missed. And our tests covered only broken links from commits. Let's be more comprehensive and cover broken tree entries (which do work) and tags (which shows off this bug). Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 840ed14 commit a3ba6bf

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

revision.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ static struct commit *handle_commit(struct rev_info *revs,
230230
die("bad tag");
231231
object = parse_object(tag->tagged->oid.hash);
232232
if (!object) {
233-
if (flags & UNINTERESTING)
233+
if (revs->ignore_missing_links || (flags & UNINTERESTING))
234234
return NULL;
235235
die("bad object %s", oid_to_hex(&tag->tagged->oid));
236236
}

t/t6501-freshen-objects.sh

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ for repack in '' true; do
129129
'
130130
done
131131

132-
test_expect_success 'do not complain about existing broken links' '
132+
test_expect_success 'do not complain about existing broken links (commit)' '
133133
cat >broken-commit <<-\EOF &&
134134
tree 0000000000000000000000000000000000000001
135135
parent 0000000000000000000000000000000000000002
@@ -144,4 +144,29 @@ test_expect_success 'do not complain about existing broken links' '
144144
test_must_be_empty stderr
145145
'
146146

147+
test_expect_success 'do not complain about existing broken links (tree)' '
148+
cat >broken-tree <<-\EOF &&
149+
100644 blob 0000000000000000000000000000000000000003 foo
150+
EOF
151+
tree=$(git mktree --missing <broken-tree) &&
152+
git gc 2>stderr &&
153+
git cat-file -e $tree &&
154+
test_must_be_empty stderr
155+
'
156+
157+
test_expect_success 'do not complain about existing broken links (tag)' '
158+
cat >broken-tag <<-\EOF &&
159+
object 0000000000000000000000000000000000000004
160+
type commit
161+
tag broken
162+
tagger whatever <[email protected]> 1234 -0000
163+
164+
this is a broken tag
165+
EOF
166+
tag=$(git hash-object -t tag -w broken-tag) &&
167+
git gc 2>stderr &&
168+
git cat-file -e $tag &&
169+
test_must_be_empty stderr
170+
'
171+
147172
test_done

0 commit comments

Comments
 (0)