git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* git diff-tree ignores --textconv
@ 2018-09-23 22:41 Stas Bekman
  2018-09-24  0:43 ` Jeff King
  0 siblings, 1 reply; 5+ messages in thread
From: Stas Bekman @ 2018-09-23 22:41 UTC (permalink / raw)
  To: Git Mailing List

Hi,

I'm using a 3rd party application that internally uses 'git diff-tree'
instead of 'git diff'. I'm trying to add filter and it works with 'git
diff' but it gets ignored with 'git diff-tree' despite having --textconv.

I was able to reproduce the problem with the following much more
simplified setup:


$ git check-attr diff test/test.ipynb
test/test.ipynb: diff: jupyternotebook


$ git config --get diff.jupyternotebook.command
git-nbdiffdriver diff


$ GIT_TRACE=1 git diff test/test.ipynb
[...]
run_command: GIT_DIFF_PATH_COUNTER=1 GIT_DIFF_PATH_TOTAL=1
'git-nbdiffdriver diff'
[...]
<shows nbdiff output as desired>


$ GIT_TRACE=1 git diff-tree -p HEAD --textconv test/test.ipynb
<shows normal diff, ignoring nbdiff>

Git tracing shows nothing relevant as in the command above.

According to https://git-scm.com/docs/git-diff-tree adding --textconv
should have respected the configured diff filter, but it does nothing.

Is this a bug or do I have something misconfigured?

Thank you.

git version 2.17.1

-- 
________________________________________________
Stas Bekman       <'))))><       <'))))><
https://stasosphere.com  https://chestofbooks.com
https://experientialsexlab.com https://stason.org
https://stasosphere.com/experience-life/my-books

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: git diff-tree ignores --textconv
  2018-09-23 22:41 git diff-tree ignores --textconv Stas Bekman
@ 2018-09-24  0:43 ` Jeff King
  2018-09-24  0:56   ` Stas Bekman
  0 siblings, 1 reply; 5+ messages in thread
From: Jeff King @ 2018-09-24  0:43 UTC (permalink / raw)
  To: Stas Bekman; +Cc: Git Mailing List

On Sun, Sep 23, 2018 at 03:41:45PM -0700, Stas Bekman wrote:

> $ git config --get diff.jupyternotebook.command
> git-nbdiffdriver diff

That's an "external diff driver", not a textconv driver.

So here:

> $ GIT_TRACE=1 git diff-tree -p HEAD --textconv test/test.ipynb
> <shows normal diff, ignoring nbdiff>

You probably want "--ext-diff", not "--textconv".

There's some discussion in the gitattributes manpage, but the short of
it is that textconv converts binary input to text, which is then fed
through the normal diff mechanism. Whereas an external diff driver is
given both sides and can produce whatever output it wants. Textconv is
less flexible, but generally way easier to write.

-Peff

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: git diff-tree ignores --textconv
  2018-09-24  0:43 ` Jeff King
@ 2018-09-24  0:56   ` Stas Bekman
  2018-09-24  1:23     ` Jeff King
  0 siblings, 1 reply; 5+ messages in thread
From: Stas Bekman @ 2018-09-24  0:56 UTC (permalink / raw)
  To: Jeff King; +Cc: Git Mailing List

On 2018-09-23 05:43 PM, Jeff King wrote:
> On Sun, Sep 23, 2018 at 03:41:45PM -0700, Stas Bekman wrote:
> 
>> $ git config --get diff.jupyternotebook.command
>> git-nbdiffdriver diff
> 
> That's an "external diff driver", not a textconv driver.
> 
> So here:
> 
>> $ GIT_TRACE=1 git diff-tree -p HEAD --textconv test/test.ipynb
>> <shows normal diff, ignoring nbdiff>
> 
> You probably want "--ext-diff", not "--textconv".
> 
> There's some discussion in the gitattributes manpage, but the short of
> it is that textconv converts binary input to text, which is then fed
> through the normal diff mechanism. Whereas an external diff driver is
> given both sides and can produce whatever output it wants. Textconv is
> less flexible, but generally way easier to write.

