Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/git/blob/master/t/t4212-log-corrupt.sh # git [Ported from github.com/git/git] Sync with Git 2.56.1 Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `git / t / t4212-log-corrupt.sh` 135 lines ยท 4387 bytes Raw Blame History 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 >ok.commit && 11 sed "s/>/>-<>/" broken_email.commit && 12 13 git hash-object --literally -w -t commit broken_email.commit >broken_email.hash && 14 git update-ref refs/heads/broken_email $(cat broken_email.hash) 15 ' 16 17 test_expect_success 'fsck notices broken commit' ' 18 test_must_fail git fsck 2>actual && 19 test_grep invalid.author actual 20 ' 21 22 test_expect_success 'git log with broken author email' ' 23 { 24 echo commit $(cat broken_email.hash) && 25 echo "Author: A U Thor " && 26 echo "Date: Thu Apr 7 15:13:13 2005 -0700" && 27 echo && 28 echo " foo" 29 } >expect.out && 30 31 git log broken_email >actual.out 2>actual.err && 32 33 test_cmp expect.out actual.out && 34 test_must_be_empty actual.err 35 ' 36 37 test_expect_success 'git log --format with broken author email' ' 38 echo "A U Thor+author@example.com+Thu Apr 7 15:13:13 2005 -0700" >expect.out && 39 40 git log --format="%an+%ae+%ad" broken_email >actual.out 2>actual.err && 41 42 test_cmp expect.out actual.out && 43 test_must_be_empty actual.err 44 ' 45 46 test_expect_success '--until handles broken email' ' 47 git rev-list --until=1980-01-01 broken_email >actual && 48 test_must_be_empty actual 49 ' 50 51 munge_author_date () { 52 git cat-file commit "$1" >commit.orig && 53 sed "s/^\(author .*>\) [0-9]*/\1 $2/" commit.munge && 54 git hash-object --literally -w -t commit commit.munge 55 } 56 57 test_expect_success 'unparsable dates produce sentinel value' ' 58 commit=$(munge_author_date HEAD totally_bogus) && 59 echo "Date: Thu Jan 1 00:00:00 1970 +0000" >expect && 60 git log -1 $commit >actual.full && 61 grep Date actual && 62 test_cmp expect actual 63 ' 64 65 test_expect_success 'unparsable dates produce sentinel value (%ad)' ' 66 commit=$(munge_author_date HEAD totally_bogus) && 67 echo >expect && 68 git log -1 --format=%ad $commit >actual && 69 test_cmp expect actual 70 ' 71 72 # date is 2^64 + 1 73 test_expect_success 'date parser recognizes integer overflow' ' 74 commit=$(munge_author_date HEAD `18446744073709551617`) && 75 echo "Thu Jan 1 00:00:00 1970 +0000" >expect && 76 git log -1 --format=%ad $commit >actual && 77 test_cmp expect actual 78 ' 79 80 # date is 2^64 - 2 81 test_expect_success 'date parser recognizes time_t overflow' ' 82 commit=$(munge_author_date HEAD `18446744073709551614`) && 83 echo "Thu Jan 1 00:00:00 1970 +0000" >expect && 84 git log -1 --format=%ad $commit >actual && 85 test_cmp expect actual 86 ' 87 88 # date is within 2^63-1, but enough to choke glibc's gmtime 89 test_expect_success 'absurdly far-in-future date' ' 90 commit=$(munge_author_date HEAD `999999999999999999`) && 91 git log -1 --format=%ad $commit 92 ' 93 94 test_expect_success 'create commits with whitespace committer dates' ' 95 # It is important that this subject line is numeric, since we want to 96 # be sure we are not confused by skipping whitespace and accidentally 97 # parsing the subject as a timestamp. 98 # 99 # Do not use munge_author_date here. Besides not hitting the committer 100 # line, it leaves the timezone intact, and we want nothing but 101 # whitespace. 102 # 103 # We will make two munged commits here. The first, ws_commit, will 104 # be purely spaces. The second contains a vertical tab, which is 105 # considered a space by strtoumax(), but not by our isspace(). 106 test_commit `1234567890` && 107 git cat-file commit HEAD >commit.orig && 108 sed "s/>.*/> /" commit.munge && 109 ws_commit=$(git hash-object --literally -w -t commit commit.munge) && 110 sed "s/>.*/> $(printf "\013")/" commit.munge && 111 vt_commit=$(git hash-object --literally -w -t commit commit.munge) 112 ' 113 114 test_expect_success '--until treats whitespace date as sentinel' ' 115 echo $ws_commit >expect && 116 git rev-list --until=1980-01-01 $ws_commit >actual && 117 test_cmp expect actual && 118 119 echo $vt_commit >expect && 120 git rev-list --until=1980-01-01 $vt_commit >actual && 121 test_cmp expect actual 122 ' 123 124 test_expect_success 'pretty-printer handles whitespace date' ' 125 # as with the %ad test above, we will show these as the empty string, 126 # not the 1970 epoch date. This is intentional; see `7d9a281941` (t4212: 127 # test bogus timestamps with git-log, 2014-02-24) for more discussion. 128 echo : >expect && 129 git log -1 --format="%at:%ct" $ws_commit >actual && 130 test_cmp expect actual && 131 git log -1 --format="%at:%ct" $vt_commit >actual && 132 test_cmp expect actual 133 ' 134 135 test_done