blob: 966bb0a61a89ed63dec085338d3c45f766a7f777 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
#!/bin/sh
test_description='git blame corner cases'
. ./test-lib.sh
pick_fc='s/^[0-9a-f^]* *\([^ ]*\) *(\([^ ]*\) .*/\1-\2/'
test_expect_success setup '
echo A A A A A >one &&
echo B B B B B >two &&
echo C C C C C >tres &&
echo ABC >mouse &&
git add one two tres mouse &&
test_tick &&
GIT_AUTHOR_NAME=Initial git commit -m Initial &&
cat one >uno &&
mv two dos &&
cat one >>tres &&
echo DEF >>mouse
git add uno dos tres mouse &&
test_tick &&
GIT_AUTHOR_NAME=Second git commit -a -m Second &&
echo GHIJK >>mouse &&
git add mouse &&
test_tick &&
GIT_AUTHOR_NAME=Third git commit -m Third &&
cat mouse >cow &&
git add cow &&
test_tick &&
GIT_AUTHOR_NAME=Fourth git commit -m Fourth &&
{
echo ABC
echo DEF
echo XXXX
echo GHIJK
} >cow &&
git add cow &&
test_tick &&
GIT_AUTHOR_NAME=Fifth git commit -m Fifth
'
test_expect_success 'straight copy without -C' '
git blame uno | grep Second
'
test_expect_success 'straight move without -C' '
git blame dos | grep Initial
'
test_expect_success 'straight copy with -C' '
git blame -C1 uno | grep Second
'
test_expect_success 'straight move with -C' '
git blame -C1 dos | grep Initial
'
test_expect_success 'straight copy with -C -C' '
git blame -C -C1 uno | grep Initial
'
test_expect_success 'straight move with -C -C' '
git blame -C -C1 dos | grep Initial
'
test_expect_success 'append without -C' '
git blame -L2 tres | grep Second
'
test_expect_success 'append with -C' '
git blame -L2 -C1 tres | grep Second
'
test_expect_success 'append with -C -C' '
git blame -L2 -C -C1 tres | grep Second
'
test_expect_success 'append with -C -C -C' '
git blame -L2 -C -C -C1 tres | grep Initial
'
test_expect_success 'blame wholesale copy' '
git blame -f -C -C1 HEAD^ -- cow | sed -e "$pick_fc" >current &&
{
echo mouse-Initial
echo mouse-Second
echo mouse-Third
} >expected &&
test_cmp expected current
'
test_expect_success 'blame wholesale copy and more' '
git blame -f -C -C1 HEAD -- cow | sed -e "$pick_fc" >current &&
{
echo mouse-Initial
echo mouse-Second
echo cow-Fifth
echo mouse-Third
} >expected &&
test_cmp expected current
'
test_done
|