Teach bash about git log/show/whatchanged options.
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@spearce.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
Shawn O. Pearce committed
Nov 27, 2006 at 03:42 UTC
6e31b866e4c8e6fc432e6087d56be73c08cf0f83
1 file changed
+26
-8
contrib/completion/git-completion.bash
+26
-8
@@ -358,6 +358,29 @@ _git_ls_tree ()
358
359
_git_log ()
360
{
361
+ local cur="${COMP_WORDS[COMP_CWORD]}"
362
+ case "$cur" in
363
+ --pretty=*)
364
+ COMPREPLY=($(compgen -W "
365
+ oneline short medium full fuller email raw
366
+ " -- "${cur##--pretty=}"))
367
+ return
368
+ ;;
369
+ --*)
370
+ COMPREPLY=($(compgen -W "
371
+ --max-count= --max-age= --since= --after=
372
+ --min-age= --before= --until=
373
+ --root --not --topo-order --date-order
374
+ --no-merges
375
+ --abbrev-commit --abbrev=
376
+ --relative-date
377
+ --author= --committer= --grep=
378
+ --all-match
379
+ --pretty= --name-status --name-only
380
+ " -- "$cur"))
381
+ return
382
+ ;;
383
+ esac
384
__git_complete_revlist
385
}
386
@@ -474,12 +497,6 @@ _git_reset ()
497
COMPREPLY=($(compgen -W "$opt $(__git_refs)" -- "$cur"))
498
}
499
477
-_git_show ()
478
-{
479
- local cur="${COMP_WORDS[COMP_CWORD]}"
480
- COMPREPLY=($(compgen -W "$(__git_refs)" -- "$cur"))
481
-}
482
-
500
_git ()
501
{
502
local i c=1 command __git_dir
@@ -526,7 +543,7 @@ _git ()
543
push) _git_push ;;
544
rebase) _git_rebase ;;
545
reset) _git_reset ;;
529
- show) _git_show ;;
546
+ show) _git_log ;;
547
show-branch) _git_log ;;
548
whatchanged) _git_log ;;
549
*) COMPREPLY=() ;;
@@ -559,7 +576,7 @@ complete -o default -o nospace -F _git_pull git-pull
576
complete -o default -o nospace -F _git_push git-push
577
complete -o default -F _git_rebase git-rebase
578
complete -o default -F _git_reset git-reset
562
-complete -o default -F _git_show git-show
579
+complete -o default -F _git_log git-show
580
complete -o default -o nospace -F _git_log git-show-branch
581
complete -o default -o nospace -F _git_log git-whatchanged
582
@@ -579,6 +596,7 @@ complete -o default -o nospace -F _git_ls_tree git-ls-tree.exe
596
complete -o default -F _git_merge_base git-merge-base.exe
597
complete -o default -F _git_name_rev git-name-rev.exe
598
complete -o default -o nospace -F _git_push git-push.exe
599
+complete -o default -o nospace -F _git_log git-show.exe
600
complete -o default -o nospace -F _git_log git-show-branch.exe
601
complete -o default -o nospace -F _git_log git-whatchanged.exe
602
fi