Merge branch 'ab/cred-netrc-no-autodie'
[alt-git.git] / t / t8008-blame-formats.sh
blobae4b579d245caf568d07d1e452f917581dbfd355
1 #!/bin/sh
3 test_description='blame output in various formats on a simple case'
4 . ./test-lib.sh
6 test_expect_success 'setup' '
7 echo a >file &&
8 git add file &&
9 test_tick &&
10 git commit -m one &&
11 echo b >>file &&
12 echo c >>file &&
13 echo d >>file &&
14 test_tick &&
15 git commit -a -m two &&
16 ID1=$(git rev-parse HEAD^) &&
17 shortID1="^$(git rev-parse HEAD^ |cut -c 1-17)" &&
18 ID2=$(git rev-parse HEAD) &&
19 shortID2="$(git rev-parse HEAD |cut -c 1-18)"
22 cat >expect <<EOF
23 $shortID1 (A U Thor 2005-04-07 15:13:13 -0700 1) a
24 $shortID2 (A U Thor 2005-04-07 15:14:13 -0700 2) b
25 $shortID2 (A U Thor 2005-04-07 15:14:13 -0700 3) c
26 $shortID2 (A U Thor 2005-04-07 15:14:13 -0700 4) d
27 EOF
28 test_expect_success 'normal blame output' '
29 git blame --abbrev=17 file >actual &&
30 test_cmp expect actual
33 COMMIT1="author A U Thor
34 author-mail <author@example.com>
35 author-time 1112911993
36 author-tz -0700
37 committer C O Mitter
38 committer-mail <committer@example.com>
39 committer-time 1112911993
40 committer-tz -0700
41 summary one
42 boundary
43 filename file"
44 COMMIT2="author A U Thor
45 author-mail <author@example.com>
46 author-time 1112912053
47 author-tz -0700
48 committer C O Mitter
49 committer-mail <committer@example.com>
50 committer-time 1112912053
51 committer-tz -0700
52 summary two
53 previous $ID1 file
54 filename file"
56 cat >expect <<EOF
57 $ID1 1 1 1
58 $COMMIT1
60 $ID2 2 2 3
61 $COMMIT2
63 $ID2 3 3
65 $ID2 4 4
67 EOF
68 test_expect_success 'blame --porcelain output' '
69 git blame --porcelain file >actual &&
70 test_cmp expect actual
73 cat >expect <<EOF
74 $ID1 1 1 1
75 $COMMIT1
77 $ID2 2 2 3
78 $COMMIT2
80 $ID2 3 3
81 $COMMIT2
83 $ID2 4 4
84 $COMMIT2
86 EOF
87 test_expect_success 'blame --line-porcelain output' '
88 git blame --line-porcelain file >actual &&
89 test_cmp expect actual
92 test_expect_success '--porcelain detects first non-blank line as subject' '
94 GIT_INDEX_FILE=.git/tmp-index &&
95 export GIT_INDEX_FILE &&
96 echo "This is it" >single-file &&
97 git add single-file &&
98 tree=$(git write-tree) &&
99 commit=$(printf "%s\n%s\n%s\n\n\n \noneline\n\nbody\n" \
100 "tree $tree" \
101 "author A <a@b.c> 123456789 +0000" \
102 "committer C <c@d.e> 123456789 +0000" |
103 git hash-object -w -t commit --stdin) &&
104 git blame --porcelain $commit -- single-file >output &&
105 grep "^summary oneline$" output
109 test_done