Skip to content

Commit b42b41b

Browse files
committed
Merge branch 'jk/ignore-broken-tags-when-ignoring-missing-links'
Tag objects, which are not reachable from any ref, that point at missing objects were mishandled by "git gc" and friends (they should silently be ignored instead) * jk/ignore-broken-tags-when-ignoring-missing-links: revision.c: ignore broken tags with ignore_missing_links
2 parents 69b050e + a3ba6bf commit b42b41b

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);
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)