diff options
author | Jeff King <peff@peff.net> | 2023-01-18 23:41:56 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2023-01-18 23:59:44 +0300 |
commit | 34959d80db602b7d6893c9e2dfa81d78fd16f702 (patch) | |
tree | 1278e4d20cc2794c7ad330ec0bf6046566207741 /t/t1450-fsck.sh | |
parent | ad5dfeac040c16057a23f341408d229656e42ab4 (diff) |
t: use hash-object --literally when created malformed objects
Many test scripts use hash-object to create malformed objects to see how
we handle the results in various commands. In some cases we already have
to use "hash-object --literally", because it does some rudimentary
quality checks. But let's use "--literally" more consistently to
future-proof these tests against hash-object learning to be more
careful.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t1450-fsck.sh')
-rwxr-xr-x | t/t1450-fsck.sh | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/t/t1450-fsck.sh b/t/t1450-fsck.sh index de0f6d5e7f..fdb886dfe4 100755 --- a/t/t1450-fsck.sh +++ b/t/t1450-fsck.sh @@ -212,7 +212,7 @@ test_expect_success 'email without @ is okay' ' test_expect_success 'email with embedded > is not okay' ' git cat-file commit HEAD >basis && sed "s/@[a-z]/&>/" basis >bad-email && - new=$(git hash-object -t commit -w --stdin <bad-email) && + new=$(git hash-object --literally -t commit -w --stdin <bad-email) && test_when_finished "remove_object $new" && git update-ref refs/heads/bogus "$new" && test_when_finished "git update-ref -d refs/heads/bogus" && @@ -223,7 +223,7 @@ test_expect_success 'email with embedded > is not okay' ' test_expect_success 'missing < email delimiter is reported nicely' ' git cat-file commit HEAD >basis && sed "s/<//" basis >bad-email-2 && - new=$(git hash-object -t commit -w --stdin <bad-email-2) && + new=$(git hash-object --literally -t commit -w --stdin <bad-email-2) && test_when_finished "remove_object $new" && git update-ref refs/heads/bogus "$new" && test_when_finished "git update-ref -d refs/heads/bogus" && @@ -234,7 +234,7 @@ test_expect_success 'missing < email delimiter is reported nicely' ' test_expect_success 'missing email is reported nicely' ' git cat-file commit HEAD >basis && sed "s/[a-z]* <[^>]*>//" basis >bad-email-3 && - new=$(git hash-object -t commit -w --stdin <bad-email-3) && + new=$(git hash-object --literally -t commit -w --stdin <bad-email-3) && test_when_finished "remove_object $new" && git update-ref refs/heads/bogus "$new" && test_when_finished "git update-ref -d refs/heads/bogus" && @@ -245,7 +245,7 @@ test_expect_success 'missing email is reported nicely' ' test_expect_success '> in name is reported' ' git cat-file commit HEAD >basis && sed "s/ </> </" basis >bad-email-4 && - new=$(git hash-object -t commit -w --stdin <bad-email-4) && + new=$(git hash-object --literally -t commit -w --stdin <bad-email-4) && test_when_finished "remove_object $new" && git update-ref refs/heads/bogus "$new" && test_when_finished "git update-ref -d refs/heads/bogus" && @@ -258,7 +258,7 @@ test_expect_success 'integer overflow in timestamps is reported' ' git cat-file commit HEAD >basis && sed "s/^\\(author .*>\\) [0-9]*/\\1 18446744073709551617/" \ <basis >bad-timestamp && - new=$(git hash-object -t commit -w --stdin <bad-timestamp) && + new=$(git hash-object --literally -t commit -w --stdin <bad-timestamp) && test_when_finished "remove_object $new" && git update-ref refs/heads/bogus "$new" && test_when_finished "git update-ref -d refs/heads/bogus" && @@ -269,7 +269,7 @@ test_expect_success 'integer overflow in timestamps is reported' ' test_expect_success 'commit with NUL in header' ' git cat-file commit HEAD >basis && sed "s/author ./author Q/" <basis | q_to_nul >commit-NUL-header && - new=$(git hash-object -t commit -w --stdin <commit-NUL-header) && + new=$(git hash-object --literally -t commit -w --stdin <commit-NUL-header) && test_when_finished "remove_object $new" && git update-ref refs/heads/bogus "$new" && test_when_finished "git update-ref -d refs/heads/bogus" && @@ -292,7 +292,7 @@ test_expect_success 'tree object with duplicate entries' ' git cat-file tree $T && git cat-file tree $T ) | - git hash-object -w -t tree --stdin + git hash-object --literally -w -t tree --stdin ) && test_must_fail git fsck 2>out && test_i18ngrep "error in tree .*contains duplicate file entries" out @@ -426,7 +426,7 @@ test_expect_success 'tag with incorrect tag name & missing tagger' ' This is an invalid tag. EOF - tag=$(git hash-object -t tag -w --stdin <wrong-tag) && + tag=$(git hash-object --literally -t tag -w --stdin <wrong-tag) && test_when_finished "remove_object $tag" && echo $tag >.git/refs/tags/wrong && test_when_finished "git update-ref -d refs/tags/wrong" && @@ -558,7 +558,7 @@ test_expect_success 'rev-list --verify-objects with commit graph (parent)' ' test_expect_success 'force fsck to ignore double author' ' git cat-file commit HEAD >basis && sed "s/^author .*/&,&/" <basis | tr , \\n >multiple-authors && - new=$(git hash-object -t commit -w --stdin <multiple-authors) && + new=$(git hash-object --literally -t commit -w --stdin <multiple-authors) && test_when_finished "remove_object $new" && git update-ref refs/heads/bogus "$new" && test_when_finished "git update-ref -d refs/heads/bogus" && @@ -573,7 +573,7 @@ test_expect_success 'fsck notices blob entry pointing to null sha1' ' (git init null-blob && cd null-blob && sha=$(printf "100644 file$_bz$_bzoid" | - git hash-object -w --stdin -t tree) && + git hash-object --literally -w --stdin -t tree) && git fsck 2>out && test_i18ngrep "warning.*null sha1" out ) @@ -583,7 +583,7 @@ test_expect_success 'fsck notices submodule entry pointing to null sha1' ' (git init null-commit && cd null-commit && sha=$(printf "160000 submodule$_bz$_bzoid" | - git hash-object -w --stdin -t tree) && + git hash-object --literally -w --stdin -t tree) && git fsck 2>out && test_i18ngrep "warning.*null sha1" out ) @@ -648,7 +648,7 @@ test_expect_success 'NUL in commit' ' git commit --allow-empty -m "initial commitQNUL after message" && git cat-file commit HEAD >original && q_to_nul <original >munged && - git hash-object -w -t commit --stdin <munged >name && + git hash-object --literally -w -t commit --stdin <munged >name && git branch bad $(cat name) && test_must_fail git -c fsck.nulInCommit=error fsck 2>warn.1 && @@ -794,8 +794,8 @@ test_expect_success 'fsck errors in packed objects' ' git cat-file commit HEAD >basis && sed "s/</one/" basis >one && sed "s/</foo/" basis >two && - one=$(git hash-object -t commit -w one) && - two=$(git hash-object -t commit -w two) && + one=$(git hash-object --literally -t commit -w one) && + two=$(git hash-object --literally -t commit -w two) && pack=$( { echo $one && |