@@ -21,6 +21,7 @@ test_expect_success setup '
21
21
test_tick &&
22
22
git commit -m X &&
23
23
git tag X &&
24
+ git tag -a -m "X (annotated)" XT &&
24
25
25
26
git blame --line-porcelain file >blame_raw &&
26
27
@@ -31,20 +32,36 @@ test_expect_success setup '
31
32
grep -E "^[0-9a-f]+ [0-9]+ 2" blame_raw | sed -e "s/ .*//" >actual &&
32
33
git rev-parse X >expect &&
33
34
test_cmp expect actual
35
+ '
36
+
37
+ # Ensure bogus --ignore-rev requests are caught
38
+ test_expect_success ' validate --ignore-rev' '
39
+ test_must_fail git blame --ignore-rev X^{tree} file
40
+ '
41
+
42
+ # Ensure bogus --ignore-revs-file requests are caught
43
+ test_expect_success ' validate --ignore-revs-file' '
44
+ git rev-parse X^{tree} >ignore_x &&
45
+ test_must_fail git blame --ignore-revs-file ignore_x file
46
+ '
47
+
48
+ for I in X XT
49
+ do
50
+ # Ignore X (or XT), make sure A is blamed for line 1 and B for line 2.
51
+ # Giving X (i.e. commit) and XT (i.e. annotated tag to commit) should
52
+ # produce the same result.
53
+ test_expect_success " ignore_rev_changing_lines ($I )" '
54
+ git blame --line-porcelain --ignore-rev $I file >blame_raw &&
55
+
56
+ grep -E "^[0-9a-f]+ [0-9]+ 1" blame_raw | sed -e "s/ .*//" >actual &&
57
+ git rev-parse A >expect &&
58
+ test_cmp expect actual &&
59
+
60
+ grep -E "^[0-9a-f]+ [0-9]+ 2" blame_raw | sed -e "s/ .*//" >actual &&
61
+ git rev-parse B >expect &&
62
+ test_cmp expect actual
34
63
'
35
-
36
- # Ignore X, make sure A is blamed for line 1 and B for line 2.
37
- test_expect_success ignore_rev_changing_lines '
38
- git blame --line-porcelain --ignore-rev X file >blame_raw &&
39
-
40
- grep -E "^[0-9a-f]+ [0-9]+ 1" blame_raw | sed -e "s/ .*//" >actual &&
41
- git rev-parse A >expect &&
42
- test_cmp expect actual &&
43
-
44
- grep -E "^[0-9a-f]+ [0-9]+ 2" blame_raw | sed -e "s/ .*//" >actual &&
45
- git rev-parse B >expect &&
46
- test_cmp expect actual
47
- '
64
+ done
48
65
49
66
# For ignored revs that have added 'unblamable' lines, attribute those to the
50
67
# ignored commit.
@@ -67,7 +84,7 @@ test_expect_success ignore_rev_adding_unblamable_lines '
67
84
68
85
grep -E "^[0-9a-f]+ [0-9]+ 4" blame_raw | sed -e "s/ .*//" >actual &&
69
86
test_cmp expect actual
70
- '
87
+ '
71
88
72
89
# Ignore X and Y, both in separate files. Lines 1 == A, 2 == B.
73
90
test_expect_success ignore_revs_from_files '
@@ -82,7 +99,7 @@ test_expect_success ignore_revs_from_files '
82
99
grep -E "^[0-9a-f]+ [0-9]+ 2" blame_raw | sed -e "s/ .*//" >actual &&
83
100
git rev-parse B >expect &&
84
101
test_cmp expect actual
85
- '
102
+ '
86
103
87
104
# Ignore X from the config option, Y from a file.
88
105
test_expect_success ignore_revs_from_configs_and_files '
@@ -96,7 +113,7 @@ test_expect_success ignore_revs_from_configs_and_files '
96
113
grep -E "^[0-9a-f]+ [0-9]+ 2" blame_raw | sed -e "s/ .*//" >actual &&
97
114
git rev-parse B >expect &&
98
115
test_cmp expect actual
99
- '
116
+ '
100
117
101
118
# Override blame.ignoreRevsFile (ignore_x) with an empty string. X should be
102
119
# blamed now for lines 1 and 2, since we are no longer ignoring X.
@@ -120,7 +137,7 @@ test_expect_success bad_files_and_revs '
120
137
echo NOREV >ignore_norev &&
121
138
test_must_fail git blame file --ignore-revs-file ignore_norev 2>err &&
122
139
test_i18ngrep "invalid object name: NOREV" err
123
- '
140
+ '
124
141
125
142
# For ignored revs that have added 'unblamable' lines, mark those lines with a
126
143
# '*'
@@ -138,7 +155,7 @@ test_expect_success mark_unblamable_lines '
138
155
139
156
sed -n "4p" blame_raw | cut -c1 >actual &&
140
157
test_cmp expect actual
141
- '
158
+ '
142
159
143
160
# Commit Z will touch the first two lines. Y touched all four.
144
161
# A--B--X--Y--Z
@@ -171,7 +188,7 @@ test_expect_success mark_ignored_lines '
171
188
172
189
sed -n "4p" blame_raw | cut -c1 >actual &&
173
190
! test_cmp expect actual
174
- '
191
+ '
175
192
176
193
# For ignored revs that added 'unblamable' lines and more recent commits changed
177
194
# the blamable lines, mark the unblamable lines with a
@@ -190,7 +207,7 @@ test_expect_success mark_unblamable_lines_intermediate '
190
207
191
208
sed -n "4p" blame_raw | cut -c1 >actual &&
192
209
test_cmp expect actual
193
- '
210
+ '
194
211
195
212
# The heuristic called by guess_line_blames() tries to find the size of a
196
213
# blame_entry 'e' in the parent's address space. Those calculations need to
@@ -227,7 +244,7 @@ test_expect_success ignored_chunk_negative_parent_size '
227
244
git tag C &&
228
245
229
246
git blame file --ignore-rev B >blame_raw
230
- '
247
+ '
231
248
232
249
# Resetting the repo and creating:
233
250
#
@@ -269,6 +286,6 @@ test_expect_success ignore_merge '
269
286
grep -E "^[0-9a-f]+ [0-9]+ 9" blame_raw | sed -e "s/ .*//" >actual &&
270
287
git rev-parse C >expect &&
271
288
test_cmp expect actual
272
- '
289
+ '
273
290
274
291
test_done
0 commit comments