Re: [Question] Diff text filters and git add
- From
Jakub Narebski <jnareb@gmail.com>
- Date
- Jul 11, 2019, 17:28 UTC
- Message-ID
- <86h87sa3b6.fsf@gmail.com>
- In-Reply-To
- <00bb01d5371d$453a8520$cfaf8f60$@nexbridge.com>
"Randall S. Becker" <rsbecker@nexbridge.com> writes:
> On July 9, 2019 5:51 PM, Peff wrote:
[...]
Show 14 quoted lines
>> 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.
If you want to ignore changes, --assume-unchanged (i.e. lying to Git) is a wrong solution, as it can lead to data loss. It is meant as performance optimization.
A better solution would be to use --skip-worktree, which though meant for sparse checkout can be used for ignoring changes. The only problem is that it can prevent some safe operations, like git-stash, because git thinks that it could lead to data loss.
Though I am not sure if they are needed with clean/smudge filter.
Best,
-- Jakub Narębski