Skip to content

Commit f99b7af

Browse files
dschogitster
authored andcommitted
Make sure that index-pack --strict checks tag objects
One of the most important use cases for the strict tag object checking is when transfer.fsckobjects is set to true to catch invalid objects early on. This new regression test essentially tests the same code path by directly calling 'index-pack --strict' on a pack containing an tag object without a 'tagger' line. Technically, this test is not enough: it only exercises a code path that *warns*, not one that *fails*. The reason is that hash-object and pack-objects both insist on parsing the tag objects and would fail on invalid tag objects at this time. Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 90e3e5f commit f99b7af

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

t/t5302-pack-index.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,4 +243,23 @@ test_expect_success 'running index-pack in the object store' '
243243
test -f .git/objects/pack/pack-${pack1}.idx
244244
'
245245

246+
test_expect_success 'index-pack --strict warns upon missing tagger in tag' '
247+
sha=$(git rev-parse HEAD) &&
248+
cat >wrong-tag <<EOF &&
249+
object $sha
250+
type commit
251+
tag guten tag
252+
253+
This is an invalid tag.
254+
EOF
255+
256+
tag=$(git hash-object -t tag -w --stdin <wrong-tag) &&
257+
pack1=$(echo $tag $sha | git pack-objects tag-test) &&
258+
echo remove tag object &&
259+
thirtyeight=${tag#??} &&
260+
rm -f .git/objects/${tag%$thirtyeight}/$thirtyeight &&
261+
git index-pack --strict tag-test-${pack1}.pack 2>err &&
262+
grep "^error:.* expected .tagger. line" err
263+
'
264+
246265
test_done

0 commit comments

Comments
 (0)