The third batch
[git/gitster.git] / t / t8008-blame-formats.sh
blobfb5d225a671447cee24906dc51a5a1587e052564
1 #!/bin/sh
3 test_description='blame output in various formats on a simple case'
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
8 test_expect_success 'setup' '
9 echo a >file &&
10 git add file &&
11 test_tick &&
12 git commit -m one &&
13 echo b >>file &&
14 echo c >>file &&
15 echo d >>file &&
16 test_tick &&
17 git commit -a -m two &&
18 ID1=$(git rev-parse HEAD^) &&
19 shortID1="^$(git rev-parse HEAD^ |cut -c 1-17)" &&
20 ID2=$(git rev-parse HEAD) &&
21 shortID2="$(git rev-parse HEAD |cut -c 1-18)"
24 cat >expect <<EOF
25 $shortID1 (A U Thor 2005-04-07 15:13:13 -0700 1) a
26 $shortID2 (A U Thor 2005-04-07 15:14:13 -0700 2) b
27 $shortID2 (A U Thor 2005-04-07 15:14:13 -0700 3) c
28 $shortID2 (A U Thor 2005-04-07 15:14:13 -0700 4) d
29 EOF
30 test_expect_success 'normal blame output' '
31 git blame --abbrev=17 file >actual &&
32 test_cmp expect actual
35 COMMIT1="author A U Thor
36 author-mail <author@example.com>
37 author-time 1112911993
38 author-tz -0700
39 committer C O Mitter
40 committer-mail <committer@example.com>
41 committer-time 1112911993
42 committer-tz -0700
43 summary one
44 boundary
45 filename file"
46 COMMIT2="author A U Thor
47 author-mail <author@example.com>
48 author-time 1112912053
49 author-tz -0700
50 committer C O Mitter
51 committer-mail <committer@example.com>
52 committer-time 1112912053
53 committer-tz -0700
54 summary two
55 previous $ID1 file
56 filename file"
58 cat >expect <<EOF
59 $ID1 1 1 1
60 $COMMIT1
62 $ID2 2 2 3
63 $COMMIT2
65 $ID2 3 3
67 $ID2 4 4
69 EOF
70 test_expect_success 'blame --porcelain output' '
71 git blame --porcelain file >actual &&
72 test_cmp expect actual
75 cat >expect <<EOF
76 $ID1 1 1 1
77 $COMMIT1
79 $ID2 2 2 3
80 $COMMIT2
82 $ID2 3 3
83 $COMMIT2
85 $ID2 4 4
86 $COMMIT2
88 EOF
89 test_expect_success 'blame --line-porcelain output' '
90 git blame --line-porcelain file >actual &&
91 test_cmp expect actual
94 test_expect_success '--porcelain detects first non-blank line as subject' '
96 GIT_INDEX_FILE=.git/tmp-index &&
97 export GIT_INDEX_FILE &&
98 echo "This is it" >single-file &&
99 git add single-file &&
100 tree=$(git write-tree) &&
101 commit=$(printf "%s\n%s\n%s\n\n\n \noneline\n\nbody\n" \
102 "tree $tree" \
103 "author A <a@b.c> 123456789 +0000" \
104 "committer C <c@d.e> 123456789 +0000" |
105 git hash-object -w -t commit --stdin) &&
106 git blame --porcelain $commit -- single-file >output &&
107 grep "^summary oneline$" output
111 test_done