2 # git-difftool--helper is a GIT_EXTERNAL_DIFF-compatible diff tool launcher.
3 # This script is typically launched by using the 'git difftool'
6 # Copyright (c) 2009 David Aguilar
8 # Load common functions from git-mergetool--lib
12 # difftool.prompt controls the default prompt/no-prompt behavior
13 # and is overridden with $GIT_DIFFTOOL*_PROMPT.
15 prompt
=$
(git config
--bool difftool.prompt ||
echo true
)
16 if test "$prompt" = true
; then
17 test -z "$GIT_DIFFTOOL_NO_PROMPT"
19 test -n "$GIT_DIFFTOOL_PROMPT"
23 # Sets up shell variables and runs a merge tool
24 launch_merge_tool
() {
25 # Merged is the filename as it appears in the work tree
26 # Local is the contents of a/filename
27 # Remote is the contents of b/filename
28 # Custom merge tool commands might use $BASE so we provide it
34 # $LOCAL and $REMOTE are temporary files so prompt
35 # the user with the real $MERGED name before launching $merge_tool.
36 if should_prompt
; then
37 printf "\nViewing: '$MERGED'\n"
38 printf "Hit return to launch '%s': " "$merge_tool"
42 # Run the appropriate merge tool command
43 run_merge_tool
"$merge_tool"
46 # Allow GIT_DIFF_TOOL and GIT_MERGE_TOOL to provide default values
47 test -n "$GIT_MERGE_TOOL" && merge_tool
="$GIT_MERGE_TOOL"
48 test -n "$GIT_DIFF_TOOL" && merge_tool
="$GIT_DIFF_TOOL"
50 if test -z "$merge_tool"; then
51 merge_tool
="$(get_merge_tool)" ||
exit
54 # Launch the merge tool on each path provided by 'git diff'
57 launch_merge_tool
"$1" "$2" "$5"