blame: add a test to cover blame_coalesce()
Signed-off-by: Barret Rhoden <brho@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Barret Rhoden committed
Jun 20, 2019 at 12:38 UTC
f0cbe742f4b5d7f38941197f4a450e48908f13bc
1 file changed
+36
t/t8003-blame-corner-cases.sh
+36
@@ -275,4 +275,40 @@ test_expect_success 'blame file with CRLF core.autocrlf=true' '
275
grep "A U Thor" actual
276
'
277
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
+
314
test_done