Re: Using clean/smudge filters with difftool

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Junio C Hamano venit, vidit, dixit 19.06.2015 00:55:
> John Keeping <john@xxxxxxxxxxxxx> 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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]