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

Re: Git on Windows, CRLF issues

From
Jeff King <peff@peff.net>
Date
Apr 23, 2008, 21:47 UTC
Message-ID
<20080423214745.GA30057@sigill.intra.peff.net>
In-Reply-To
<480F218C.3060703@viscovery.net>
On Wed, Apr 23, 2008 at 01:46:20PM +0200, Johannes Sixt wrote:
Show 18 quoted lines
> > I assume you are wanting to do something like:
> > 
> >   git filter-branch --blob-filter '
> >     case "$1" in
> >       *.jpg) cat ;;
> >           *) tr a-z A-Z ;;
> >     esac
> >   '
> > 
> > Obviously it is unlikely to get the same blob sha1 as "foo.jpg" and
> > "foo.txt", but it just feels a little wrong.
> 
> Yes, that's how I intended it to work. What's wrong here? The fact that a
> user might name a JPEG foo.txt instead of foo.jpg? Or that the same blob
> might appear with entirely different names, including different suffixes?
> Well, tough luck. Use an index filter. But without any sort of hint what
> the blob is about, your original --blob-filter is useless except for the
> most simplistic repositories.

Yes, the script produces incorrect results if you have the same blob with different names. IOW, if I accidentally add a JPEG as 'foo', and then later rename it to 'foo.jpg', it will munge the blob the first time it sees it, and then use the munged value for 'foo.jpg', since we never even run the case statement. Yes, this is not terribly likely, but it does seem like an awful (and hard to diagnose!) bug to have hiding in the script.

The correct fix is either:
  - the blob cache needs to take into account sha1 _and_ path
  - the cache lookup needs to be _inside_ the path filter. In that case
    you would either have to support it in the script (e.g.,
    --blob-ignore jpg), or you could make the caching an optional part
    of the blob filter (the way you can call 'map' explicitly from your
    filters).
-Peff
Previous: Johannes SixtNext: Junio C Hamano
Message 17 of 30 in “Git on Windows, CRLF issues”
  1. Peter KarlssonApr 21, 2008
  2. Johannes SchindelinApr 21, 2008
  3. Avery PennarunApr 21, 2008
  4. Jeff KingApr 22, 2008
  5. Avery PennarunApr 22, 2008
  6. Peter KarlssonApr 23, 2008
  7. Jeff KingApr 23, 2008
  8. Peter KarlssonApr 23, 2008
  9. Johan HerlandApr 23, 2008
  10. Johannes SixtApr 23, 2008
  11. Jeff KingApr 23, 2008
  12. Johannes SchindelinApr 23, 2008
  13. Jeff KingApr 23, 2008
  14. Johannes SixtApr 23, 2008
  15. Jeff KingApr 23, 2008
  16. Johannes SixtApr 23, 2008
  17. Jeff KingApr 23, 2008
  18. Junio C HamanoApr 23, 2008
  19. Avery PennarunApr 23, 2008
  20. Johannes SchindelinApr 24, 2008
  21. Avery PennarunApr 24, 2008
  22. Jeff KingApr 24, 2008
  23. Avery PennarunApr 23, 2008
  24. Johannes SixtApr 24, 2008
  25. Johannes SixtApr 22, 2008
  26. Jakub NarebskiApr 21, 2008
  27. Peter KarlssonApr 22, 2008
  28. Johannes SixtApr 22, 2008
  29. Johannes SixtApr 22, 2008
  30. Peter KarlssonApr 22, 2008

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.