On Sat, Dec 15, 2007 at 06:16:21AM -0500, Jeff King wrote: > Something seems to be not quite right with the trim_common_tail code in > xdiff-interface.c. The diff I just sent for contrib/completion looks > fine (as I sent it) when I comment out trim_common_tail. But using > the current master, it looks like this: Hrm. It feels like there is an off-by-one when recovering the context lines; we end the inner loop at the newline, but then we never skip past it. So we end up counting only one line total, and even that ends up with a missing newline. Something like this fixes it for me, but somebody please double check. diff --git a/xdiff-interface.c b/xdiff-interface.c index 700def2..eb60e88 100644 --- a/xdiff-interface.c +++ b/xdiff-interface.c @@ -124,6 +124,8 @@ static void trim_common_tail(mmfile_t *a, mmfile_t *b, long ctx) for (i = 0, recovered = 0; recovered < trimmed && i <= ctx; i++) { while (recovered < trimmed && ap[recovered] != '\n') recovered++; + if (recovered < trimmed && ap[recovered] == '\n') + recovered++; } a->size -= (trimmed - recovered); b->size -= (trimmed - recovered); - 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