Re: [PATCH 01/10] diff: move line ending check into emit_hunk_header

2016-09-12 Thread Junio C Hamano
Stefan Beller  writes:

> From: Stefan Beller 
>
> Signed-off-by: Stefan Beller 
> ---

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.

>  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(, line + len, org_len - len);
> + if (line[org_len - 1] != '\n')
> + strbuf_addch(, '\n');
> +
>   emit_line(ecbdata->opt, "", "", msgbuf.buf, msgbuf.len);
>   strbuf_release();
>  }
> @@ -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;
>   }


[PATCH 01/10] diff: move line ending check into emit_hunk_header

2016-09-10 Thread Stefan Beller
From: Stefan Beller 

Signed-off-by: Stefan Beller 
---
 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(, line + len, org_len - len);
+   if (line[org_len - 1] != '\n')
+   strbuf_addch(, '\n');
+
emit_line(ecbdata->opt, "", "", msgbuf.buf, msgbuf.len);
strbuf_release();
 }
@@ -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;
}
 
-- 
2.7.4