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

Re: Bug report: "Use of uninitialized value $_ in print"

From
Jeff King <peff@peff.net>
Date
Mar 2, 2018, 10:42 UTC
Message-ID
<20180302104232.GA11074@sigill.intra.peff.net>
In-Reply-To
<CAD-Jur+6m1SjqHVWBxW5HnTjutSVrkP+dEXdYmFHzoUf0FGdNA@mail.gmail.com>
On Fri, Mar 02, 2018 at 01:19:35AM +0000, Sam Kuper wrote:
> The bug is that in the midst of running
> 
> git -c interactive.diffFilter="git diff --word-diff --color" add --patch
That's not how interactive.diffFilter is supposed to work.

It's meant to have the output of an existing diff piped into it. Generating the diff anew will appear to work for some simple cases, but fall down for others:

  1. Any of the flavors besides "add -p" will be running the wrong diff
     (e.g., "reset -p" runs a diff between the index and HEAD).
  2. Any pathspec limiters would be ignored (e.g., "add -p file").
  3. Your invocation in particular is a problem because it uses
     --word-diff, which will not have a one-to-one line correspondence
     with the bare diff.
     add--interactive handles pretty-printing by running the diff
     command twice: once with no special options, and once with
     "--color" and piped through the diffFilter. It assumes that the two
     match each other line for line, so it shows you the "DISPLAY"
     variant, but then ultimately applies the "TEXT" variant.
And that last one is the cause of the errors you see:
> Use of uninitialized value $_ in print at
> /usr/lib/git-core/git-add--interactive line 1371, <STDIN> line 74.

The "DISPLAY" run for your case generates fewer lines than the "TEXT" run, and we complain on trying to show those extra lines.

Unfortunately, I don't think there's an easy way to do what you want (show word-diffs but apply the full diff).

-Peff
Previous: Sam KuperNext: Sam Kuper
Message 17 of 23 in “Bug report: "Use of uninitialized value $_ in print"”
  1. Sam KuperMar 2, 2018
  2. Jonathan NiederMar 2, 2018
  3. Jeff KingMar 2, 2018
  4. Junio C HamanoMar 2, 2018
  5. Jeff KingMar 2, 2018
  6. Junio C HamanoMar 2, 2018
  7. Jeff KingMar 3, 2018
  8. 1/2 t3701: add a test for interactive.diffFilterJeff King, Mar 3, 2018
  9. 2/2 add--interactive: detect bogus diffFilter outputJeff King, Mar 3, 2018
  10. Junio C HamanoMar 5, 2018
  11. Jeff KingMar 5, 2018
  12. Ævar Arnfjörð BjarmasonMar 5, 2018
  13. Junio C HamanoMar 5, 2018
  14. Ævar Arnfjörð BjarmasonMar 5, 2018
  15. Jonathan NiederMar 5, 2018
  16. Sam KuperMar 2, 2018
  17. Jeff KingMar 2, 2018
  18. Sam KuperMar 2, 2018
  19. Jeff KingMar 3, 2018
  20. Junio C HamanoMar 2, 2018
  21. Sam KuperMar 2, 2018
  22. Junio C HamanoMar 2, 2018
  23. Jeff KingMar 3, 2018

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.