{"thread":{"id":"49409","subject":"git diff-tree ignores --textconv","startedAt":"2018-09-23T22:41:53Z","lastAt":"2018-09-24T01:39:20Z","messageCount":5,"participants":["Stas Bekman","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"358738","messageId":"41cd358c-d900-2996-b78a-b9d897a2ba2b@stason.org","threadId":"49409","inReplyTo":null,"subject":"git diff-tree ignores --textconv","fromName":"Stas Bekman","fromEmail":"stas@stason.org","sentAt":"2018-09-23T22:41:45Z","receivedAt":"2018-09-23T22:41:53Z","isPatch":false,"sender":{"key":"stas@stason.org","avatar":null},"body":"Hi,\n\nI'm using a 3rd party application that internally uses 'git diff-tree'\ninstead of 'git diff'. I'm trying to add filter and it works with 'git\ndiff' but it gets ignored with 'git diff-tree' despite having --textconv.\n\nI was able to reproduce the problem with the following much more\nsimplified setup:\n\n\n$ git check-attr diff test/test.ipynb\ntest/test.ipynb: diff: jupyternotebook\n\n\n$ git config --get diff.jupyternotebook.command\ngit-nbdiffdriver diff\n\n\n$ GIT_TRACE=1 git diff test/test.ipynb\n[...]\nrun_command: GIT_DIFF_PATH_COUNTER=1 GIT_DIFF_PATH_TOTAL=1\n'git-nbdiffdriver diff'\n[...]\n<shows nbdiff output as desired>\n\n\n$ GIT_TRACE=1 git diff-tree -p HEAD --textconv test/test.ipynb\n<shows normal diff, ignoring nbdiff>\n\nGit tracing shows nothing relevant as in the command above.\n\nAccording to https://git-scm.com/docs/git-diff-tree adding --textconv\nshould have respected the configured diff filter, but it does nothing.\n\nIs this a bug or do I have something misconfigured?\n\nThank you.\n\ngit version 2.17.1\n\n-- \n________________________________________________\nStas Bekman       <'))))><       <'))))><\nhttps://stasosphere.com  https://chestofbooks.com\nhttps://experientialsexlab.com https://stason.org\nhttps://stasosphere.com/experience-life/my-books\n"},{"id":"358740","messageId":"20180924004307.GA26103@sigill.intra.peff.net","threadId":"49409","inReplyTo":"41cd358c-d900-2996-b78a-b9d897a2ba2b@stason.org","subject":"Re: git diff-tree ignores --textconv","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2018-09-24T00:43:07Z","receivedAt":"2018-09-24T00:46:01Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sun, Sep 23, 2018 at 03:41:45PM -0700, Stas Bekman wrote:\n\n> $ git config --get diff.jupyternotebook.command\n> git-nbdiffdriver diff\n\nThat's an \"external diff driver\", not a textconv driver.\n\nSo here:\n\n> $ GIT_TRACE=1 git diff-tree -p HEAD --textconv test/test.ipynb\n> <shows normal diff, ignoring nbdiff>\n\nYou probably want \"--ext-diff\", not \"--textconv\".\n\nThere's some discussion in the gitattributes manpage, but the short of\nit is that textconv converts binary input to text, which is then fed\nthrough the normal diff mechanism. Whereas an external diff driver is\ngiven both sides and can produce whatever output it wants. Textconv is\nless flexible, but generally way easier to write.\n\n-Peff\n"},{"id":"358741","messageId":"13dec8d3-b164-dc24-45e0-8e1bbd550524@stason.org","threadId":"49409","inReplyTo":"20180924004307.GA26103@sigill.intra.peff.net","subject":"Re: git diff-tree ignores --textconv","fromName":"Stas Bekman","fromEmail":"stas@stason.org","sentAt":"2018-09-24T00:56:03Z","receivedAt":"2018-09-24T00:56:08Z","isPatch":false,"sender":{"key":"stas@stason.org","avatar":null},"body":"On 2018-09-23 05:43 PM, Jeff King wrote:\n> On Sun, Sep 23, 2018 at 03:41:45PM -0700, Stas Bekman wrote:\n> \n>> $ git config --get diff.jupyternotebook.command\n>> git-nbdiffdriver diff\n> \n> That's an \"external diff driver\", not a textconv driver.\n> \n> So here:\n> \n>> $ GIT_TRACE=1 git diff-tree -p HEAD --textconv test/test.ipynb\n>> <shows normal diff, ignoring nbdiff>\n> \n> You probably want \"--ext-diff\", not \"--textconv\".\n> \n> There's some discussion in the gitattributes manpage, but the short of\n> it is that textconv converts binary input to text, which is then fed\n> through the normal diff mechanism. Whereas an external diff driver is\n> given both sides and can produce whatever output it wants. Textconv is\n> less flexible, but generally way easier to write.\n\nThank you, Jeff, for explaining my misunderstanding and how to fix it.\n\nWould it be safe to ask the maintainer of the application to include\nboth --textconv and --ext-diff in that 'git diff-tree' call? I only need\nthe latter, but someone needed --textconv there as it's in the code.\n\nThis is for this package:\nhttps://github.com/rsmmr/git-notifier\n\nIt was added here:\nhttps://github.com/rsmmr/git-notifier/search?q=textconv&unscoped_q=textconv\n\n-- \n________________________________________________\nStas Bekman       <'))))><       <'))))><\nhttps://stasosphere.com  https://chestofbooks.com\nhttps://experientialsexlab.com https://stason.org\nhttps://stasosphere.com/experience-life/my-books\n"},{"id":"358742","messageId":"20180924012354.GA27439@sigill.intra.peff.net","threadId":"49409","inReplyTo":"13dec8d3-b164-dc24-45e0-8e1bbd550524@stason.org","subject":"Re: git diff-tree ignores --textconv","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2018-09-24T01:23:54Z","receivedAt":"2018-09-24T01:29:09Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sun, Sep 23, 2018 at 05:56:03PM -0700, Stas Bekman wrote:\n\n> > You probably want \"--ext-diff\", not \"--textconv\".\n> [...]\n> Would it be safe to ask the maintainer of the application to include\n> both --textconv and --ext-diff in that 'git diff-tree' call? I only need\n> the latter, but someone needed --textconv there as it's in the code.\n\nI think so. The main reason that they are not the default for plumbing\ncommands such as diff-tree is that the output may be quite surprising to\nanything trying to parse the output. Using --textconv will always\nproduce a diff, but one that may not be applied to the original content.\nUsing --ext-diff may produce output that doesn't even look like a diff,\nthough in practice they often do.\n\n> This is for this package:\n> https://github.com/rsmmr/git-notifier\n\nIt looks like the output is meant to be read by humans, so yeah, I think\nit would be fine (and preferred) to enable both.\n\n-Peff\n"},{"id":"358743","messageId":"84b70e1b-5868-f122-6960-e725163ccde1@stason.org","threadId":"49409","inReplyTo":"20180924012354.GA27439@sigill.intra.peff.net","subject":"Re: git diff-tree ignores --textconv","fromName":"Stas Bekman","fromEmail":"stas@stason.org","sentAt":"2018-09-24T01:37:42Z","receivedAt":"2018-09-24T01:39:20Z","isPatch":false,"sender":{"key":"stas@stason.org","avatar":null},"body":"On 2018-09-23 06:23 PM, Jeff King wrote:\n> On Sun, Sep 23, 2018 at 05:56:03PM -0700, Stas Bekman wrote:\n> \n>>> You probably want \"--ext-diff\", not \"--textconv\".\n>> [...]\n>> Would it be safe to ask the maintainer of the application to include\n>> both --textconv and --ext-diff in that 'git diff-tree' call? I only need\n>> the latter, but someone needed --textconv there as it's in the code.\n> \n> I think so. The main reason that they are not the default for plumbing\n> commands such as diff-tree is that the output may be quite surprising to\n> anything trying to parse the output. Using --textconv will always\n> produce a diff, but one that may not be applied to the original content.\n> Using --ext-diff may produce output that doesn't even look like a diff,\n> though in practice they often do.\n> \n>> This is for this package:\n>> https://github.com/rsmmr/git-notifier\n> \n> It looks like the output is meant to be read by humans, so yeah, I think\n> it would be fine (and preferred) to enable both.\n\nFantastic. Thank you so much, Jeff.\n\n-- \n________________________________________________\nStas Bekman       <'))))><       <'))))><\nhttps://stasosphere.com  https://chestofbooks.com\nhttps://experientialsexlab.com https://stason.org\nhttps://stasosphere.com/experience-life/my-books\n"}]}