@@ -21,6 +21,7 @@ test_expect_success setup '
2121 test_tick &&
2222 git commit -m X &&
2323 git tag X &&
24+ git tag -a -m "X (annotated)" XT &&
2425
2526 git blame --line-porcelain file >blame_raw &&
2627
@@ -31,20 +32,36 @@ test_expect_success setup '
3132 grep -E "^[0-9a-f]+ [0-9]+ 2" blame_raw | sed -e "s/ .*//" >actual &&
3233 git rev-parse X >expect &&
3334 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
3463 '
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
4865
4966# For ignored revs that have added 'unblamable' lines, attribute those to the
5067# ignored commit.
@@ -67,7 +84,7 @@ test_expect_success ignore_rev_adding_unblamable_lines '
6784
6885 grep -E "^[0-9a-f]+ [0-9]+ 4" blame_raw | sed -e "s/ .*//" >actual &&
6986 test_cmp expect actual
70- '
87+ '
7188
7289# Ignore X and Y, both in separate files. Lines 1 == A, 2 == B.
7390test_expect_success ignore_revs_from_files '
@@ -82,7 +99,7 @@ test_expect_success ignore_revs_from_files '
8299 grep -E "^[0-9a-f]+ [0-9]+ 2" blame_raw | sed -e "s/ .*//" >actual &&
83100 git rev-parse B >expect &&
84101 test_cmp expect actual
85- '
102+ '
86103
87104# Ignore X from the config option, Y from a file.
88105test_expect_success ignore_revs_from_configs_and_files '
@@ -96,7 +113,7 @@ test_expect_success ignore_revs_from_configs_and_files '
96113 grep -E "^[0-9a-f]+ [0-9]+ 2" blame_raw | sed -e "s/ .*//" >actual &&
97114 git rev-parse B >expect &&
98115 test_cmp expect actual
99- '
116+ '
100117
101118# Override blame.ignoreRevsFile (ignore_x) with an empty string. X should be
102119# 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 '
120137 echo NOREV >ignore_norev &&
121138 test_must_fail git blame file --ignore-revs-file ignore_norev 2>err &&
122139 test_i18ngrep "invalid object name: NOREV" err
123- '
140+ '
124141
125142# For ignored revs that have added 'unblamable' lines, mark those lines with a
126143# '*'
@@ -138,7 +155,7 @@ test_expect_success mark_unblamable_lines '
138155
139156 sed -n "4p" blame_raw | cut -c1 >actual &&
140157 test_cmp expect actual
141- '
158+ '
142159
143160# Commit Z will touch the first two lines. Y touched all four.
144161# A--B--X--Y--Z
@@ -171,7 +188,7 @@ test_expect_success mark_ignored_lines '
171188
172189 sed -n "4p" blame_raw | cut -c1 >actual &&
173190 ! test_cmp expect actual
174- '
191+ '
175192
176193# For ignored revs that added 'unblamable' lines and more recent commits changed
177194# the blamable lines, mark the unblamable lines with a
@@ -190,7 +207,7 @@ test_expect_success mark_unblamable_lines_intermediate '
190207
191208 sed -n "4p" blame_raw | cut -c1 >actual &&
192209 test_cmp expect actual
193- '
210+ '
194211
195212# The heuristic called by guess_line_blames() tries to find the size of a
196213# 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 '
227244 git tag C &&
228245
229246 git blame file --ignore-rev B >blame_raw
230- '
247+ '
231248
232249# Resetting the repo and creating:
233250#
@@ -269,6 +286,6 @@ test_expect_success ignore_merge '
269286 grep -E "^[0-9a-f]+ [0-9]+ 9" blame_raw | sed -e "s/ .*//" >actual &&
270287 git rev-parse C >expect &&
271288 test_cmp expect actual
272- '
289+ '
273290
274291test_done
0 commit comments