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

Re: Using clean/smudge filters with difftool

From
Michael J Gruber <git@drmicha.warpmail.net>
Date
Jun 19, 2015, 08:57 UTC
Message-ID
<5583D993.4090305@drmicha.warpmail.net>
In-Reply-To
<xmqqr3p8bp8l.fsf@gitster.dls.corp.google.com>
Junio C Hamano venit, vidit, dixit 19.06.2015 00:55:
Show 14 quoted lines
> John Keeping <john@keeping.me.uk> writes:
> 
>> I think the summary is that there are some scenarios where the external
>> diff tool should see the smudged version and others where the clean
>> version is more appropriate and Git should support both options.  It
>> seems this is a property of the filter, so I wonder if the best solution
>> is a new "filter.<name>.extdiff = [clean|smudge]" configuration
>> variable (there's probably a better name for the variable than
>> "extdiff").
> 
> Not just the external diff, but the textconv filter obeys the same
> rule.  The setting should be done the same way for both, if we are
> going to go in that direction.
> 

textconv is a "one-way" filter from "blob" to "readable blob". External diffs may prefer to work on "blob" rather than "readable blob", but the currect setup does not seem to produce surprises.

clean and smudge are two-way filters: clean from "worktree blob" (aka file) to "repo blob", smudge the other way round.

Typically, the user perceives these as inverse to each other. But we only require clean to be a left-inverse of smudge, i.e. "(cat-file then) smudge then clean" should give the same "repo blob" (as "cat-file").

We don't require that the other way round, i.e. we don't require smudge to be a left-inverse of clean, and in most setups (like the current one) it is not: smudge does not recreate what clean has cleaned out. It is a no-op (the "identity", while clean is a "projection").

Now, since external diff runs on smudged blobs, it appears as if we mixed cleaned and smudged blobs when feeding external diffs; whereas really, we mix "worktree blobs" and "smudged repo blobs", which is okay as per our definition of clean/smudge: the difference is irrelevant by definition.

I still think that feeding cleaned blobs to external diff would be less surprising (and should be the default, but maybe can't be changed any more) and feeding smudged blobs should be the special case requiring a special config. Because otherwise, the external diff would have to know which parts of the diff are irrelevant - if it display the complete ("uncleaned") diff, it shows differences ("what will be committed") that will not end up in the commit (because they will get cleaned out before).

As a guiding principle, a worktree-HEAD diff and an index-HEAD diff should be previews of the result of "commit -a" resp. "commit", and therefore should diff cleaned versions. textconv, on the other hand, is a setting by which you tell git: "Don't show me the 'proper' diff/commit-preview but a readable version."

Michael
Previous: Junio C HamanoNext: John Keeping
Message 14 of 18 in “Using clean/smudge filters with difftool”
  1. Florian AspartJun 16, 2015
  2. Michael J GruberJun 18, 2015
  3. Florian AspartJun 18, 2015
  4. John KeepingJun 18, 2015
  5. Florian AspartJun 18, 2015
  6. John KeepingJun 18, 2015
  7. Florian AspartJun 18, 2015
  8. John KeepingJun 18, 2015
  9. Florian AspartJun 18, 2015
  10. John KeepingJun 18, 2015
  11. Junio C HamanoJun 18, 2015
  12. John KeepingJun 18, 2015
  13. Junio C HamanoJun 18, 2015
  14. Michael J GruberJun 19, 2015
  15. John KeepingJun 19, 2015
  16. Florian AspartJun 19, 2015
  17. Junio C HamanoJun 19, 2015
  18. Michael J GruberJun 21, 2015

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.