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