[PATCH 8/10] Teach bash about git log/show/whatchanged options.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Typing out options to git log/show/whatchanged can take a while, but
we can easily complete them with bash.  So list the most common ones,
especially --pretty=online|short|medium|... so that users don't need
to type everything out.

Signed-off-by: Shawn O. Pearce <spearce@xxxxxxxxxxx>
---
 contrib/completion/git-completion.bash |   34 ++++++++++++++++++++++++-------
 1 files changed, 26 insertions(+), 8 deletions(-)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index a61b6b9..8acfb09 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -358,6 +358,29 @@ _git_ls_tree ()
 
 _git_log ()
 {
+	local cur="${COMP_WORDS[COMP_CWORD]}"
+	case "$cur" in
+	--pretty=*)
+		COMPREPLY=($(compgen -W "
+			oneline short medium full fuller email raw
+			" -- "${cur##--pretty=}"))
+		return
+		;;
+	--*)
+		COMPREPLY=($(compgen -W "
+			--max-count= --max-age= --since= --after=
+			--min-age= --before= --until=
+			--root --not --topo-order --date-order
+			--no-merges
+			--abbrev-commit --abbrev=
+			--relative-date
+			--author= --committer= --grep=
+			--all-match
+			--pretty= --name-status --name-only
+			" -- "$cur"))
+		return
+		;;
+	esac
 	__git_complete_revlist
 }
 
@@ -474,12 +497,6 @@ _git_reset ()
 	COMPREPLY=($(compgen -W "$opt $(__git_refs)" -- "$cur"))
 }
 
-_git_show ()
-{
-	local cur="${COMP_WORDS[COMP_CWORD]}"
-	COMPREPLY=($(compgen -W "$(__git_refs)" -- "$cur"))
-}
-
 _git ()
 {
 	local i c=1 command __git_dir
@@ -526,7 +543,7 @@ _git ()
 	push)        _git_push ;;
 	rebase)      _git_rebase ;;
 	reset)       _git_reset ;;
-	show)        _git_show ;;
+	show)        _git_log ;;
 	show-branch) _git_log ;;
 	whatchanged) _git_log ;;
 	*)           COMPREPLY=() ;;
@@ -559,7 +576,7 @@ complete -o default -o nospace -F _git_pull git-pull
 complete -o default -o nospace -F _git_push git-push
 complete -o default            -F _git_rebase git-rebase
 complete -o default            -F _git_reset git-reset
-complete -o default            -F _git_show git-show
+complete -o default            -F _git_log git-show
 complete -o default -o nospace -F _git_log git-show-branch
 complete -o default -o nospace -F _git_log git-whatchanged
 
@@ -579,6 +596,7 @@ complete -o default -o nospace -F _git_ls_tree git-ls-tree.exe
 complete -o default            -F _git_merge_base git-merge-base.exe
 complete -o default            -F _git_name_rev git-name-rev.exe
 complete -o default -o nospace -F _git_push git-push.exe
+complete -o default -o nospace -F _git_log git-show.exe
 complete -o default -o nospace -F _git_log git-show-branch.exe
 complete -o default -o nospace -F _git_log git-whatchanged.exe
 fi
-- 
1.4.4.1.ge3fb

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]