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

Re: Best way to apply textconv to a working tree file

From
Jeff King <peff@peff.net>
Date
Jun 1, 2010, 17:14 UTC
Message-ID
<20100601171359.GD9702@sigill.intra.peff.net>
In-Reply-To
<vpqd3walot1.fsf@bauges.imag.fr>
On Tue, Jun 01, 2010 at 06:07:06PM +0200, Matthieu Moy wrote:
> After thinking about it, I think a mix of these solutions would be
> OK:
> 
> git cat-file --textconv <blob-sha1>            # Run textconv on blob

This wouldn't work. The textconv is defined by the diff driver, which is associated with a pathname, not a blob. You don't have a pathname here (and in fact the same blob could potentially even be represented by different textconvs if it appeared in different contexts).

> git cat-file --textconv <tree-sha1>:<filename> # Run textconv on file
>                                                # (in object database)

This could work in theory, but will not be as easy to implement as you hope. The code to parse <tree-ish>:<filename> will give you only a blob sha1, and you will have to look up the tree manually (which you will have to split at the ":" manually, remembering that it may be as complex as "HEAD@{12:00 yesterday}:foo.c", then check the diff attr manually for that filename.

It would be nice if there was some way in the get_sha1* functions to save some context, like tree context and filename. This would be helpful for something like "git show HEAD:foo.txt", which probably should be respecting autocrlf and smudge/clean filters.

> git cat-file --textconv ./<filename>           # Run textconv on file
>                                                # (in worktree)

FWIW, I think this combination is the best of the possible syntaxes outlined in the original mail.

-Peff
Previous: Matthieu MoyNext: Matthieu Moy
Message 3 of 8 in “Best way to apply textconv to a working tree file”
  1. Clément PoulainJun 1, 2010
  2. Matthieu MoyJun 1, 2010
  3. Jeff KingJun 1, 2010
  4. Matthieu MoyJun 1, 2010
  5. Jeff KingJun 1, 2010
  6. Clément PoulainJun 2, 2010
  7. Jeff KingJun 1, 2010
  8. Clément PoulainJun 2, 2010

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.