Matthijs Kooijman <matthijs@xxxxxxxx> writes: > $ git diff-tree -p -c HEAD > d945a51b6ca22e6e8e550c53980d026f11b05158 > diff --combined file > index 3404f54,0eab113..e8c8c18 > --- a/file > +++ b/file > @@@ -1,7 -1,5 +1,6 @@@ > +LEFT > BASE2 > BASE3 > BASE4 > - BASE5 > + BASE5MODIFIED > BASE6 > > Here, the header claims that the first head has 7 lines, but there really are > only 6 (5 lines of context and one delete line). The numbers for the others > heads are incorrect. In the original diff, the difference was bigger > (first head was stated to have 28 lines, while the output was similar to > the above). The count and the output does look inconsistent. The hunk header claims that it is showing: - range 1,7 for the first parent but it should be 1,5 (2, 3, 4, 5 and 6) to match the output. - range 1,5 for the second parent (left, 2, 3, 4, 5mod, and 6 -- correct) - range 1,6 for the result (left, 2, 3, 4, 5mod and 6 -- correct) If we resurrect the loss of "BASE1" from the output, then the output should have shown: +LEFT - BASE1 BASE2 BASE3 BASE4 - BASE5 + BASE5MODIFIED BASE6 which means the numbers shown for the first parent (1, 2, 3, 4, 5 and 6) should be 1,6. > Note that to trigger this behaviour, the number of context lines between the > BASE1 and BASE5 must be _exactly_ 3, more or less prevents this bug from > occuring. I think the coalescing of two adjacent hunks into one is painting leading lines "interesting to show context but not worth showing deletion before it" incorrectly. Does this patch fix the issue? combine-diff.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/combine-diff.c b/combine-diff.c index 77d7872..7359b84 100644 --- a/combine-diff.c +++ b/combine-diff.c @@ -533,7 +533,7 @@ static int give_context(struct sline *sline, unsigned long cnt, int num_parent) k = find_next(sline, mark, j, cnt, 0); j = adjust_hunk_tail(sline, all_mask, i, j); - if (k < j + context) { + if (k <= j + context) { /* k is interesting and [j,k) are not, but * paint them interesting because the gap is small. */ -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html