Re: [PATCH 01/10] diff: move line ending check into emit_hunk_header
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Sep 12, 2016, 23:35 UTC
- Message-ID
- <xmqqa8fcy9m4.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <1473572530-25764-2-git-send-email-stefanbeller@gmail.com>
Stefan Beller <stefanbeller@gmail.com> writes:
> From: Stefan Beller <sbeller@google.com> > > Signed-off-by: Stefan Beller <sbeller@google.com> > ---
The reason being...?
"Doing this would not change any behaviour and would not break anything" may be true, but that is not a reason to do a change.
Hopefully it will become clear why this is needed once we look at a later patch in the series.
Show 25 quoted lines
> diff.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/diff.c b/diff.c
> index cc8e812..aa50b2d 100644
> --- a/diff.c
> +++ b/diff.c
> @@ -610,6 +610,9 @@ static void emit_hunk_header(struct emit_callback *ecbdata,
> }
>
> strbuf_add(&msgbuf, line + len, org_len - len);
> + if (line[org_len - 1] != '\n')
> + strbuf_addch(&msgbuf, '\n');
> +
> emit_line(ecbdata->opt, "", "", msgbuf.buf, msgbuf.len);
> strbuf_release(&msgbuf);
> }
> @@ -1247,8 +1250,6 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
> len = sane_truncate_line(ecbdata, line, len);
> find_lno(line, ecbdata);
> emit_hunk_header(ecbdata, line, len);
> - if (line[len-1] != '\n')
> - putc('\n', o->file);
> return;
> }