Re: [PATCHv2 11/20] diff.c: convert emit_rewrite_lines to use emit_line_*
- From
Stefan Beller <sbeller@google.com>
- Date
- May 17, 2017, 21:16 UTC
- Message-ID
- <CAGZ79kbrFacBvGsHo6A1o94sA=zB7g7q1z3hKGNi-msXnQVjVw@mail.gmail.com>
- In-Reply-To
- <xmqqefvoxeg7.fsf@gitster.mtv.corp.google.com>
On Tue, May 16, 2017 at 10:03 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Stefan Beller <sbeller@google.com> 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.
Show 6 quoted lines
> 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.