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

Re: [PATCH v1 1/2] log -G: Ignore binary files

From
Jeff King <peff@peff.net>
Date
Nov 22, 2018, 16:27 UTC
Message-ID
<20181122162705.GE28192@sigill.intra.peff.net>
In-Reply-To
<87k1l5zabd.fsf@evledraar.gmail.com>
On Thu, Nov 22, 2018 at 11:16:38AM +0100, Ævar Arnfjörð Bjarmason wrote:
Show 17 quoted lines
> > +test_expect_success 'log -G looks into binary files with textconv filter' '
> > +	rm -rf .git &&
> > +	git init &&
> > +	echo "* diff=bin" > .gitattributes &&
> > +	printf "a\0b" >data.bin &&
> > +	git add data.bin &&
> > +	git commit -m "message" &&
> > +	git -c diff.bin.textconv=cat log -G a >actual &&
> > +	git log >expected &&
> > +	test_cmp actual expected
> > +'
> > +
> >  test_done
> 
> This patch seems like the wrong direction to me. In particular the
> assertion that "the concept of differences only makes sense for text
> files". That's just not true. This patch breaks this:

But "-G" is defined as "look for differences whose patch text contains added/removed lines that match <regex>". We don't have patch text here, let alone added/removed lines.

For binary files, "-Sfoo" is better defined. I think we _could_ define "search for <pattern> in the added/removed bytes of a binary file". But I don't think that's what the current code does (it really does a line diff on a binary file, which is likely to put tons of unchanged crap into the "added and removed" lines, because the line divisions aren't meaningful in the first place).

Show 17 quoted lines
>     (
>         rm -rf /tmp/g-test &&
>         git init /tmp/g-test &&
>         cd /tmp/g-test &&
>         for i in {1..10}; do
>             echo "Always matching thensome 5" >file &&
>             printf "a thensome %d binary \0" $i >>file &&
>             git add file &&
>             git commit -m"Bump $i"
>         done &&
>         git log -Gthensome.*5
>     )
> 
> Right now this will emit 3/10 patches, and the right ones! I.e. "Bump
> [156]". The 1st one because it introduces the "Always matching thensome
> 5". Then 5/6 because the add/remove the string "a thensome 5 binary",
> respectively. Which matches /thensome.*5/.

Right, this will sometimes do the right thing. But it will also often do the wrong thing. It's also very expensive (we specifically avoid feeding large binary files to xdiff, but I think "-G" will happily do so -- I didn't double check, though).

-Peff
Previous: Ævar Arnfjörð BjarmasonNext: Thomas Braun
Message 22 of 30 in “Teach log -G to ignore binary files”
  1. 0/2 Teach log -G to ignore binary filesThomas Braun, Nov 21, 2018
  2. 1/2 log -G: Ignore binary filesThomas Braun, Nov 21, 2018
  3. 2/2 log -S: Add test which searches in binary filesThomas Braun, Nov 21, 2018
  4. 0/2 Teach log -G to ignore binary filesThomas Braun, Nov 21, 2018
  5. log -G: Ignore binary filesThomas Braun, Nov 28, 2018
  6. Ævar Arnfjörð BjarmasonNov 28, 2018
  7. Thomas BraunDec 14, 2018
  8. Junio C HamanoNov 29, 2018
  9. Junio C HamanoNov 29, 2018
  10. Thomas BraunDec 14, 2018
  11. Thomas BraunDec 14, 2018
  12. log -G: ignore binary filesThomas Braun, Dec 14, 2018
  13. Junio C HamanoDec 26, 2018
  14. Junio C HamanoNov 22, 2018
  15. Thomas BraunNov 28, 2018
  16. Ævar Arnfjörð BjarmasonNov 22, 2018
  17. Junio C HamanoNov 24, 2018
  18. Thomas BraunNov 28, 2018
  19. Junio C HamanoNov 22, 2018
  20. Thomas BraunNov 28, 2018
  21. Ævar Arnfjörð BjarmasonNov 22, 2018
  22. Jeff KingNov 22, 2018
  23. Thomas BraunNov 28, 2018
  24. Thomas BraunNov 28, 2018
  25. Jeff KingNov 22, 2018
  26. Junio C HamanoNov 24, 2018
  27. Thomas BraunNov 28, 2018
  28. Stefan BellerNov 26, 2018
  29. Junio C HamanoNov 27, 2018
  30. Thomas BraunNov 28, 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.