difftool: add support for a difftool.prompt config variable
[gitweb.git] / git-difftool--helper.sh
index fc61416acb1e14f4c6ad492ee3e105c345a5e44f..f3c27d86adf3ba158de4749d45c4ac54e7887e76 100755 (executable)
@@ -5,9 +5,15 @@
 #
 # Copyright (c) 2009 David Aguilar
 
-# Set GIT_DIFFTOOL_NO_PROMPT to bypass the per-file prompt.
+# difftool.prompt controls the default prompt/no-prompt behavior
+# and is overridden with $GIT_DIFFTOOL*_PROMPT.
 should_prompt () {
-       test -z "$GIT_DIFFTOOL_NO_PROMPT"
+       prompt=$(git config --bool difftool.prompt || echo true)
+       if test "$prompt" = true; then
+               test -z "$GIT_DIFFTOOL_NO_PROMPT"
+       else
+               test -n "$GIT_DIFFTOOL_PROMPT"
+       fi
 }
 
 # This function prepares temporary files and launches the appropriate