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

git mergetool, merge.tool, merge.guitool and DISPLAY

From
Tao Klerks <tao@klerks.biz>
Date
Sep 9, 2022, 11:56 UTC
Message-ID
<CAPMMpogZd_em4_Fdk0sNFqAXqH19VOVyw3WsNT2LHsQNOb0_rw@mail.gmail.com>
Hi folks,

I've just become aware today of what *seems* like a very strange discrepancy or limitation in "git mergetool":

When you use it without having configured a "merge.tool", it auto-selects the first available tool from a predefined list, which appears to be hardcoded in "git-mergetool--lib.sh", with some conditions around "$DISPLAY", "$GNOME_DESKTOP_SESSION_ID" and "${VISUAL:-$EDITOR}".

In this "auto-selection" situation, no GUI-based merge tool will be offered/selected if you're not in a GUI session.

When you configure your tools, you can configure "merge.tool" for the default, and "merge.guitool" for GUI contexts - so far so good, sounds consistent.

However, once you've configured these two settings, "git mergetool" will never select the GUI tool you've configured unless you very *explicitly* tell it to, by specifying the --gui argument. The sensible auto-selection based on "DISPLAY" disappears.

The upshot, as I understand it, is that the only way to get a GUI when I'm connected with an X session, and get a terminal-based mergetool when I'm not, without having to be aware and issue different commands, is to accept whatever tooling default order is hardcoded in "git-mergetool--lib.sh"

Is this intentional / is there any logic here, or is this just unfortunate, a result of the auto-selection evolving more intelligently than the built-in explicit "--gui" selection, over time??

If I wanted to improve this, what would be a more sensible approach?
* Assume "--gui" if there is a DISPLAY and "--no-gui" has not been
specified? (behavior change for some existing users)
* Add a new configuration to enable such an "auto-gui respecting
config" mode (no behavior change)

(I have not looked into "git difftool", but I assume the same arguments and issues apply - if so an equivalent improvement would need to be made there of course)

Thanks for any thoughts, Tao

Next: Junio C Hamano
Message 1 of 5 in “git mergetool, merge.tool, merge.guitool and DISPLAY”
  1. Tao KlerksSep 9, 2022
  2. Junio C HamanoSep 9, 2022
  3. Tao KlerksSep 9, 2022
  4. Junio C HamanoSep 9, 2022
  5. Tao KlerksOct 12, 2022

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.