Web lists-archives.com

Re: [PATCHv2 11/20] diff.c: convert emit_rewrite_lines to use emit_line_*




On Tue, May 16, 2017 at 10:03 PM, Junio C Hamano <gitster@xxxxxxxxx> wrote:
> Stefan Beller <sbeller@xxxxxxxxxx> writes:

> The reason why we can lose the LF immediately after the incomplete
> line we found in the above loop is because the updated emit_line_0()
> adds LF if its input is an incomplete line?

No. Because there are no incomplete lines any more, as we complete
the line above via strbuf_addch(&sb, '\n');

In a buffered world, we need to think about what to buffer, and I think
we rather want to buffer all lines with the same line ending otherwise
the comparison function is harder. So in that case we'll rather

    line1="last line, but we added EOL\n"
    line2="\\ No newline at end of file\n"

because line1 could occur somewhere else as is with the \n.

>  Even before this series
> started, emit_line_0() was already prepared to see a complete or
> incomplete line and emit the "reset" color after the optional EOL
> bytes at the end, so emit_line() and emit_{add,del}_line() calls
> throughout the code can pass the body of the line with or without
> the EOL and right things will happen.  Sounds about right.

Yes the emit_line_0 will strip off \n if there is and output it after a
potential color reset.