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

Re: [2.22.0] difftool no longer passes through to git diff if diff.tool is unset

From
Jeff King <peff@peff.net>
Date
Jun 25, 2019, 21:35 UTC
Message-ID
<20190625213545.GA23411@sigill.intra.peff.net>
In-Reply-To
<SN6PR09MB3248412C9E5AE197B65A8D878AE40@SN6PR09MB3248.namprd09.prod.outlook.com>
On Thu, Jun 20, 2019 at 07:29:36PM +0000, Pugh, Logan wrote:
Show 5 quoted lines
> Thanks for the explanation. It sounds like I was under the incorrect 
> assumption that I could use the difftool command the same way as the 
> diff command. Part of my confusion could be blamed on the git-difftool 
> documentation (https://git-scm.com/docs/git-difftool) which near the top 
> states:

Well, it _is_ true that you can use it the same way. It's just that you need to configure it to use whatever 3rd-party tool you want (and if you do not want to configure a tool, then you are better off just using git-diff directly). It was only due to a bug/historical accident that it behaved just like git-diff in the no-index case (but not in the regular case -- AFAICT, that would have been broken for your script always).

Show 14 quoted lines
> My use case is a CLI program I've written that processes and then 
> compares two arbitrary files using the git difftool apparatus as 
> configured by the end user, leaving the choice to them whether to use 
> the internal diff tool or an external tool.
> 
> Now, if I'm understanding correctly, I should not rely on the behavior 
> of git difftool --no-index passing through to git diff. I could add 
> another CLI switch and code path to my program that calls git diff 
> directly instead of git difftool but the passthrough behavior seemed 
> more elegant at the time.
> 
> Ideally, in my mind, git difftool should work as it says on the tin, as 
> a straight up passthrough to git diff *unless* explicitly configured to 
> use external tools (e.g. diff.tool and diff.guitool).

That does make some sense to me for your use case. But I'm worried it would be a worse experience for people new to difftool (they run it and scratch their heads why it does not do anything different, whereas now they get walked through an interactive configuration).

I dunno. I do not use difftool myself, so I don't have strong opinions.

In the meantime, I think you can probably switch behavior in your script by checking if the diff.tool config is set. It might be nice if difftool had a better way to query that without you having to know if it's configured. Or in your case I suppose even better would just be an option like "--if-not-configured-just-use-regular-diff". Then it would do what you want, without impacting users who do want the interactive setup.

-Peff
Previous: Pugh, LoganNext: Pugh, Logan
Message 6 of 8 in “[2.22.0] difftool no longer passes through to git diff if diff.tool is unset”
  1. Pugh, LoganJun 19, 2019
  2. Denton LiuJun 20, 2019
  3. Denton LiuJun 20, 2019
  4. Jeff KingJun 20, 2019
  5. Pugh, LoganJun 20, 2019
  6. Jeff KingJun 25, 2019
  7. Pugh, LoganJun 25, 2019
  8. Jeff KingJun 26, 2019

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.