Thank you, Jeff, for explaining my misunderstanding and how to fix it.

Would it be safe to ask the maintainer of the application to include
both --textconv and --ext-diff in that 'git diff-tree' call? I only need
the latter, but someone needed --textconv there as it's in the code.

This is for this package:
https://github.com/rsmmr/git-notifier

It was added here:
https://github.com/rsmmr/git-notifier/search?q=textconv&unscoped_q=textconv

-- 
________________________________________________
Stas Bekman       <'))))><       <'))))><
https://stasosphere.com  https://chestofbooks.com
https://experientialsexlab.com https://stason.org
https://stasosphere.com/experience-life/my-books

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: git diff-tree ignores --textconv
  2018-09-24  0:56   ` Stas Bekman
@ 2018-09-24  1:23     ` Jeff King
  2018-09-24  1:37       ` Stas Bekman
  0 siblings, 1 reply; 5+ messages in thread
From: Jeff King @ 2018-09-24  1:23 UTC (permalink / raw)
  To: Stas Bekman; +Cc: Git Mailing List

On Sun, Sep 23, 2018 at 05:56:03PM -0700, Stas Bekman wrote:

> > You probably want "--ext-diff", not "--textconv".
> [...]
> Would it be safe to ask the maintainer of the application to include
> both --textconv and --ext-diff in that 'git diff-tree' call? I only need
> the latter, but someone needed --textconv there as it's in the code.

I think so. The main reason that they are not the default for plumbing
commands such as diff-tree is that the output may be quite surprising to
anything trying to parse the output. Using --textconv will always
produce a diff, but one that may not be applied to the original content.
Using --ext-diff may produce output that doesn't even look like a diff,
though in practice they often do.

> This is for this package:
> https://github.com/rsmmr/git-notifier

It looks like the output is meant to be read by humans, so yeah, I think
it would be fine (and preferred) to enable both.

-Peff

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: git diff-tree ignores --textconv
  2018-09-24  1:23     ` Jeff King
@ 2018-09-24  1:37       ` Stas Bekman
  0 siblings, 0 replies; 5+ messages in thread
From: Stas Bekman @ 2018-09-24  1:37 UTC (permalink / raw)
  To: Jeff King; +Cc: Git Mailing List

On 2018-09-23 06:23 PM, Jeff King wrote:
> On Sun, Sep 23, 2018 at 05:56:03PM -0700, Stas Bekman wrote:
> 
>>> You probably want "--ext-diff", not "--textconv".
>> [...]
>> Would it be safe to ask the maintainer of the application to include
>> both --textconv and --ext-diff in that 'git diff-tree' call? I only need
>> the latter, but someone needed --textconv there as it's in the code.
> 
> I think so. The main reason that they are not the default for plumbing
> commands such as diff-tree is that the output may be quite surprising to
> anything trying to parse the output. Using --textconv will always
> produce a diff, but one that may not be applied to the original content.
> Using --ext-diff may produce output that doesn't even look like a diff,
> though in practice they often do.
> 
>> This is for this package:
>> https://github.com/rsmmr/git-notifier
> 
> It looks like the output is meant to be read by humans, so yeah, I think
> it would be fine (and preferred) to enable both.

Fantastic. Thank you so much, Jeff.

-- 
________________________________________________
Stas Bekman       <'))))><       <'))))><
https://stasosphere.com  https://chestofbooks.com
https://experientialsexlab.com https://stason.org
https://stasosphere.com/experience-life/my-books

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-09-24  1:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-23 22:41 git diff-tree ignores --textconv Stas Bekman
2018-09-24  0:43 ` Jeff King
2018-09-24  0:56   ` Stas Bekman
2018-09-24  1:23     ` Jeff King
2018-09-24  1:37       ` Stas Bekman

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).