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 21, 2015, 19:29 UTC
Message-ID
<558710AF.9040009@drmicha.warpmail.net>
In-Reply-To
<xmqqsi9naavw.fsf@gitster.dls.corp.google.com>
Junio C Hamano venit, vidit, dixit 19.06.2015 19:03:
Show 11 quoted lines
> Michael J Gruber <git@drmicha.warpmail.net> writes:
> 
>> 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.
> 
> It does not appear to "mix cleaned and smudged" to me (even though
> before Dscho's commit that John pointed out, we did mix by mistake)
> to me,
... neither to me. I appears as if you missed the past subjunctive ;)
> but you arrived at the correct conclusion in the rest of your
> sentence.
Show 66 quoted lines
> We treat "worktree files" and "smudged repo blobs" as "comparable"
> because by definition the latter is what you get if you did a
> "checkout" of the blob.  Indeed, when we know a worktree file is an
> unmodified checkout from a blob and we want to have a read-only
> temporary file for a "smudged repo blob", we allow that worktree
> file to be used as such.
> 
> So in that sense, the commit by Dscho that John pointed out earlier
> was not something that changed the semantics; it merely made things
> consistent (before that commit, we used to use clean version if we
> do not have a usable worktree file).
> 
> It is a separate question which of clean or smudged an external diff
> tool should be given to work on.
> 
>> 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.
> 
> Go back six years and make a review comment before 4e218f54 (Smudge
> the files fed to external diff and textconv, 2009-03-21) was taken
> ;-).  The argument against that commit may have gone like this:
> 
>  * The current (that is, current as of 4e218f54^) code is
>    inconsistent, and your patch has a side effect of making it
>    consistent by always feeding smudged version.
> 
>  * We however could make it consistent by always feeding clean
>    version (i.e. disable borrow-from-working-tree codepath when
>    driving external diff).  And that gives us cleaner semantics; the
>    internal diff and external diff will both work on clean, not
>    smudged data.
> 
>  * Of course, going the "clean" way would not help your cause of
>    allowing external diff to work on smudged version, so you would
>    need a separate patch on top of that "consistently feed 'clean'
>    version" fix to optionally allow "consistently feed 'smudge'
>    version" mode to help msysGit issue 177.
> 
> And I would have bought such an argument with 97% chance [*1*].
> 
> I do not think 6 years have changed things very much with respect to
> the above three-bullet point argument, except that it would be too
> late to set the default to 'clean' all of a sudden.  So a plausible
> way forward would be to
> 
>  * introduce an option to feed 'clean' versions to external diff
>    drivers, perhaps with --ext-diff-clean=<driver> command line
>    option and GIT_EXTERNAL_DIFF_CLEAN environment variable, both of
>    which take precedence over existing --ext-diff/GIT_EXTERNAL_DIFF
> 
>  * optionally add a configuration variable diff.feedCleanToExternal
>    that makes --ext-diff/GIT_EXTERNAL_DIFF behave as if their
>    'clean' siblings were given.  Default it to false.
> 
> My gut feeling is that textconv should need a similar treatment for
> consistency (after all, it goes through the same prepare_temp_file()
> infrastructure).
> 
> 
> [Footnote]
> 
> *1* The 3% reservation is that I am not entirely convinced that
> "both internal and external get to work on the same 'clean'
> representation gives us cleaner semantics" is always true.

With consistency stepping back behind compatibility, I don't expect any defaults to change.

But a knob to change defaults would be nice, yes, and in that case for external diff as well as textconv. A config variable should suffice given that we have "git -c" these days.

Michael
Previous: Junio C Hamano
Message 18 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.