summaryrefslogtreecommitdiff
path: root/mergetools
diff options
context:
space:
mode:
authorFernando Ramos <greenfoo@u92.eu>2022-03-30 19:19:08 (GMT)
committerJunio C Hamano <gitster@pobox.com>2022-04-03 22:09:52 (GMT)
commit7b5cf8be180940ce099c8413d02fb5707d900708 (patch)
tree834f9bc647ca5d3f7e67d6bc282eccf0db171ad5 /mergetools
parenta242c150ebb02d4146694d982f806620ca0e565b (diff)
downloadgit-7b5cf8be180940ce099c8413d02fb5707d900708.zip
git-7b5cf8be180940ce099c8413d02fb5707d900708.tar.gz
git-7b5cf8be180940ce099c8413d02fb5707d900708.tar.bz2
vimdiff: add tool documentation
Running 'git {merge,diff}tool --tool-help' now also prints usage information about the vimdiff tool (and its variants) instead of just its name. Two new functions ('diff_cmd_help()' and 'merge_cmd_help()') have been added to the set of functions that each merge tool (ie. scripts found inside "mergetools/") can overwrite to provided tool specific information. Right now, only 'mergetools/vimdiff' implements these functions, but other tools are encouraged to do so in the future, specially if they take configuration options not explained anywhere else (as it is the case with the 'vimdiff' tool and the new 'layout' option) Note that the function 'show_tool_names', used in the implementation of 'git mergetool --tool-help', is also used in Documentation/Makefile to generate the list of allowed values for the configuration variables '{diff,merge}.{gui,}tool'. Adjust the rule so its output is an Asciidoc "description list" instead of a plain list, with the tool name as the item and the newly added tool description as the description. In addition, a section has been added to "Documentation/git-mergetool.txt" to explain the new "layout" configuration option with examples. Helped-by: Philippe Blain <levraiphilippeblain@gmail.com> Signed-off-by: Fernando Ramos <greenfoo@u92.eu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'mergetools')
-rw-r--r--mergetools/vimdiff53
1 files changed, 53 insertions, 0 deletions
diff --git a/mergetools/vimdiff b/mergetools/vimdiff
index 9d1bf4f..461a89b 100644
--- a/mergetools/vimdiff
+++ b/mergetools/vimdiff
@@ -365,6 +365,25 @@ diff_cmd () {
}
+diff_cmd_help () {
+ TOOL=$1
+
+ case "$TOOL" in
+ nvimdiff*)
+ printf "Use Neovim"
+ ;;
+ gvimdiff*)
+ printf "Use gVim (requires a graphical session)"
+ ;;
+ vimdiff*)
+ printf "Use Vim"
+ ;;
+ esac
+
+ return 0
+}
+
+
merge_cmd () {
layout=$(git config mergetool.vimdiff.layout)
@@ -436,6 +455,40 @@ merge_cmd () {
}
+merge_cmd_help () {
+ TOOL=$1
+
+ case "$TOOL" in
+ nvimdiff*)
+ printf "Use Neovim "
+ ;;
+ gvimdiff*)
+ printf "Use gVim (requires a graphical session) "
+ ;;
+ vimdiff*)
+ printf "Use Vim "
+ ;;
+ esac
+
+ case "$TOOL" in
+ *1)
+ echo "with a 2 panes layout (LOCAL and REMOTE)"
+ ;;
+ *2)
+ echo "with a 3 panes layout (LOCAL, MERGED and REMOTE)"
+ ;;
+ *3)
+ echo "where only the MERGED file is shown"
+ ;;
+ *)
+ echo "with a custom layout (see \`git help mergetool\`'s \`BACKEND SPECIFIC HINTS\` section)"
+ ;;
+ esac
+
+ return 0
+}
+
+
translate_merge_tool_path () {
case "$1" in
nvimdiff*)