11#
22# bash completion support for core Git.
33#
4- # Copyright (C) 2006,2007 Shawn Pearce
4+ # Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
55# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
6+ # Distributed under the GNU General Public License, version 2.0.
67#
78# The contained completion routines provide support for completing:
89#
1112# *) .git/remotes file names
1213# *) git 'subcommands'
1314# *) tree paths within 'ref:path/to/file' expressions
15+ # *) common --long-options
1416#
1517# To use these routines:
1618#
3133# are currently in a git repository. The %s token will be
3234# the name of the current branch.
3335#
36+ # To submit patches:
37+ #
38+ # *) Read Documentation/SubmittingPatches
39+ # *) Send all patches to the current maintainer:
40+ #
41+ # "Shawn O. Pearce" <spearce@spearce.org>
42+ #
43+ # *) Always CC the Git mailing list:
44+ #
45+ # git@vger.kernel.org
46+ #
3447
3548__gitdir ()
3649{
@@ -262,17 +275,23 @@ __git_commands ()
262275 applypatch) : ask gittus;;
263276 archimport) : import;;
264277 cat-file) : plumbing;;
278+ check-attr) : plumbing;;
265279 check-ref-format) : plumbing;;
266280 commit-tree) : plumbing;;
267281 convert-objects) : plumbing;;
268282 cvsexportcommit) : export ;;
269283 cvsimport) : import;;
270284 cvsserver) : daemon;;
271285 daemon) : daemon;;
286+ diff-files) : plumbing;;
287+ diff-index) : plumbing;;
288+ diff-tree) : plumbing;;
272289 fast-import) : import;;
273290 fsck-objects) : plumbing;;
291+ fetch--tool) : plumbing;;
274292 fetch-pack) : plumbing;;
275293 fmt-merge-msg) : plumbing;;
294+ for-each-ref) : plumbing;;
276295 hash-object) : plumbing;;
277296 http-* ) : transport;;
278297 index-pack) : plumbing;;
@@ -573,13 +592,13 @@ _git_log ()
573592 __gitcomp "
574593 --max-count= --max-age= --since= --after=
575594 --min-age= --before= --until=
576- --root --not -- topo-order --date-order
595+ --root --topo-order --date-order --reverse
577596 --no-merges
578597 --abbrev-commit --abbrev=
579598 --relative-date
580599 --author= --committer= --grep=
581600 --all-match
582- --pretty= --name-status --name-only
601+ --pretty= --name-status --name-only --raw
583602 --not --all
584603 "
585604 return
@@ -745,9 +764,11 @@ _git_config ()
745764 case " $cur " in
746765 --* )
747766 __gitcomp "
748- --global --list --replace-all
767+ --global --system
768+ --list --replace-all
749769 --get --get-all --get-regexp
750770 --add --unset --unset-all
771+ --remove-section --rename-section
751772 "
752773 return
753774 ;;
@@ -766,7 +787,10 @@ _git_config ()
766787 remote.* .* )
767788 local pfx=" ${cur% .* } ."
768789 cur=" ${cur##* .} "
769- __gitcomp " url fetch push" " $pfx " " $cur "
790+ __gitcomp "
791+ url fetch push skipDefaultUpdate
792+ receivepack uploadpack tagopt
793+ " " $pfx " " $cur "
770794 return
771795 ;;
772796 remote.* )
@@ -816,6 +840,9 @@ _git_config ()
816840 format.headers
817841 gitcvs.enabled
818842 gitcvs.logfile
843+ gitcvs.allbinary
844+ gitcvs.dbname gitcvs.dbdriver gitcvs.dbuser gitcvs.dvpass
845+ gc.packrefs
819846 gc.reflogexpire
820847 gc.reflogexpireunreachable
821848 gc.rerereresolved
@@ -832,9 +859,11 @@ _git_config ()
832859 i18n.commitEncoding
833860 i18n.logOutputEncoding
834861 log.showroot
862+ merge.tool
835863 merge.summary
836864 merge.verbosity
837865 pack.window
866+ pack.depth
838867 pull.octopus
839868 pull.twohead
840869 repack.useDeltaBaseOffset
@@ -858,20 +887,32 @@ _git_remote ()
858887 while [ $c -lt $COMP_CWORD ]; do
859888 i=" ${COMP_WORDS[c]} "
860889 case " $i " in
861- add|show|prune) command=" $i " ; break ;;
890+ add|show|prune|update ) command=" $i " ; break ;;
862891 esac
863892 c=$(( ++ c))
864893 done
865894
866895 if [ $c -eq $COMP_CWORD -a -z " $command " ]; then
867- __gitcomp " add show prune"
896+ __gitcomp " add show prune update "
868897 return
869898 fi
870899
871900 case " $command " in
872901 show|prune)
873902 __gitcomp " $( __git_remotes) "
874903 ;;
904+ update)
905+ local i c=' ' IFS=$' \n '
906+ for i in $( git --git-dir=" $( __gitdir) " config --list) ; do
907+ case " $i " in
908+ remotes.* )
909+ i=" ${i# remotes.} "
910+ c=" $c ${i/ =*/ } "
911+ ;;
912+ esac
913+ done
914+ __gitcomp " $c "
915+ ;;
875916 * )
876917 COMPREPLY=()
877918 ;;
@@ -890,6 +931,26 @@ _git_reset ()
890931 __gitcomp " $( __git_refs) "
891932}
892933
934+ _git_shortlog ()
935+ {
936+ local cur=" ${COMP_WORDS[COMP_CWORD]} "
937+ case " $cur " in
938+ --* )
939+ __gitcomp "
940+ --max-count= --max-age= --since= --after=
941+ --min-age= --before= --until=
942+ --no-merges
943+ --author= --committer= --grep=
944+ --all-match
945+ --not --all
946+ --numbered --summary
947+ "
948+ return
949+ ;;
950+ esac
951+ __git_complete_revlist
952+ }
953+
893954_git_show ()
894955{
895956 local cur=" ${COMP_WORDS[COMP_CWORD]} "
@@ -947,7 +1008,6 @@ _git ()
9471008 commit) _git_commit ;;
9481009 config) _git_config ;;
9491010 diff) _git_diff ;;
950- diff-tree) _git_diff_tree ;;
9511011 fetch) _git_fetch ;;
9521012 format-patch) _git_format_patch ;;
9531013 gc) _git_gc ;;
@@ -962,6 +1022,7 @@ _git ()
9621022 rebase) _git_rebase ;;
9631023 remote) _git_remote ;;
9641024 reset) _git_reset ;;
1025+ shortlog) _git_shortlog ;;
9651026 show) _git_show ;;
9661027 show-branch) _git_log ;;
9671028 whatchanged) _git_log ;;
@@ -992,7 +1053,6 @@ complete -o default -o nospace -F _git_cherry git-cherry
9921053complete -o default -o nospace -F _git_cherry_pick git-cherry-pick
9931054complete -o default -o nospace -F _git_commit git-commit
9941055complete -o default -o nospace -F _git_diff git-diff
995- complete -o default -o nospace -F _git_diff_tree git-diff-tree
9961056complete -o default -o nospace -F _git_fetch git-fetch
9971057complete -o default -o nospace -F _git_format_patch git-format-patch
9981058complete -o default -o nospace -F _git_gc git-gc
@@ -1008,6 +1068,7 @@ complete -o default -o nospace -F _git_rebase git-rebase
10081068complete -o default -o nospace -F _git_config git-config
10091069complete -o default -o nospace -F _git_remote git-remote
10101070complete -o default -o nospace -F _git_reset git-reset
1071+ complete -o default -o nospace -F _git_shortlog git-shortlog
10111072complete -o default -o nospace -F _git_show git-show
10121073complete -o default -o nospace -F _git_log git-show-branch
10131074complete -o default -o nospace -F _git_log git-whatchanged
@@ -1023,14 +1084,14 @@ complete -o default -o nospace -F _git git.exe
10231084complete -o default -o nospace -F _git_branch git-branch.exe
10241085complete -o default -o nospace -F _git_cherry git-cherry.exe
10251086complete -o default -o nospace -F _git_diff git-diff.exe
1026- complete -o default -o nospace -F _git_diff_tree git-diff-tree.exe
10271087complete -o default -o nospace -F _git_format_patch git-format-patch.exe
10281088complete -o default -o nospace -F _git_log git-log.exe
10291089complete -o default -o nospace -F _git_ls_tree git-ls-tree.exe
10301090complete -o default -o nospace -F _git_merge_base git-merge-base.exe
10311091complete -o default -o nospace -F _git_name_rev git-name-rev.exe
10321092complete -o default -o nospace -F _git_push git-push.exe
10331093complete -o default -o nospace -F _git_config git-config
1094+ complete -o default -o nospace -F _git_shortlog git-shortlog.exe
10341095complete -o default -o nospace -F _git_show git-show.exe
10351096complete -o default -o nospace -F _git_log git-show-branch.exe
10361097complete -o default -o nospace -F _git_log git-whatchanged.exe
0 commit comments