diff options
author | Junio C Hamano <gitster@pobox.com> | 2013-04-22 11:11:36 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2013-04-22 11:11:36 -0700 |
commit | 703319313fc2878c0c28ccc14a488024e8687fc2 (patch) | |
tree | 98ead8765fa14f86b491b72896aa3f19871f692f /t | |
parent | Merge branch 'th/bisect-final-log' (diff) | |
parent | blame: handle broken commit headers gracefully (diff) | |
download | tgif-703319313fc2878c0c28ccc14a488024e8687fc2.tar.xz |
Merge branch 'jk/chopped-ident'
A commit object whose author or committer ident are malformed
crashed some code that trusted that a name, an email and an
timestamp can always be found in it.
* jk/chopped-ident:
blame: handle broken commit headers gracefully
pretty: handle broken commit headers gracefully
cat-file: print tags raw for "cat-file -p"
Diffstat (limited to 't')
-rwxr-xr-x | t/t1006-cat-file.sh | 5 | ||||
-rwxr-xr-x | t/t4212-log-corrupt.sh | 42 |
2 files changed, 43 insertions, 4 deletions
diff --git a/t/t1006-cat-file.sh b/t/t1006-cat-file.sh index 9820f70c84..9cc5c6bf4d 100755 --- a/t/t1006-cat-file.sh +++ b/t/t1006-cat-file.sh @@ -135,14 +135,11 @@ tag_description="This is a tag" tag_content="$tag_header_without_timestamp 0000000000 +0000 $tag_description" -tag_pretty_content="$tag_header_without_timestamp Thu Jan 1 00:00:00 1970 +0000 - -$tag_description" tag_sha1=$(echo_without_newline "$tag_content" | git mktag) tag_size=$(strlen "$tag_content") -run_tests 'tag' $tag_sha1 $tag_size "$tag_content" "$tag_pretty_content" 1 +run_tests 'tag' $tag_sha1 $tag_size "$tag_content" "$tag_content" 1 test_expect_success \ "Reach a blob from a tag pointing to it" \ diff --git a/t/t4212-log-corrupt.sh b/t/t4212-log-corrupt.sh new file mode 100755 index 0000000000..ec5099b83d --- /dev/null +++ b/t/t4212-log-corrupt.sh @@ -0,0 +1,42 @@ +#!/bin/sh + +test_description='git log with invalid commit headers' + +. ./test-lib.sh + +test_expect_success 'setup' ' + test_commit foo && + + git cat-file commit HEAD | + sed "/^author /s/>/>-<>/" >broken_email.commit && + git hash-object -w -t commit broken_email.commit >broken_email.hash && + git update-ref refs/heads/broken_email $(cat broken_email.hash) +' + +test_expect_success 'git log with broken author email' ' + { + echo commit $(cat broken_email.hash) + echo "Author: A U Thor <author@example.com>" + echo "Date: Thu Jan 1 00:00:00 1970 +0000" + echo + echo " foo" + } >expect.out && + : >expect.err && + + git log broken_email >actual.out 2>actual.err && + + test_cmp expect.out actual.out && + test_cmp expect.err actual.err +' + +test_expect_success 'git log --format with broken author email' ' + echo "A U Thor+author@example.com+" >expect.out && + : >expect.err && + + git log --format="%an+%ae+%ad" broken_email >actual.out 2>actual.err && + + test_cmp expect.out actual.out && + test_cmp expect.err actual.err +' + +test_done |