path: root/
diff options
authorDenton Liu <>2019-04-29 06:21:08 (GMT)
committerJunio C Hamano <>2019-05-13 14:11:59 (GMT)
commit05fb8726cccc74908853c166248ff9b6abdafae5 (patch)
treee879f61c63d326d264ab6911fd8e32e6445610e4 /
parent57d93c1d2ce7deddf485e7c826278fef6815ec6b (diff)
mergetool: use get_merge_tool function
In git-mergetool, the logic for getting which merge tool to use is duplicated in git-mergetool--lib, except for the fact that it needs to know whether the tool was guessed or not. Rewrite `get_merge_tool` to return whether or not the tool was guessed through the return code and make git-mergetool call this function instead of duplicating the logic. Note that 1 was chosen to be the return code of when a tool is guessed because it seems like a slightly more abnormal condition than getting a tool that's explicitly specified but this is completely arbitrary. Also, let `$GIT_MERGETOOL_GUI` be set to determine whether or not the guitool will be selected. This change is not completely backwards compatible as there may be external users of git-mergetool--lib. However, only one user, git-diffall[1], was found from searching GitHub and Google, and this tool is superseded by `git difftool --dir-diff` anyway. It seems very unlikely that there exists an external caller that would take into account the return code of `get_merge_tool` as it would always return 0 before this change so this change probably does not affect any external users. [1]: Signed-off-by: Denton Liu <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to '')
1 files changed, 4 insertions, 1 deletions
diff --git a/ b/
index 83bf524..b928179 100644
--- a/
+++ b/
@@ -403,14 +403,17 @@ get_merge_tool_path () {
get_merge_tool () {
+ is_guessed=false
# Check if a merge tool has been configured
- merge_tool=$(get_configured_merge_tool)
+ merge_tool=$(get_configured_merge_tool $GIT_MERGETOOL_GUI)
# Try to guess an appropriate merge tool if no tool has been set.
if test -z "$merge_tool"
merge_tool=$(guess_merge_tool) || exit
+ is_guessed=true
echo "$merge_tool"
+ test "$is_guessed" = false
mergetool_find_win32_cmd () {