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

RE: [Question] Diff text filters and git add

From
Randall S. Becker <rsbecker@nexbridge.com>
Date
Jul 10, 2019, 12:44 UTC
Message-ID
<00bb01d5371d$453a8520$cfaf8f60$@nexbridge.com>
In-Reply-To
<20190709215104.GA20936@sigill.intra.peff.net>
On July 9, 2019 5:51 PM, Peff wrote:
Show 27 quoted lines
> To: Randall S. Becker <rsbecker@nexbridge.com>
> Cc: git@vger.kernel.org
> Subject: Re: [Question] Diff text filters and git add
> 
> On Tue, Jul 09, 2019 at 05:43:05PM -0400, Randall S. Becker wrote:
> 
> > I am trying to do something a bit strange and wonder about the best
> > way to go. I have a text filter that presents content of very special
> > binary file formats using textconv. What I am wondering is whether
> > using the textconv mechanism is sufficient to have git calculate the
> > file signature or whether I need to use an external diff engine, so
> > that git add behaves in a stable manner (i.e., does git internally use
> > the textconv mechanism for evaluating whether a file changed or
> > whether the external diff engine is required, or whether this is even
> possible at all).
> 
> No, textconv only applies when generating a diff to output, and will never
> impact what's stored in Git.
> 
> It sounds like you might want a clean filter instead, to sanitize the file
> contents as they come into Git (and perhaps a matching smudge filter to
> convert back to the working-tree version if necessary).
> 
> You're talking about "the diff engine" here, but note that git-add would never
> do a diff at all. It cares only about full sha1s (and optimizes out re-computing
> the sha1 on each invocation by using stat data). So outside of clean/smudge,
> there's nothing else going on.
Thanks. I can script this instead. Will do an external diff then --assume-unchanged when I detect an equivalence.

Appreciate the advice and info, Randall

Previous: Jeff KingNext: Jakub Narebski
Message 3 of 4 in “[Question] Diff text filters and git add”
  1. Randall S. BeckerJul 9, 2019
  2. Jeff KingJul 9, 2019
  3. Randall S. BeckerJul 10, 2019
  4. Jakub NarebskiJul 11, 2019

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.