Skip to content

Commit bdc8d9a

Browse files
committed
Use git mergetool for merge.tool identifiers
1 parent 44c4cac commit bdc8d9a

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

lib/thor/shell/basic.rb

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,8 +380,18 @@ def merge_tool #:nodoc:
380380
@merge_tool ||= ENV["THOR_MERGE"] || git_merge_tool
381381
end
382382

383-
def git_merge_tool #:nodoc:
384-
`git config merge.tool`.rstrip rescue ""
383+
def git_merge_tool
384+
tool = `git config merge.tool`.strip
385+
return "" if tool.empty?
386+
387+
custom = `git config --get mergetool.#{tool}.cmd`.strip
388+
return custom unless custom.empty?
389+
390+
return tool if system("command -v #{Shellwords.escape(tool)} > /dev/null 2>&1")
391+
392+
"git mergetool --no-prompt --tool=#{tool}"
393+
rescue
394+
""
385395
end
386396
end
387397
end

0 commit comments

Comments
 (0)