]> git.ipfire.org Git - thirdparty/git.git/blob - t/t8008-blame-formats.sh
path.c: don't call the match function without value in trie_find()
[thirdparty/git.git] / t / t8008-blame-formats.sh
1 #!/bin/sh
2
3 test_description='blame output in various formats on a simple case'
4 . ./test-lib.sh
5
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)"
20 '
21
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
31 '
32
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"
55
56 cat >expect <<EOF
57 $ID1 1 1 1
58 $COMMIT1
59 a
60 $ID2 2 2 3
61 $COMMIT2
62 b
63 $ID2 3 3
64 c
65 $ID2 4 4
66 d
67 EOF
68 test_expect_success 'blame --porcelain output' '
69 git blame --porcelain file >actual &&
70 test_cmp expect actual
71 '
72
73 cat >expect <<EOF
74 $ID1 1 1 1
75 $COMMIT1
76 a
77 $ID2 2 2 3
78 $COMMIT2
79 b
80 $ID2 3 3
81 $COMMIT2
82 c
83 $ID2 4 4
84 $COMMIT2
85 d
86 EOF
87 test_expect_success 'blame --line-porcelain output' '
88 git blame --line-porcelain file >actual &&
89 test_cmp expect actual
90 '
91
92 test_expect_success '--porcelain detects first non-blank line as subject' '
93 (
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
106 )
107 '
108
109 test_done