Merge branch 'jk/diff-filespec-cleanup'
[gitweb.git] / t / t4212-log-corrupt.sh
index 611b687a3cde08cb170124492dc6f6d023342fa8..3fa171541a161e0a5549c316b7c85608eb2d93d6 100755 (executable)
@@ -13,11 +13,16 @@ test_expect_success 'setup' '
        git update-ref refs/heads/broken_email $(cat broken_email.hash)
 '
 
+test_expect_success 'fsck notices broken commit' '
+       git fsck 2>actual &&
+       test_i18ngrep invalid.author actual
+'
+
 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 "Date:   Thu Apr 7 15:13:13 2005 -0700"
                echo
                echo "    foo"
        } >expect.out &&
@@ -30,7 +35,7 @@ test_expect_success 'git log with broken author email' '
 '
 
 test_expect_success 'git log --format with broken author email' '
-       echo "A U Thor+author@example.com+" >expect.out &&
+       echo "A U Thor+author@example.com+Thu Apr 7 15:13:13 2005 -0700" >expect.out &&
        : >expect.err &&
 
        git log --format="%an+%ae+%ad" broken_email >actual.out 2>actual.err &&
@@ -60,4 +65,28 @@ test_expect_success 'unparsable dates produce sentinel value (%ad)' '
        test_cmp expect actual
 '
 
+# date is 2^64 + 1
+test_expect_success 'date parser recognizes integer overflow' '
+       commit=$(munge_author_date HEAD 18446744073709551617) &&
+       echo "Thu Jan 1 00:00:00 1970 +0000" >expect &&
+       git log -1 --format=%ad $commit >actual &&
+       test_cmp expect actual
+'
+
+# date is 2^64 - 2
+test_expect_success 'date parser recognizes time_t overflow' '
+       commit=$(munge_author_date HEAD 18446744073709551614) &&
+       echo "Thu Jan 1 00:00:00 1970 +0000" >expect &&
+       git log -1 --format=%ad $commit >actual &&
+       test_cmp expect actual
+'
+
+# date is within 2^63-1, but enough to choke glibc's gmtime
+test_expect_success 'absurdly far-in-future dates produce sentinel' '
+       commit=$(munge_author_date HEAD 999999999999999999) &&
+       echo "Thu Jan 1 00:00:00 1970 +0000" >expect &&
+       git log -1 --format=%ad $commit >actual &&
+       test_cmp expect actual
+'
+
 test_done