{"thread":{"id":"44033","subject":"[PATCH 0/3] preparatory diff improvements for moved color detection","startedAt":"2016-09-07T23:36:58Z","lastAt":"2016-09-08T21:07:55Z","messageCount":9,"participants":["Stefan Beller","Jacob Keller","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"301341","messageId":"20160907233648.5162-1-sbeller@google.com","threadId":"44033","inReplyTo":null,"subject":"[PATCH 0/3] preparatory diff improvements for moved color detection","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2016-09-07T23:36:43Z","receivedAt":"2016-09-07T23:36:58Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Motivated by the feedback on the \"[PATCHv4] diff.c: emit moved lines\nwith a different color\"[1], I started refactoring the fn_out_consume function\nin diff.c.  This lead to a huge amount of tiny patches so far, but nothing\nto present as an end result.\n\nThese patches are preparatory for this effort and I want them out such that\nI do not need to worry about them later.\n\nThanks,\nStefan\n\n[1] https://public-inbox.org/git/20160906070151.15163-1-stefanbeller@gmail.com/\n\n\n\nStefan Beller (3):\n  diff.c: use diff_options directly\n  diff: omit found pointer from emit_callback\n  diff: remove dead code\n\n diff.c | 30 +++++++++---------------------\n 1 file changed, 9 insertions(+), 21 deletions(-)\n\n-- \n2.10.0.2.g0676c79.dirty\n\n"},{"id":"301342","messageId":"20160907233648.5162-2-sbeller@google.com","threadId":"44033","inReplyTo":"20160907233648.5162-1-sbeller@google.com","subject":"[PATCH 1/3] diff.c: use diff_options directly","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2016-09-07T23:36:44Z","receivedAt":"2016-09-07T23:37:01Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"The value of `ecbdata->opt` is accessible via the short variable `o`\nalready, so let's use that instead.\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n diff.c | 21 ++++++++++-----------\n 1 file changed, 10 insertions(+), 11 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 534c12e..4a6501c 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -1217,7 +1217,7 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)\n \tconst char *line_prefix = diff_line_prefix(o);\n \n \tif (ecbdata->header) {\n-\t\tfprintf(ecbdata->opt->file, \"%s\", ecbdata->header->buf);\n+\t\tfprintf(o->file, \"%s\", ecbdata->header->buf);\n \t\tstrbuf_reset(ecbdata->header);\n \t\tecbdata->header = NULL;\n \t}\n@@ -1229,9 +1229,9 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)\n \t\tname_a_tab = strchr(ecbdata->label_path[0], ' ') ? \"\\t\" : \"\";\n \t\tname_b_tab = strchr(ecbdata->label_path[1], ' ') ? \"\\t\" : \"\";\n \n-\t\tfprintf(ecbdata->opt->file, \"%s%s--- %s%s%s\\n\",\n+\t\tfprintf(o->file, \"%s%s--- %s%s%s\\n\",\n \t\t\tline_prefix, meta, ecbdata->label_path[0], reset, name_a_tab);\n-\t\tfprintf(ecbdata->opt->file, \"%s%s+++ %s%s%s\\n\",\n+\t\tfprintf(o->file, \"%s%s+++ %s%s%s\\n\",\n \t\t\tline_prefix, meta, ecbdata->label_path[1], reset, name_b_tab);\n \t\tecbdata->label_path[0] = ecbdata->label_path[1] = NULL;\n \t}\n@@ -1249,15 +1249,15 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)\n \t\tfind_lno(line, ecbdata);\n \t\temit_hunk_header(ecbdata, line, len);\n \t\tif (line[len-1] != '\\n')\n-\t\t\tputc('\\n', ecbdata->opt->file);\n+\t\t\tputc('\\n', o->file);\n \t\treturn;\n \t}\n \n \tif (len < 1) {\n-\t\temit_line(ecbdata->opt, reset, reset, line, len);\n+\t\temit_line(o, reset, reset, line, len);\n \t\tif (ecbdata->diff_words\n \t\t    && ecbdata->diff_words->type == DIFF_WORDS_PORCELAIN)\n-\t\t\tfputs(\"~\\n\", ecbdata->opt->file);\n+\t\t\tfputs(\"~\\n\", o->file);\n \t\treturn;\n \t}\n \n@@ -1282,8 +1282,8 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)\n \t\t}\n \t\tdiff_words_flush(ecbdata);\n \t\tif (ecbdata->diff_words->type == DIFF_WORDS_PORCELAIN) {\n-\t\t\temit_line(ecbdata->opt, context, reset, line, len);\n-\t\t\tfputs(\"~\\n\", ecbdata->opt->file);\n+\t\t\temit_line(o, context, reset, line, len);\n+\t\t\tfputs(\"~\\n\", o->file);\n \t\t} else {\n \t\t\t/*\n \t\t\t * Skip the prefix character, if any.  With\n@@ -1294,7 +1294,7 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)\n \t\t\t      line++;\n \t\t\t      len--;\n \t\t\t}\n-\t\t\temit_line(ecbdata->opt, context, reset, line, len);\n+\t\t\temit_line(o, context, reset, line, len);\n \t\t}\n \t\treturn;\n \t}\n@@ -1316,8 +1316,7 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)\n \tdefault:\n \t\t/* incomplete line at the end */\n \t\tecbdata->lno_in_preimage++;\n-\t\temit_line(ecbdata->opt,\n-\t\t\t  diff_get_color(ecbdata->color_diff, DIFF_CONTEXT),\n+\t\temit_line(o, diff_get_color(ecbdata->color_diff, DIFF_CONTEXT),\n \t\t\t  reset, line, len);\n \t\tbreak;\n \t}\n-- \n2.10.0.2.g0676c79.dirty\n\n"},{"id":"301343","messageId":"20160907233648.5162-3-sbeller@google.com","threadId":"44033","inReplyTo":"20160907233648.5162-1-sbeller@google.com","subject":"[PATCH 1/2] diff: omit found pointer from emit_callback","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2016-09-07T23:36:45Z","receivedAt":"2016-09-07T23:37:13Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"We keep the actual data in the diff options, which are just as accessible.\nRemove the pointer stored in struct emit_callback for readability.\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n diff.c | 5 +----\n 1 file changed, 1 insertion(+), 4 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 4a6501c..79ad91d 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -354,7 +354,6 @@ struct emit_callback {\n \tconst char **label_path;\n \tstruct diff_words_data *diff_words;\n \tstruct diff_options *opt;\n-\tint *found_changesp;\n \tstruct strbuf *header;\n };\n \n@@ -722,7 +721,6 @@ static void emit_rewrite_diff(const char *name_a,\n \n \tmemset(&ecbdata, 0, sizeof(ecbdata));\n \tecbdata.color_diff = want_color(o->use_color);\n-\tecbdata.found_changesp = &o->found_changes;\n \tecbdata.ws_rule = whitespace_rule(name_b);\n \tecbdata.opt = o;\n \tif (ecbdata.ws_rule & WS_BLANK_AT_EOF) {\n@@ -1215,13 +1213,13 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)\n \tconst char *reset = diff_get_color(ecbdata->color_diff, DIFF_RESET);\n \tstruct diff_options *o = ecbdata->opt;\n \tconst char *line_prefix = diff_line_prefix(o);\n+\to->found_changes = 1;\n \n \tif (ecbdata->header) {\n \t\tfprintf(o->file, \"%s\", ecbdata->header->buf);\n \t\tstrbuf_reset(ecbdata->header);\n \t\tecbdata->header = NULL;\n \t}\n-\t*(ecbdata->found_changesp) = 1;\n \n \tif (ecbdata->label_path[0]) {\n \t\tconst char *name_a_tab, *name_b_tab;\n@@ -2437,7 +2435,6 @@ static void builtin_diff(const char *name_a,\n \t\tmemset(&ecbdata, 0, sizeof(ecbdata));\n \t\tecbdata.label_path = lbl;\n \t\tecbdata.color_diff = want_color(o->use_color);\n-\t\tecbdata.found_changesp = &o->found_changes;\n \t\tecbdata.ws_rule = whitespace_rule(name_b);\n \t\tif (ecbdata.ws_rule & WS_BLANK_AT_EOF)\n \t\t\tcheck_blank_at_eof(&mf1, &mf2, &ecbdata);\n-- \n2.10.0.2.g0676c79.dirty\n\n"},{"id":"301344","messageId":"20160907233648.5162-4-sbeller@google.com","threadId":"44033","inReplyTo":"20160907233648.5162-1-sbeller@google.com","subject":"[PATCH 2/3] diff: omit found pointer from emit_callback","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2016-09-07T23:36:46Z","receivedAt":"2016-09-07T23:37:15Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"We keep the actual data in the diff options, which are just as accessible.\nRemove the pointer stored in struct emit_callback for readability.\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n diff.c | 5 +----\n 1 file changed, 1 insertion(+), 4 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 4a6501c..79ad91d 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -354,7 +354,6 @@ struct emit_callback {\n \tconst char **label_path;\n \tstruct diff_words_data *diff_words;\n \tstruct diff_options *opt;\n-\tint *found_changesp;\n \tstruct strbuf *header;\n };\n \n@@ -722,7 +721,6 @@ static void emit_rewrite_diff(const char *name_a,\n \n \tmemset(&ecbdata, 0, sizeof(ecbdata));\n \tecbdata.color_diff = want_color(o->use_color);\n-\tecbdata.found_changesp = &o->found_changes;\n \tecbdata.ws_rule = whitespace_rule(name_b);\n \tecbdata.opt = o;\n \tif (ecbdata.ws_rule & WS_BLANK_AT_EOF) {\n@@ -1215,13 +1213,13 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)\n \tconst char *reset = diff_get_color(ecbdata->color_diff, DIFF_RESET);\n \tstruct diff_options *o = ecbdata->opt;\n \tconst char *line_prefix = diff_line_prefix(o);\n+\to->found_changes = 1;\n \n \tif (ecbdata->header) {\n \t\tfprintf(o->file, \"%s\", ecbdata->header->buf);\n \t\tstrbuf_reset(ecbdata->header);\n \t\tecbdata->header = NULL;\n \t}\n-\t*(ecbdata->found_changesp) = 1;\n \n \tif (ecbdata->label_path[0]) {\n \t\tconst char *name_a_tab, *name_b_tab;\n@@ -2437,7 +2435,6 @@ static void builtin_diff(const char *name_a,\n \t\tmemset(&ecbdata, 0, sizeof(ecbdata));\n \t\tecbdata.label_path = lbl;\n \t\tecbdata.color_diff = want_color(o->use_color);\n-\t\tecbdata.found_changesp = &o->found_changes;\n \t\tecbdata.ws_rule = whitespace_rule(name_b);\n \t\tif (ecbdata.ws_rule & WS_BLANK_AT_EOF)\n \t\t\tcheck_blank_at_eof(&mf1, &mf2, &ecbdata);\n-- \n2.10.0.2.g0676c79.dirty\n\n"},{"id":"301345","messageId":"20160907233648.5162-6-sbeller@google.com","threadId":"44033","inReplyTo":"20160907233648.5162-1-sbeller@google.com","subject":"[PATCH 3/3] diff: remove dead code","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2016-09-07T23:36:48Z","receivedAt":"2016-09-07T23:37:17Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"When `len < 1`, len has to be 0 or negative, emit_line will then remove the\nfirst character and by then `len` would be negative. As this doesn't\nhappen, it is safe to assume it is dead code.\n\nThis continues to simplify the code, which was started in b8d9c1a66b\n(2009-09-03,  diff.c: the builtin_diff() deals with only two-file\ncomparison).\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n diff.c | 8 --------\n 1 file changed, 8 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 79ad91d..c143019 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -1251,14 +1251,6 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)\n \t\treturn;\n \t}\n \n-\tif (len < 1) {\n-\t\temit_line(o, reset, reset, line, len);\n-\t\tif (ecbdata->diff_words\n-\t\t    && ecbdata->diff_words->type == DIFF_WORDS_PORCELAIN)\n-\t\t\tfputs(\"~\\n\", o->file);\n-\t\treturn;\n-\t}\n-\n \tif (ecbdata->diff_words) {\n \t\tif (line[0] == '-') {\n \t\t\tdiff_words_append(line, len,\n-- \n2.10.0.2.g0676c79.dirty\n\n"},{"id":"301346","messageId":"20160907233648.5162-5-sbeller@google.com","threadId":"44033","inReplyTo":"20160907233648.5162-1-sbeller@google.com","subject":"[PATCH 2/2] diff: remove dead code","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2016-09-07T23:36:47Z","receivedAt":"2016-09-07T23:37:18Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"When `len < 1`, len has to be 0 or negative, emit_line will then remove the\nfirst character and by then `len` would be negative. As this doesn't\nhappen, it is safe to assume it is dead code.\n\nThis continues to simplify the code, which was started in b8d9c1a66b\n(2009-09-03,  diff.c: the builtin_diff() deals with only two-file\ncomparison).\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n diff.c | 8 --------\n 1 file changed, 8 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 79ad91d..c143019 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -1251,14 +1251,6 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)\n \t\treturn;\n \t}\n \n-\tif (len < 1) {\n-\t\temit_line(o, reset, reset, line, len);\n-\t\tif (ecbdata->diff_words\n-\t\t    && ecbdata->diff_words->type == DIFF_WORDS_PORCELAIN)\n-\t\t\tfputs(\"~\\n\", o->file);\n-\t\treturn;\n-\t}\n-\n \tif (ecbdata->diff_words) {\n \t\tif (line[0] == '-') {\n \t\t\tdiff_words_append(line, len,\n-- \n2.10.0.2.g0676c79.dirty\n\n"},{"id":"301364","messageId":"CA+P7+xrdtwAQkmHGkL37rZMJLWAn1ezAophn+QASz354eL8MqQ@mail.gmail.com","threadId":"44033","inReplyTo":"20160907233648.5162-2-sbeller@google.com","subject":"Re: [PATCH 1/3] diff.c: use diff_options directly","fromName":"Jacob Keller","fromEmail":"jacob.keller@gmail.com","sentAt":"2016-09-08T05:33:52Z","receivedAt":"2016-09-08T06:32:07Z","isPatch":true,"sender":{"key":"jacob.keller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/874719?v=4"},"body":"On Wed, Sep 7, 2016 at 4:36 PM, Stefan Beller <sbeller@google.com> wrote:\n> The value of `ecbdata->opt` is accessible via the short variable `o`\n> already, so let's use that instead.\n>\n> Signed-off-by: Stefan Beller <sbeller@google.com>\n\nSeems reasonable.\n\n> ---\n>  diff.c | 21 ++++++++++-----------\n>  1 file changed, 10 insertions(+), 11 deletions(-)\n>\n> diff --git a/diff.c b/diff.c\n> index 534c12e..4a6501c 100644\n> --- a/diff.c\n> +++ b/diff.c\n> @@ -1217,7 +1217,7 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)\n>         const char *line_prefix = diff_line_prefix(o);\n>\n>         if (ecbdata->header) {\n> -               fprintf(ecbdata->opt->file, \"%s\", ecbdata->header->buf);\n> +               fprintf(o->file, \"%s\", ecbdata->header->buf);\n>                 strbuf_reset(ecbdata->header);\n>                 ecbdata->header = NULL;\n>         }\n> @@ -1229,9 +1229,9 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)\n>                 name_a_tab = strchr(ecbdata->label_path[0], ' ') ? \"\\t\" : \"\";\n>                 name_b_tab = strchr(ecbdata->label_path[1], ' ') ? \"\\t\" : \"\";\n>\n> -               fprintf(ecbdata->opt->file, \"%s%s--- %s%s%s\\n\",\n> +               fprintf(o->file, \"%s%s--- %s%s%s\\n\",\n>                         line_prefix, meta, ecbdata->label_path[0], reset, name_a_tab);\n> -               fprintf(ecbdata->opt->file, \"%s%s+++ %s%s%s\\n\",\n> +               fprintf(o->file, \"%s%s+++ %s%s%s\\n\",\n>                         line_prefix, meta, ecbdata->label_path[1], reset, name_b_tab);\n>                 ecbdata->label_path[0] = ecbdata->label_path[1] = NULL;\n>         }\n> @@ -1249,15 +1249,15 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)\n>                 find_lno(line, ecbdata);\n>                 emit_hunk_header(ecbdata, line, len);\n>                 if (line[len-1] != '\\n')\n> -                       putc('\\n', ecbdata->opt->file);\n> +                       putc('\\n', o->file);\n>                 return;\n>         }\n>\n>         if (len < 1) {\n> -               emit_line(ecbdata->opt, reset, reset, line, len);\n> +               emit_line(o, reset, reset, line, len);\n>                 if (ecbdata->diff_words\n>                     && ecbdata->diff_words->type == DIFF_WORDS_PORCELAIN)\n> -                       fputs(\"~\\n\", ecbdata->opt->file);\n> +                       fputs(\"~\\n\", o->file);\n>                 return;\n>         }\n>\n> @@ -1282,8 +1282,8 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)\n>                 }\n>                 diff_words_flush(ecbdata);\n>                 if (ecbdata->diff_words->type == DIFF_WORDS_PORCELAIN) {\n> -                       emit_line(ecbdata->opt, context, reset, line, len);\n> -                       fputs(\"~\\n\", ecbdata->opt->file);\n> +                       emit_line(o, context, reset, line, len);\n> +                       fputs(\"~\\n\", o->file);\n>                 } else {\n>                         /*\n>                          * Skip the prefix character, if any.  With\n> @@ -1294,7 +1294,7 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)\n>                               line++;\n>                               len--;\n>                         }\n> -                       emit_line(ecbdata->opt, context, reset, line, len);\n> +                       emit_line(o, context, reset, line, len);\n>                 }\n>                 return;\n>         }\n> @@ -1316,8 +1316,7 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)\n>         default:\n>                 /* incomplete line at the end */\n>                 ecbdata->lno_in_preimage++;\n> -               emit_line(ecbdata->opt,\n> -                         diff_get_color(ecbdata->color_diff, DIFF_CONTEXT),\n> +               emit_line(o, diff_get_color(ecbdata->color_diff, DIFF_CONTEXT),\n>                           reset, line, len);\n>                 break;\n>         }\n> --\n> 2.10.0.2.g0676c79.dirty\n>\n"},{"id":"301447","messageId":"xmqqpooef706.fsf@gitster.mtv.corp.google.com","threadId":"44033","inReplyTo":"20160907233648.5162-4-sbeller@google.com","subject":"Re: [PATCH 2/3] diff: omit found pointer from emit_callback","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-09-08T20:53:29Z","receivedAt":"2016-09-08T20:53:42Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Stefan Beller <sbeller@google.com> writes:\n\n> diff --git a/diff.c b/diff.c\n> index 4a6501c..79ad91d 100644\n> --- a/diff.c\n> +++ b/diff.c\n> @@ -354,7 +354,6 @@ struct emit_callback {\n>  \tconst char **label_path;\n>  \tstruct diff_words_data *diff_words;\n>  \tstruct diff_options *opt;\n> -\tint *found_changesp;\n>  \tstruct strbuf *header;\n>  };\n\nI briefly wondered if we have some callsites that do not want\no->found_changes to be modified (hence pointing this field at\nelsewhere), but the fact that you can _remove_ this field means that\nthere is no such use case, which is good.\n\n> @@ -722,7 +721,6 @@ static void emit_rewrite_diff(const char *name_a,\n>  \n>  \tmemset(&ecbdata, 0, sizeof(ecbdata));\n>  \tecbdata.color_diff = want_color(o->use_color);\n> -\tecbdata.found_changesp = &o->found_changes;\n>  \tecbdata.ws_rule = whitespace_rule(name_b);\n>  \tecbdata.opt = o;\n>  \tif (ecbdata.ws_rule & WS_BLANK_AT_EOF) {\n> @@ -1215,13 +1213,13 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)\n>  \tconst char *reset = diff_get_color(ecbdata->color_diff, DIFF_RESET);\n>  \tstruct diff_options *o = ecbdata->opt;\n>  \tconst char *line_prefix = diff_line_prefix(o);\n> +\to->found_changes = 1;\n>  \n>  \tif (ecbdata->header) {\n>  \t\tfprintf(o->file, \"%s\", ecbdata->header->buf);\n>  \t\tstrbuf_reset(ecbdata->header);\n>  \t\tecbdata->header = NULL;\n>  \t}\n> -\t*(ecbdata->found_changesp) = 1;\n\nIs there a good reason to move the assignment up?  \"The fact that\nthis function was called even once means we found some change\" is\nprobably a good argument, but then I'd prefer to have a blank before\nit to separate it (the first statement) from the block of decls.\n\nNo need to resend.  Thanks.\n"},{"id":"301448","messageId":"xmqqlgz2f6ce.fsf@gitster.mtv.corp.google.com","threadId":"44033","inReplyTo":"20160907233648.5162-6-sbeller@google.com","subject":"Re: [PATCH 3/3] diff: remove dead code","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-09-08T21:07:45Z","receivedAt":"2016-09-08T21:07:55Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Stefan Beller <sbeller@google.com> writes:\n\n> When `len < 1`, len has to be 0 or negative, emit_line will then remove the\n> first character and by then `len` would be negative. As this doesn't\n> happen, it is safe to assume it is dead code.\n>\n> This continues to simplify the code, which was started in b8d9c1a66b\n> (2009-09-03,  diff.c: the builtin_diff() deals with only two-file\n> comparison).\n\nWe look at line[0] to see if it is '@' before this check, which\nwould have been wrong if \"len < 1\" were ever true.\n\n>\n> Signed-off-by: Stefan Beller <sbeller@google.com>\n> ---\n>  diff.c | 8 --------\n>  1 file changed, 8 deletions(-)\n>\n> diff --git a/diff.c b/diff.c\n> index 79ad91d..c143019 100644\n> --- a/diff.c\n> +++ b/diff.c\n> @@ -1251,14 +1251,6 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)\n>  \t\treturn;\n>  \t}\n>  \n> -\tif (len < 1) {\n> -\t\temit_line(o, reset, reset, line, len);\n> -\t\tif (ecbdata->diff_words\n> -\t\t    && ecbdata->diff_words->type == DIFF_WORDS_PORCELAIN)\n> -\t\t\tfputs(\"~\\n\", o->file);\n> -\t\treturn;\n> -\t}\n> -\n>  \tif (ecbdata->diff_words) {\n>  \t\tif (line[0] == '-') {\n>  \t\t\tdiff_words_append(line, len,\n"}]}