gitweb: Use "previous" header of git-blame -p in 'blame' view
[git/jnareb-git/bp-gitweb.git] / git-difftool--helper.sh
blob57e8e3256d7b6578cda37815163d8945431aa6db
1 #!/bin/sh
2 # git-difftool--helper is a GIT_EXTERNAL_DIFF-compatible diff tool launcher.
3 # This script is typically launched by using the 'git difftool'
4 # convenience command.
6 # Copyright (c) 2009 David Aguilar
8 # Load common functions from git-mergetool--lib
9 TOOL_MODE=diff
10 . git-mergetool--lib
12 # difftool.prompt controls the default prompt/no-prompt behavior
13 # and is overridden with $GIT_DIFFTOOL*_PROMPT.
14 should_prompt () {
15 prompt=$(git config --bool difftool.prompt || echo true)
16 if test "$prompt" = true; then
17 test -z "$GIT_DIFFTOOL_NO_PROMPT"
18 else
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
29 MERGED="$1"
30 LOCAL="$2"
31 REMOTE="$3"
32 BASE="$1"
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"
39 read ans
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'
55 while test $# -gt 6
57 launch_merge_tool "$1" "$2" "$5"
58 shift 7
59 done