]>
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 && | |
29 | : >expect.err && | |
30 | ||
31 | git log broken_email >actual.out 2>actual.err && | |
32 | ||
33 | test_cmp expect.out actual.out && | |
34 | test_cmp expect.err actual.err | |
35 | ' | |
36 | ||
37 | test_expect_success 'git log --format with broken author email' ' | |
03818a4a | 38 | echo "A U Thor+author@example.com+Thu Apr 7 15:13:13 2005 -0700" >expect.out && |
9dbe7c3d RS |
39 | : >expect.err && |
40 | ||
41 | git log --format="%an+%ae+%ad" broken_email >actual.out 2>actual.err && | |
42 | ||
43 | test_cmp expect.out actual.out && | |
44 | test_cmp expect.err actual.err | |
45 | ' | |
46 | ||
7d9a2819 JK |
47 | munge_author_date () { |
48 | git cat-file commit "$1" >commit.orig && | |
49 | sed "s/^\(author .*>\) [0-9]*/\1 $2/" <commit.orig >commit.munge && | |
50 | git hash-object -w -t commit commit.munge | |
51 | } | |
52 | ||
53 | test_expect_success 'unparsable dates produce sentinel value' ' | |
54 | commit=$(munge_author_date HEAD totally_bogus) && | |
55 | echo "Date: Thu Jan 1 00:00:00 1970 +0000" >expect && | |
56 | git log -1 $commit >actual.full && | |
57 | grep Date <actual.full >actual && | |
58 | test_cmp expect actual | |
59 | ' | |
60 | ||
61 | test_expect_success 'unparsable dates produce sentinel value (%ad)' ' | |
62 | commit=$(munge_author_date HEAD totally_bogus) && | |
63 | echo >expect && | |
60687de5 | 64 | git log -1 --format=%ad $commit >actual && |
7d9a2819 JK |
65 | test_cmp expect actual |
66 | ' | |
67 | ||
1dca155f JK |
68 | # date is 2^64 + 1 |
69 | test_expect_success 'date parser recognizes integer overflow' ' | |
70 | commit=$(munge_author_date HEAD 18446744073709551617) && | |
71 | echo "Thu Jan 1 00:00:00 1970 +0000" >expect && | |
72 | git log -1 --format=%ad $commit >actual && | |
73 | test_cmp expect actual | |
74 | ' | |
75 | ||
76 | # date is 2^64 - 2 | |
77 | test_expect_success 'date parser recognizes time_t overflow' ' | |
78 | commit=$(munge_author_date HEAD 18446744073709551614) && | |
79 | echo "Thu Jan 1 00:00:00 1970 +0000" >expect && | |
80 | git log -1 --format=%ad $commit >actual && | |
81 | test_cmp expect actual | |
82 | ' | |
83 | ||
2b15846d | 84 | # date is within 2^63-1, but enough to choke glibc's gmtime |
f80d1f95 | 85 | test_expect_success 'absurdly far-in-future date' ' |
2b15846d | 86 | commit=$(munge_author_date HEAD 999999999999999999) && |
f80d1f95 | 87 | git log -1 --format=%ad $commit |
2b15846d JK |
88 | ' |
89 | ||
9dbe7c3d | 90 | test_done |