From 7119d6d3e504aeaf34974abd36775b55225f6cd2 Mon Sep 17 00:00:00 2001 From: deboeto Date: Thu, 18 Jul 2024 17:23:10 +0200 Subject: [PATCH] git Gui: Add directly calling merge tool from gitconfig * git Gui can open a merge tool when conflicts are detected. The merge tools that are allowed to call have to be hard coded into git Gui althgough there are configuration options for merge tools git in the git config. Git calls the configured merge tools directly from the config while git Gui doesn't. * git Gui can now call the tool configured in the gitconfig directly. * Can be enabled through setting gui.mergeToolFromConfig * Disabled by default, since option is most likely never set * bc3 and vscode tested --- Documentation/config/gui.txt | 4 ++++ git-gui/lib/mergetool.tcl | 11 +++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Documentation/config/gui.txt b/Documentation/config/gui.txt index 171be774d243fd..e63d0b46e7c421 100644 --- a/Documentation/config/gui.txt +++ b/Documentation/config/gui.txt @@ -55,3 +55,7 @@ gui.blamehistoryctx:: linkgit:gitk[1] for the selected commit, when the `Show History Context` menu item is invoked from 'git gui blame'. If this variable is set to zero, the whole history is shown. + +gui.mergeToolFromConfig:: + If true, allow to call the merge tool configured in gitconfig + in git gui directly. \ No newline at end of file diff --git a/git-gui/lib/mergetool.tcl b/git-gui/lib/mergetool.tcl index e688b016ef6c9d..fbd0889612a302 100644 --- a/git-gui/lib/mergetool.tcl +++ b/git-gui/lib/mergetool.tcl @@ -272,8 +272,15 @@ proc merge_resolve_tool2 {} { } } default { - error_popup [mc "Unsupported merge tool '%s'" $tool] - return + if {[is_config_true gui.mergetoolfromconfig]} { + set path [get_config mergetool.$tool.path] + set cmdline_config [get_config mergetool.$tool.cmd] + set cmdline_substituted [subst -nobackslashes -nocommands $cmdline_config] + set cmdline [lreplace $cmdline_substituted 0 0 $path] + } else { + error_popup [mc "Unsupported merge tool '%s'" $tool] + return + } } }