Commit | Line | Data |
---|---|---|
838466b8 JK |
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 && | |
99094a7a | 8 | git add file && |
838466b8 JK |
9 | test_tick && |
10 | git commit -m one && | |
11 | echo b >>file && | |
12 | echo c >>file && | |
13 | echo d >>file && | |
14 | test_tick && | |
0ba9c9a0 SB |
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)" | |
838466b8 JK |
20 | ' |
21 | ||
0ba9c9a0 SB |
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 | |
838466b8 JK |
27 | EOF |
28 | test_expect_success 'normal blame output' ' | |
0ba9c9a0 | 29 | git blame --abbrev=17 file >actual && |
838466b8 JK |
30 | test_cmp expect actual |
31 | ' | |
32 | ||
0ba9c9a0 | 33 | COMMIT1="author A U Thor |
838466b8 JK |
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 | |
0ba9c9a0 SB |
43 | filename file" |
44 | COMMIT2="author A U Thor | |
838466b8 JK |
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 | |
0ba9c9a0 SB |
53 | previous $ID1 file |
54 | filename file" | |
838466b8 JK |
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 | ||
ed747dd5 JK |
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 | ||
4e1b06da JS |
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 | ||
838466b8 | 109 | test_done |