threads / patch / 18690

patchbash completion: add git-difftool

Subject: [PATCH] bash completion: add git-difftool

## tl;dr

2 messages between Apr 2, 2009 and Apr 5, 2009. Diffs are folded; open one to read it.

replies: 1people: 2as markdown or json

David Aguilar· Apr 2, 2009, 11:30 UTC · lore

This adds completion for difftool's --tool flag. The known diff tool names were also consolidated into a single variable.

Signed-off-by: David Aguilar <davvid@gmail.com>
---
 contrib/completion/git-completion.bash |   27 ++++++++++++++++++++++-----
 1 files changed, 22 insertions(+), 5 deletions(-)
Show changes to contrib/completion/git-completion.bash +22 −5
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 4fcd77a..33a8ec7 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -909,6 +909,26 @@ _git_diff ()
 	__git_complete_file
 }
 
+__git_mergetools_common="diffuse ecmerge emerge kdiff3 meld opendiff
+			tkdiff vimdiff gvimdiff xxdiff
+"
+
+_git_difftool ()
+{
+	local cur="${COMP_WORDS[COMP_CWORD]}"
+	case "$cur" in
+	--tool=*)
+		__gitcomp "$__git_mergetools_common kompare" "" "${cur##--tool=}"
+		return
+		;;
+	--*)
+		__gitcomp "--tool="
+		return
+		;;
+	esac
+	COMPREPLY=()
+}
+
 __git_fetch_options="
 	--quiet --verbose --append --upload-pack --force --keep --depth=
 	--tags --no-tags
@@ -1171,11 +1191,7 @@ _git_mergetool ()
 	local cur="${COMP_WORDS[COMP_CWORD]}"
 	case "$cur" in
 	--tool=*)
-		__gitcomp "
-			kdiff3 tkdiff meld xxdiff emerge
-			vimdiff gvimdiff ecmerge diffuse
-			opendiff
-			" "" "${cur##--tool=}"
+		__gitcomp "$__git_mergetools_common" "" "${cur##--tool=}"
 		return
 		;;
 	--*)
@@ -1900,6 +1916,7 @@ _git ()
 	config)      _git_config ;;
 	describe)    _git_describe ;;
 	diff)        _git_diff ;;
+	difftool)    _git_difftool;;
 	fetch)       _git_fetch ;;
 	format-patch) _git_format_patch ;;
 	fsck)        _git_fsck ;;
-- 
1.6.2.1.469.gdffc1
Shawn O. Pearce· Apr 5, 2009, 19:43 UTC · re: David Aguilar · lore

Re: [PATCH] bash completion: add git-difftool

David Aguilar <davvid@gmail.com> wrote:
> This adds completion for difftool's --tool flag.
> The known diff tool names were also consolidated into
> a single variable.
Looks good to me.  I see Junio has it slated in pu currently.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
 
-- 
Shawn.

← back to recent threads