]>
Commit | Line | Data |
---|---|---|
9dbe7c3d RS |
1 | #!/bin/sh |
2 | ||
3 | test_description='git log with invalid commit headers' | |
4 | ||
5 | . ./test-lib.sh | |
6 | ||
7 | test_expect_success 'setup' ' | |
8 | test_commit foo && | |
9 | ||
10 | git cat-file commit HEAD | | |
11 | sed "/^author /s/>/>-<>/" >broken_email.commit && | |
12 | git hash-object -w -t commit broken_email.commit >broken_email.hash && | |
13 | git update-ref refs/heads/broken_email $(cat broken_email.hash) | |
14 | ' | |
15 | ||
03818a4a | 16 | test_expect_success 'fsck notices broken commit' ' |
2e770fe4 | 17 | test_must_fail git fsck 2>actual && |
03818a4a JK |
18 | test_i18ngrep invalid.author actual |
19 | ' | |
20 | ||
9dbe7c3d RS |
21 | test_expect_success 'git log with broken author email' ' |
22 | { | |
23 | echo commit $(cat broken_email.hash) | |
24 | echo "Author: A U Thor <author@example.com>" | |
03818a4a | 25 | echo "Date: Thu Apr 7 15:13:13 2005 -0700" |
9dbe7c3d RS |
26 | echo |
27 | echo " foo" | |
28 | } >expect.out && | |
9dbe7c3d RS |
29 | |
30 | git log broken_email >actual.out 2>actual.err && | |
31 | ||
32 | test_cmp expect.out actual.out && | |
1c5e94f4 | 33 | test_must_be_empty actual.err |
9dbe7c3d RS |
34 | ' |
35 | ||
36 | test_expect_success 'git log --format with broken author email' ' | |
03818a4a | 37 | echo "A U Thor+author@example.com+Thu Apr 7 15:13:13 2005 -0700" >expect.out && |
9dbe7c3d RS |
38 | |
39 | git log --format="%an+%ae+%ad" broken_email >actual.out 2>actual.err && | |
40 | ||
41 | test_cmp expect.out actual.out && | |
1c5e94f4 | 42 | test_must_be_empty actual.err |
9dbe7c3d RS |
43 | ' |
44 | ||
7d9a2819 JK |
45 | munge_author_date () { |
46 | git cat-file commit "$1" >commit.orig && | |
47 | sed "s/^\(author .*>\) [0-9]*/\1 $2/" <commit.orig >commit.munge && | |
48 | git hash-object -w -t commit commit.munge | |
49 | } | |
50 | ||
51 | test_expect_success 'unparsable dates produce sentinel value' ' | |
52 | commit=$(munge_author_date HEAD totally_bogus) && | |
53 | echo "Date: Thu Jan 1 00:00:00 1970 +0000" >expect && | |
54 | git log -1 $commit >actual.full && | |
55 | grep Date <actual.full >actual && | |
56 | test_cmp expect actual | |
57 | ' | |
58 | ||
59 | test_expect_success 'unparsable dates produce sentinel value (%ad)' ' | |
60 | commit=$(munge_author_date HEAD totally_bogus) && | |
61 | echo >expect && | |
60687de5 | 62 | git log -1 --format=%ad $commit >actual && |
7d9a2819 JK |
63 | test_cmp expect actual |
64 | ' | |
65 | ||
1dca155f JK |
66 | # date is 2^64 + 1 |
67 | test_expect_success 'date parser recognizes integer overflow' ' | |
68 | commit=$(munge_author_date HEAD 18446744073709551617) && | |
69 | echo "Thu Jan 1 00:00:00 1970 +0000" >expect && | |
70 | git log -1 --format=%ad $commit >actual && | |
71 | test_cmp expect actual | |
72 | ' | |
73 | ||
74 | # date is 2^64 - 2 | |
75 | test_expect_success 'date parser recognizes time_t overflow' ' | |
76 | commit=$(munge_author_date HEAD 18446744073709551614) && | |
77 | echo "Thu Jan 1 00:00:00 1970 +0000" >expect && | |
78 | git log -1 --format=%ad $commit >actual && | |
79 | test_cmp expect actual | |
80 | ' | |
81 | ||
2b15846d | 82 | # date is within 2^63-1, but enough to choke glibc's gmtime |
f80d1f95 | 83 | test_expect_success 'absurdly far-in-future date' ' |
2b15846d | 84 | commit=$(munge_author_date HEAD 999999999999999999) && |
f80d1f95 | 85 | git log -1 --format=%ad $commit |
2b15846d JK |
86 | ' |
87 | ||
9dbe7c3d | 88 | test_done |