git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: diffstat summary mode change bug

From
Stefan Beller <sbeller@google.com>
Date
Sep 27, 2017, 20:40 UTC
Message-ID
<CAGZ79kZF5w7ucbUCKJAuAbz2KBoMJjWneAxFcjOPeted8SBNmg@mail.gmail.com>
In-Reply-To
<CA+55aFzThd6cayUVuv39k=sb8KCphLkWGCV4n2HUjfn7Pxkd3g@mail.gmail.com>

On Wed, Sep 27, 2017 at 11:15 AM, Linus Torvalds <torvalds@linux-foundation.org> wrote:

> (ok, linewrapping in this email may make that look wrong - but the
> "mode change" land the "create mode" are both on the same line.
Thanks for the bug report.
> and the reason seems to be that the '\n' at the end got dropped as the
> old code was very confusing (the old code had two different '\n' cases
> for the "show filename or not").

I disagree with this analysis, as the fix you propose adds the new line unconditionally, i.e. this code path would be broken regardless of "show filename or not".

Both search for "create mode" and "mode change" results in hits in the test suite, so we should have caught this. I wonder why our tests failed to tell us about this.

Specifically we have t4100/t-apply-4.expect
  mode change 100644 => 100755 t/t0000-basic.sh
  mode change 100644 => 100755 t/test-lib.sh
which would seem to exercise this code path.
The code *looks* correct, but I am full of doubts now.
Stefan
Show 19 quoted lines
> I think the right fix is this whitespace-damaged trivial one-liner:
>
>   diff --git a/diff.c b/diff.c
>   index 3c6a3e0fa..653bb2e72 100644
>   --- a/diff.c
>   +++ b/diff.c
>   @@ -5272,6 +5272,7 @@ static void show_mode_change(struct
> diff_options *opt, struct diff_filepair *p,
>                           strbuf_addch(&sb, ' ');
>                           quote_c_style(p->two->path, &sb, NULL, 0);
>                   }
>   +               strbuf_addch(&sb, '\n');
>                   emit_diff_symbol(opt, DIFF_SYMBOL_SUMMARY,
>                                    sb.buf, sb.len, 0);
>                   strbuf_release(&sb);
>
> but somebody should double-check that.
>
>                         Linus
Previous: Linus TorvaldsNext: Linus Torvalds
Message 2 of 19 in “diffstat summary mode change bug”
  1. Linus TorvaldsSep 27, 2017
  2. Stefan BellerSep 27, 2017
  3. Linus TorvaldsSep 27, 2017
  4. Stefan BellerSep 27, 2017
  5. diff: correct newline in summary for renamed filesStefan Beller, Sep 27, 2017
  6. Linus TorvaldsSep 27, 2017
  7. Jeff KingSep 27, 2017
  8. Jeff KingSep 27, 2017
  9. Stefan BellerSep 27, 2017
  10. Jeff KingSep 27, 2017
  11. diff: correct newline in summary for renamed filesStefan Beller, Sep 27, 2017
  12. Jonathan NiederSep 27, 2017
  13. Ramsay JonesSep 27, 2017
  14. Stefan BellerSep 27, 2017
  15. Jeff KingSep 28, 2017
  16. Junio C HamanoSep 28, 2017
  17. Jeff KingSep 28, 2017
  18. Stefan BellerSep 27, 2017
  19. Junio C HamanoSep 28, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.