File tree Expand file tree Collapse file tree 2 files changed +20
-9
lines changed Expand file tree Collapse file tree 2 files changed +20
-9
lines changed Original file line number Diff line number Diff line change @@ -1184,6 +1184,7 @@ void blame_coalesce(struct blame_scoreboard *sb)
1184
1184
for (ent = sb -> ent ; ent && (next = ent -> next ); ent = next ) {
1185
1185
if (ent -> suspect == next -> suspect &&
1186
1186
ent -> s_lno + ent -> num_lines == next -> s_lno &&
1187
+ ent -> lno + ent -> num_lines == next -> lno &&
1187
1188
ent -> ignored == next -> ignored &&
1188
1189
ent -> unblamable == next -> unblamable ) {
1189
1190
ent -> num_lines += next -> num_lines ;
Original file line number Diff line number Diff line change @@ -273,18 +273,14 @@ test_expect_success 'blame file with CRLF core.autocrlf=true' '
273
273
grep "A U Thor" actual
274
274
'
275
275
276
- # Tests the splitting and merging of blame entries in blame_coalesce().
277
- # The output of blame is the same, regardless of whether blame_coalesce() runs
278
- # or not, so we'd likely only notice a problem if blame crashes or assigned
279
- # blame to the "splitting" commit ('SPLIT' below).
280
- test_expect_success ' blame coalesce' '
276
+ test_expect_success ' setup coalesce tests' '
281
277
cat >giraffe <<-\EOF &&
282
278
ABC
283
279
DEF
284
280
EOF
285
281
git add giraffe &&
286
282
git commit -m "original file" &&
287
- oid =$(git rev-parse HEAD) &&
283
+ orig =$(git rev-parse HEAD) &&
288
284
289
285
cat >giraffe <<-\EOF &&
290
286
ABC
@@ -293,19 +289,33 @@ test_expect_success 'blame coalesce' '
293
289
EOF
294
290
git add giraffe &&
295
291
git commit -m "interior SPLIT line" &&
292
+ split=$(git rev-parse HEAD) &&
296
293
297
294
cat >giraffe <<-\EOF &&
298
295
ABC
299
296
DEF
300
297
EOF
301
298
git add giraffe &&
302
299
git commit -m "same contents as original" &&
300
+ final=$(git rev-parse HEAD)
301
+ '
302
+
303
+ test_expect_success ' blame coalesce' '
304
+ cat >expect <<-EOF &&
305
+ $orig 1 1 2
306
+ $orig 2 2
307
+ EOF
308
+ git blame --porcelain $final giraffe >actual.raw &&
309
+ grep "^$orig" actual.raw >actual &&
310
+ test_cmp expect actual
311
+ '
303
312
313
+ test_expect_success ' blame does not coalesce non-adjacent result lines' '
304
314
cat >expect <<-EOF &&
305
- $oid 1) ABC
306
- $oid 2 ) DEF
315
+ $orig 1) ABC
316
+ $orig 3 ) DEF
307
317
EOF
308
- git -c core. abbrev=$(test_oid hexsz) blame -s giraffe >actual &&
318
+ git blame --no- abbrev -s -L1,1 -L3,3 $split giraffe >actual &&
309
319
test_cmp expect actual
310
320
'
311
321
You can’t perform that action at this time.
0 commit comments