Skip to content

Commit f0cbe74

Browse files
Barret Rhodengitster
authored andcommitted
blame: add a test to cover blame_coalesce()
Signed-off-by: Barret Rhoden <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a07a977 commit f0cbe74

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

t/t8003-blame-corner-cases.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,4 +275,40 @@ test_expect_success 'blame file with CRLF core.autocrlf=true' '
275275
grep "A U Thor" actual
276276
'
277277

278+
# Tests the splitting and merging of blame entries in blame_coalesce().
279+
# The output of blame is the same, regardless of whether blame_coalesce() runs
280+
# or not, so we'd likely only notice a problem if blame crashes or assigned
281+
# blame to the "splitting" commit ('SPLIT' below).
282+
test_expect_success 'blame coalesce' '
283+
cat >giraffe <<-\EOF &&
284+
ABC
285+
DEF
286+
EOF
287+
git add giraffe &&
288+
git commit -m "original file" &&
289+
oid=$(git rev-parse HEAD) &&
290+
291+
cat >giraffe <<-\EOF &&
292+
ABC
293+
SPLIT
294+
DEF
295+
EOF
296+
git add giraffe &&
297+
git commit -m "interior SPLIT line" &&
298+
299+
cat >giraffe <<-\EOF &&
300+
ABC
301+
DEF
302+
EOF
303+
git add giraffe &&
304+
git commit -m "same contents as original" &&
305+
306+
cat >expect <<-EOF &&
307+
$oid 1) ABC
308+
$oid 2) DEF
309+
EOF
310+
git -c core.abbrev=40 blame -s giraffe >actual &&
311+
test_cmp expect actual
312+
'
313+
278314
test_done

0 commit comments

Comments
 (0)