interplane.Get Omega
Read in your language

git

[Ported from github.com/git/git] Sync with Git 2.56.1

Brought by drakestapleton

branch master Branches Tags History

git / t / t8008-blame-formats.sh

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