3 # A customized bash environment suitable for git work. 
   5 # Copyright (C) 2008 Ryan Tomayko <http://tomayko.com/> 
   6 # Copyright (C) 2008 Aristotle Pagaltzis <http://plasmasturm.org/> 
   8 # This program is free software; you can redistribute it and/or modify 
   9 # it under the terms of the GNU General Public License as published by 
  10 # the Free Software Foundation; either version 2 of the License, or 
  11 # (at your option) any later version. 
  13 # This program is distributed in the hope that it will be useful, 
  14 # but WITHOUT ANY WARRANTY; without even the implied warranty of 
  15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
  16 # GNU General Public License for more details. 
  18 # You should have received a copy of the GNU General Public License along 
  19 # with this program; if not, write to the Free Software Foundation, Inc., 
  20 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 
  21 # Distributed under the GNU General Public License, version 2.0. 
  23 # use to install the sh alias 
  24 [[ $1 = '--configure' && $# = 1 ]] && { 
  26         git config 
--global alias.sh 
'!git-sh' 
  27         echo "alias 'sh' added to ~/.gitconfig" 
  31 # we expect to be sourced into an interactive shell. when executed as a 
  32 # command, kick off a new shell and source us. 
  34 exec /usr
/bin
/env bash 
--rcfile "$0" "$@" 
  36 # source the user's .bashrc file 
  44 # ALIASES + COMPLETION ========================================================= 
  46 # gitcomp <alias> <command> 
  48 # Complete command named <alias> like standard git command named 
  49 # <command>. <command> must be a valid git command with completion. 
  52 #   gitcomplete ci commit 
  53 #   gitcomplete c  checkout 
  55         local alias="$1" command="$2" 
  56         complete 
-o default 
-o nospace 
-F _git_
${command//-/_} $alias 
  59 # gitalias <alias>='<command> [<args>...]' 
  61 # Define a new shell alias (as with the alias builtin) named <alias> 
  62 # and enable command completion based on <command>. <command> must be 
  63 # a standard non-abbreviated git command name that has completion support. 
  67 #   gitalias ci='commit -v' 
  68 #   gitalias r='rebase --interactive HEAD~10' 
  70         local alias="${1%%=*}" command="${1#*=}" 
  71         local prog
="${command##git }" 
  73         alias $alias="$command" 
  74         gitcomplete 
"$alias" "$prog" 
  77 # create aliases and configure bash completion for most porcelain commands 
  85         'bisect         alias  stdcmpl' 
  87         'branch         alias  stdcmpl' 
  88         'bundle         alias  stdcmpl' 
  90         'checkout       alias  stdcmpl' 
  91         'cherry         alias  stdcmpl' 
  92         'cherry-pick    alias  stdcmpl' 
  95         'commit         alias  stdcmpl' 
  96         'config         alias  stdcmpl' 
  97         'describe       alias  stdcmpl' 
 100         'fetch          alias  stdcmpl' 
 101         'format-patch   alias  stdcmpl' 
 111         'ls-remote      alias  stdcmpl' 
 112         'ls-tree        alias  stdcmpl' 
 113         'merge          alias  stdcmpl' 
 114         'merge-base     alias  stdcmpl' 
 124         'rebase         alias  stdcmpl' 
 126         'remote         alias  stdcmpl' 
 130         'reset          alias  stdcmpl' 
 137         'shortlog       alias  stdcmpl' 
 139         'show-branch    alias  logcmpl' 
 140         'stash          alias  stdcmpl' 
 143         'submodule      alias  stdcmpl' 
 149         'whatchanged    alias  logcmpl' 
 152 for cfg 
in "${_git_cmd_cfg[@]}" ; do 
 153         read cmd opts 
<<< $cfg 
 154         for opt 
in $opts ; do 
 156                         alias)   alias $cmd="git $cmd" ;; 
 157                         stdcmpl
) complete 
-o default 
-o nospace 
-F _git_
${cmd//-/_} $cmd ;; 
 158                         logcmpl
) complete 
-o default 
-o nospace 
-F _git_log         
$cmd ;; 
 163 # Create aliases for everything defined in the gitconfig [alias] section. 
 164 _git_import_aliases 
() { 
 166                 git config --get-regexp 'alias\..*' | 
 168                 while read key command 
 170                         if expr -- "$command" : '!' >/dev/null 
 171                         then echo "alias $key='git $key'" 
 172                         else echo "gitalias 
$key=\"git 
$command\"" 
 178 # PROMPT ======================================================================= 
 180 PS1
='`_git_headname`!`_git_workdir``_git_dirty`> ' 
 182 ANSI_RESET
="\001$(git config --get-color "" "reset")\002" 
 184 # detect whether the tree is in a dirty state. returns 
 186         if git status 
2>/dev
/null 
| fgrep 
-q '(working directory clean)'; then 
 189         local dirty_marker
="`git config gitsh.dirty || echo ' *'`" 
 190         _git_apply_color 
"$dirty_marker" "color.sh.dirty" "red" 
 193 # detect the current branch; use 7-sha when not on branch 
 195         local br
=`git symbolic-ref -q HEAD 2>/dev/null` 
 197                 br
=${br#refs/heads/} || 
 198                 br
=`git rev-parse --short HEAD 2>/dev/null` 
 199         _git_apply_color 
"$br" "color.sh.branch" "yellow reverse" 
 202 # detect working directory relative to working tree root 
 204         subdir
=`git rev-parse --show-prefix 2>/dev/null` 
 206         workdir
="${PWD%/$subdir}" 
 207         _git_apply_color 
"${workdir/*\/}${subdir:+/$subdir}" "color.sh.workdir" "blue bold" 
 210 # determine whether color should be enabled. this checks git's color.ui 
 211 # option and then color.sh. 
 212 _git_color_enabled
() { 
 213         [ `git config --get-colorbool color.sh true` = "true" ] 
 216 # apply a color to the first argument 
 218         local output
="$1" color
="$2" default
="$3" 
 219         if _git_color_enabled 
; then 
 220                 color
=`_git_color "$color" "$default"` 
 221                 echo -ne "${color}${output}${ANSI_RESET}" 
 227 # retrieve an ANSI color escape sequence from git config 
 230         color
=`git config --get-color "$1" "$2" 2>/dev/null` 
 231         [ -n "$color" ] && echo -ne "\001$color\002" 
 234 # HELP ======================================================================== 
 238         # show git's inbuilt help, after some tweaking... 
 239         git 
--help | grep -v "See 'git help" 
 241         # show aliases defined in ~/.gitconfig 
 242         echo "Command aliases:" 
 243         git config 
--get-regexp 'alias\..*' | 
 246         while read name value
 
 247         do printf "   %-10s %-65s\n" "$name" "$value" 
 250         printf "\nSee 'help COMMAND' for more information on a specific command.\n" 
 254         local _git_pager
=$(git config core.pager) 
 257         else (_help_display 
| ${_git_pager:-${PAGER:-less}}) 
 260 complete 
-o default 
-o nospace 
-F _git 
help 
 262 # vim: tw=80 noexpandtab 
 265 # bash completion support for core Git. 
 267 # Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org> 
 268 # Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/). 
 269 # Distributed under the GNU General Public License, version 2.0. 
 271 # The contained completion routines provide support for completing: 
 273 #    *) local and remote branch names 
 274 #    *) local and remote tag names 
 275 #    *) .git/remotes file names 
 276 #    *) git 'subcommands' 
 277 #    *) tree paths within 'ref:path/to/file' expressions 
 278 #    *) common --long-options 
 280 # To use these routines: 
 282 #    1) Copy this file to somewhere (e.g. ~/.git-completion.sh). 
 283 #    2) Added the following line to your .bashrc: 
 284 #        source ~/.git-completion.sh 
 286 #    3) Consider changing your PS1 to also show the current branch: 
 287 #        PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ ' 
 289 #       The argument to __git_ps1 will be displayed only if you 
 290 #       are currently in a git repository.  The %s token will be 
 291 #       the name of the current branch. 
 293 #       In addition, if you set GIT_PS1_SHOWDIRTYSTATE to a nonempty 
 294 #       value, unstaged (*) and staged (+) changes will be shown next 
 295 #       to the branch name.  You can configure this per-repository 
 296 #       with the bash.showDirtyState variable, which defaults to true 
 297 #       once GIT_PS1_SHOWDIRTYSTATE is enabled. 
 299 #       You can also see if currently something is stashed, by setting 
 300 #       GIT_PS1_SHOWSTASHSTATE to a nonempty value. If something is stashed, 
 301 #       then a '$' will be shown next to the branch name. 
 303 #       If you would like to see if there're untracked files, then you can 
 304 #       set GIT_PS1_SHOWUNTRACKEDFILES to a nonempty value. If there're 
 305 #       untracked files, then a '%' will be shown next to the branch name. 
 307 #       If you would like to see the difference between HEAD and its 
 308 #       upstream, set GIT_PS1_SHOWUPSTREAM="auto".  A "<" indicates 
 309 #       you are behind, ">" indicates you are ahead, and "<>" 
 310 #       indicates you have diverged.  You can further control 
 311 #       behaviour by setting GIT_PS1_SHOWUPSTREAM to a space-separated 
 313 #           verbose       show number of commits ahead/behind (+/-) upstream 
 314 #           legacy        don't use the '--count' option available in recent 
 315 #                         versions of git-rev-list 
 316 #           git           always compare HEAD to @{upstream} 
 317 #           svn           always compare HEAD to your SVN upstream 
 318 #       By default, __git_ps1 will compare HEAD to your SVN upstream 
 319 #       if it can find one, or @{upstream} otherwise.  Once you have 
 320 #       set GIT_PS1_SHOWUPSTREAM, you can override it on a 
 321 #       per-repository basis by setting the bash.showUpstream config 
 327 #    *) Read Documentation/SubmittingPatches 
 328 #    *) Send all patches to the current maintainer: 
 330 #       "Shawn O. Pearce" <spearce@spearce.org> 
 332 #    *) Always CC the Git mailing list: 
 334 #       git@vger.kernel.org 
 337 case "$COMP_WORDBREAKS" in 
 339 *)   COMP_WORDBREAKS
="$COMP_WORDBREAKS:" 
 342 # __gitdir accepts 0 or 1 arguments (i.e., location) 
 343 # returns location of .git repo 
 346         if [ -z "${1-}" ]; then 
 347                 if [ -n "${__git_dir-}" ]; then 
 349                 elif [ -d .git 
]; then 
 352                         git 
rev-parse --git-dir 2>/dev
/null
 
 354         elif [ -d "$1/.git" ]; then 
 361 # stores the divergence from upstream in $p 
 362 # used by GIT_PS1_SHOWUPSTREAM 
 363 __git_ps1_show_upstream 
() 
 366         local svn_remote
=() svn_url_pattern count n
 
 367         local upstream
=git legacy
="" verbose
="" 
 369         # get some config options from git-config 
 370         while read key value
; do 
 373                         GIT_PS1_SHOWUPSTREAM
="$value" 
 374                         if [[ -z "${GIT_PS1_SHOWUPSTREAM}" ]]; then 
 380                         svn_remote
[ $((${#svn_remote[@]} + 1)) ]="$value" 
 381                         svn_url_pattern
+="\\|$value" 
 382                         upstream
=svn
+git 
# default upstream is SVN if available, else git 
 385         done < <(git config 
-z --get-regexp '^(svn-remote\..*\.url|bash\.showupstream)$' 2>/dev
/null 
| tr '\0\n' '\n ') 
 387         # parse configuration values 
 388         for option 
in ${GIT_PS1_SHOWUPSTREAM}; do 
 390                 git
|svn
) upstream
="$option" ;; 
 391                 verbose
) verbose
=1 ;; 
 398         git
)    upstream
="@{upstream}" ;; 
 400                 # get the upstream from the "git-svn-id: ..." in a commit message 
 401                 # (git-svn uses essentially the same procedure internally) 
 402                 local svn_upstream
=($
(git log 
--first-parent -1 \
 
 403                                         --grep="^git-svn-id: \(${svn_url_pattern:2}\)" 2>/dev
/null
)) 
 404                 if [[ 0 -ne ${#svn_upstream[@]} ]]; then 
 405                         svn_upstream
=${svn_upstream[ ${#svn_upstream[@]} - 2 ]} 
 406                         svn_upstream
=${svn_upstream%@*} 
 407                         for ((n
=1; "$n" <= "${#svn_remote[@]}"; ++n
)); do 
 408                                 svn_upstream
=${svn_upstream#${svn_remote[$n]}} 
 411                         if [[ -z "$svn_upstream" ]]; then 
 412                                 # default branch name for checkouts with no layout: 
 413                                 upstream
=${GIT_SVN_ID:-git-svn} 
 415                                 upstream
=${svn_upstream#/} 
 417                 elif [[ "svn+git" = "$upstream" ]]; then 
 418                         upstream
="@{upstream}" 
 423         # Find how many commits we are ahead/behind our upstream 
 424         if [[ -z "$legacy" ]]; then 
 425                 count
="$(git rev-list --count --left-right \ 
 426                                 "$upstream"...HEAD 2>/dev/null)" 
 428                 # produce equivalent output to --count for older versions of git 
 430                 if commits
="$(git rev-list --left-right "$upstream"...HEAD 2>/dev/null)" 
 432                         local commit behind
=0 ahead
=0 
 433                         for commit 
in $commits 
 442                         count
="$behind  $ahead" 
 448         # calculate the result 
 449         if [[ -z "$verbose" ]]; then 
 453                 "0      0") # equal to upstream 
 455                 "0      "*) # ahead of upstream 
 457                 *"      0") # behind upstream 
 459                 *)          # diverged from upstream 
 466                 "0      0") # equal to upstream 
 468                 "0      "*) # ahead of upstream 
 469                         p
=" u+${count#0 }" ;; 
 470                 *"      0") # behind upstream 
 471                         p
=" u-${count%  0}" ;; 
 472                 *)          # diverged from upstream 
 473                         p
=" u+${count#* }-${count%      *}" ;; 
 480 # __git_ps1 accepts 0 or 1 arguments (i.e., format string) 
 481 # returns text to add to bash PS1 prompt (includes branch name) 
 484         local g
="$(__gitdir)" 
 488                 if [ -f "$g/rebase-merge/interactive" ]; then 
 490                         b
="$(cat "$g/rebase-merge/head-name")" 
 491                 elif [ -d "$g/rebase-merge" ]; then 
 493                         b
="$(cat "$g/rebase-merge/head-name")" 
 495                         if [ -d "$g/rebase-apply" ]; then 
 496                                 if [ -f "$g/rebase-apply/rebasing" ]; then 
 498                                 elif [ -f "$g/rebase-apply/applying" ]; then 
 503                         elif [ -f "$g/MERGE_HEAD" ]; then 
 505                         elif [ -f "$g/BISECT_LOG" ]; then 
 509                         b
="$(git symbolic-ref HEAD 2>/dev/null)" || { 
 512                                 case "${GIT_PS1_DESCRIBE_STYLE-}" in 
 514                                         git describe --contains HEAD ;; 
 516                                         git describe --contains --all HEAD ;; 
 520                                         git describe --exact-match HEAD ;; 
 521                                 esac 2>/dev/null)" || 
 523                                 b
="$(cut -c1-7 "$g/HEAD" 2>/dev/null)..." || 
 536                 if [ "true" = "$(git rev-parse --is-inside-git-dir 2>/dev/null)" ]; then 
 537                         if [ "true" = "$(git rev-parse --is-bare-repository 2>/dev/null)" ]; then 
 542                 elif [ "true" = "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]; then 
 543                         if [ -n "${GIT_PS1_SHOWDIRTYSTATE-}" ]; then 
 544                                 if [ "$(git config --bool bash.showDirtyState)" != "false" ]; then 
 545                                         git 
diff --no-ext-diff --quiet --exit-code || w
="*" 
 546                                         if git 
rev-parse --quiet --verify HEAD 
>/dev
/null
; then 
 547                                                 git 
diff-index --cached --quiet HEAD 
-- || i
="+" 
 553                         if [ -n "${GIT_PS1_SHOWSTASHSTATE-}" ]; then 
 554                                 git 
rev-parse --verify refs
/stash 
>/dev
/null 
2>&1 && s
="$" 
 557                         if [ -n "${GIT_PS1_SHOWUNTRACKEDFILES-}" ]; then 
 558                            if [ -n "$(git ls-files --others --exclude-standard)" ]; then 
 563                         if [ -n "${GIT_PS1_SHOWUPSTREAM-}" ]; then 
 564                                 __git_ps1_show_upstream
 
 569                 printf "${1:- (%s)}" "$c${b##refs/heads/}${f:+ $f}$r$p" 
 573 # __gitcomp_1 requires 2 arguments 
 576         local c IFS
=' '$
'\t'$
'\n' 
 579                 --*=*) printf %s$
'\n' "$c$2" ;; 
 580                 *.
)    printf %s$
'\n' "$c$2" ;; 
 581                 *)     printf %s$
'\n' "$c$2 " ;; 
 586 # __gitcomp accepts 1, 2, 3, or 4 arguments 
 587 # generates completion reply with compgen 
 590         local cur
="${COMP_WORDS[COMP_CWORD]}" 
 591         if [ $# -gt 2 ]; then 
 600                 COMPREPLY
=($
(compgen 
-P "${2-}" \
 
 601                         -W "$(__gitcomp_1 "${1-}" "${4-}")" \
 
 607 # __git_heads accepts 0 or 1 arguments (to pass to __gitdir) 
 610         local cmd i is_hash
=y dir
="$(__gitdir "${1-}")" 
 611         if [ -d "$dir" ]; then 
 612                 git 
--git-dir="$dir" for-each-ref --format='%(refname:short)' \
 
 616         for i 
in $(git ls-remote "${1-}" 2>/dev/null); do 
 617                 case "$is_hash,$i" in 
 620                 n
,refs
/heads
/*) is_hash
=y
; echo "${i#refs/heads/}" ;; 
 621                 n
,*) is_hash
=y
; echo "$i" ;; 
 626 # __git_tags accepts 0 or 1 arguments (to pass to __gitdir) 
 629         local cmd i is_hash
=y dir
="$(__gitdir "${1-}")" 
 630         if [ -d "$dir" ]; then 
 631                 git 
--git-dir="$dir" for-each-ref --format='%(refname:short)' \
 
 635         for i 
in $(git ls-remote "${1-}" 2>/dev/null); do 
 636                 case "$is_hash,$i" in 
 639                 n
,refs
/tags
/*) is_hash
=y
; echo "${i#refs/tags/}" ;; 
 640                 n
,*) is_hash
=y
; echo "$i" ;; 
 645 # __git_refs accepts 0 or 1 arguments (to pass to __gitdir) 
 648         local i is_hash
=y dir
="$(__gitdir "${1-}")" 
 649         local cur
="${COMP_WORDS[COMP_CWORD]}" format refs
 
 650         if [ -d "$dir" ]; then 
 657                         for i 
in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD
; do 
 658                                 if [ -e "$dir/$i" ]; then echo $i; fi 
 660                         format
="refname:short" 
 661                         refs
="refs/tags refs/heads refs/remotes" 
 664                 git 
--git-dir="$dir" for-each-ref --format="%($format)" \
 
 668         for i 
in $(git ls-remote "$dir" 2>/dev/null); do 
 669                 case "$is_hash,$i" in 
 672                 n
,refs
/tags
/*) is_hash
=y
; echo "${i#refs/tags/}" ;; 
 673                 n
,refs
/heads
/*) is_hash
=y
; echo "${i#refs/heads/}" ;; 
 674                 n
,refs
/remotes
/*) is_hash
=y
; echo "${i#refs/remotes/}" ;; 
 675                 n
,*) is_hash
=y
; echo "$i" ;; 
 680 # __git_refs2 requires 1 argument (to pass to __git_refs) 
 684         for i 
in $(__git_refs "$1"); do 
 689 # __git_refs_remotes requires 1 argument (to pass to ls-remote) 
 690 __git_refs_remotes 
() 
 692         local cmd i is_hash
=y
 
 693         for i 
in $(git ls-remote "$1" 2>/dev/null); do 
 694                 case "$is_hash,$i" in 
 697                         echo "$i:refs/remotes/$1/${i#refs/heads/}" 
 701                 n
,refs
/tags
/*) is_hash
=y
;; 
 709         local i ngoff IFS
=$
'\n' d
="$(__gitdir)" 
 710         shopt -q nullglob 
|| ngoff
=1 
 712         for i 
in "$d/remotes"/*; do 
 713                 echo ${i#$d/remotes/} 
 715         [ "$ngoff" ] && shopt -u nullglob
 
 716         for i 
in $(git --git-dir="$d" config --get-regexp 'remote\..*\.url' 2>/dev/null); do 
 722 __git_list_merge_strategies 
() 
 724         git merge 
-s help 2>&1 | 
 725         sed -n -e '/[Aa]vailable strategies are: /,/^$/{ 
 734 __git_merge_strategies
= 
 735 # 'git merge -s help' (and thus detection of the merge strategy 
 736 # list) fails, unfortunately, if run outside of any git working 
 737 # tree.  __git_merge_strategies is set to the empty string in 
 738 # that case, and the detection will be repeated the next time it 
 740 __git_compute_merge_strategies 
() 
 742         : ${__git_merge_strategies:=$(__git_list_merge_strategies)} 
 745 __git_complete_file 
() 
 747         local pfx 
ls ref cur
="${COMP_WORDS[COMP_CWORD]}" 
 764                 case "$COMP_WORDBREAKS" in 
 766                 *)   pfx
="$ref:$pfx" ;; 
 770                 COMPREPLY
=($
(compgen 
-P "$pfx" \
 
 771                         -W "$(git --git-dir="$(__gitdir)" ls-tree "$ls" \
 
 772                                 | sed '/^100... blob /{ 
 788                 __gitcomp "$(__git_refs)" 
 793 __git_complete_revlist () 
 795         local pfx cur="${COMP_WORDS[COMP_CWORD]}" 
 800                 __gitcomp "$(__git_refs)" "$pfx" "$cur" 
 805                 __gitcomp "$(__git_refs)" "$pfx" "$cur" 
 808                 __gitcomp "$(__git_refs)" 
 813 __git_complete_remote_or_refspec () 
 815         local cmd="${COMP_WORDS[0]}" 
 816         local cur="${COMP_WORDS[COMP_CWORD]}" 
 817         local i c=1 remote="" pfx="" lhs=1 no_complete_refspec=0 
 819         # git-sh hack: adjust args upward when completing git * 
 820         if [ "$cmd" = "git
" ] 
 822                 cmd="${COMP_WORDS[1]}" 
 826         while [ $c -lt $COMP_CWORD ]; do 
 829                 --mirror) [ "$cmd" = "push
" ] && no_complete_refspec=1 ;; 
 832                         push) no_complete_refspec=1 ;; 
 841                 *) remote="$i"; break ;; 
 845         if [ -z "$remote" ]; then 
 846                 __gitcomp "$(__git_remotes)" 
 849         if [ $no_complete_refspec = 1 ]; then 
 853         [ "$remote" = ".
" ] && remote= 
 856                 case "$COMP_WORDBREAKS" in 
 858                 *)   pfx="${cur%%:*}:" ;; 
 870                 if [ $lhs = 1 ]; then 
 871                         __gitcomp "$(__git_refs2 "$remote")" "$pfx" "$cur" 
 873                         __gitcomp "$(__git_refs)" "$pfx" "$cur" 
 877                 if [ $lhs = 1 ]; then 
 878                         __gitcomp "$(__git_refs "$remote")" "$pfx" "$cur" 
 880                         __gitcomp "$(__git_refs)" "$pfx" "$cur" 
 884                 if [ $lhs = 1 ]; then 
 885                         __gitcomp "$(__git_refs)" "$pfx" "$cur" 
 887                         __gitcomp "$(__git_refs "$remote")" "$pfx" "$cur" 
 893 __git_complete_strategy () 
 895         __git_compute_merge_strategies 
 896         case "${COMP_WORDS[COMP_CWORD-1]}" in 
 898                 __gitcomp "$__git_merge_strategies" 
 901         local cur="${COMP_WORDS[COMP_CWORD]}" 
 904                 __gitcomp "$__git_merge_strategies" "" "${cur##--strategy=}" 
 911 __git_list_all_commands () 
 914         for i in $(git help -a|egrep '^  [a-zA-Z0-9]') 
 917                 *--*)             : helper pattern;; 
 924 __git_compute_all_commands () 
 926         : ${__git_all_commands:=$(__git_list_all_commands)} 
 929 __git_list_porcelain_commands () 
 932         __git_compute_all_commands 
 933         for i in "help" $__git_all_commands 
 936                 *--*)             : helper pattern;; 
 937                 applymbox)        : ask gittus;; 
 938                 applypatch)       : ask gittus;; 
 939                 archimport)       : import;; 
 940                 cat-file)         : plumbing;; 
 941                 check-attr)       : plumbing;; 
 942                 check-ref-format) : plumbing;; 
 943                 checkout-index)   : plumbing;; 
 944                 commit-tree)      : plumbing;; 
 945                 count-objects)    : infrequent;; 
 946                 cvsexportcommit)  : export;; 
 947                 cvsimport)        : import;; 
 948                 cvsserver)        : daemon;; 
 950                 diff-files)       : plumbing;; 
 951                 diff-index)       : plumbing;; 
 952                 diff-tree)        : plumbing;; 
 953                 fast-import)      : import;; 
 954                 fast-export)      : export;; 
 955                 fsck-objects)     : plumbing;; 
 956                 fetch-pack)       : plumbing;; 
 957                 fmt-merge-msg)    : plumbing;; 
 958                 for-each-ref)     : plumbing;; 
 959                 hash-object)      : plumbing;; 
 960                 http-*)           : transport;; 
 961                 index-pack)       : plumbing;; 
 962                 init-db)          : deprecated;; 
 963                 local-fetch)      : plumbing;; 
 964                 lost-found)       : infrequent;; 
 965                 ls-files)         : plumbing;; 
 966                 ls-remote)        : plumbing;; 
 967                 ls-tree)          : plumbing;; 
 968                 mailinfo)         : plumbing;; 
 969                 mailsplit)        : plumbing;; 
 970                 merge-*)          : plumbing;; 
 973                 pack-objects)     : plumbing;; 
 974                 pack-redundant)   : plumbing;; 
 975                 pack-refs)        : plumbing;; 
 976                 parse-remote)     : plumbing;; 
 977                 patch-id)         : plumbing;; 
 978                 peek-remote)      : plumbing;; 
 980                 prune-packed)     : plumbing;; 
 981                 quiltimport)      : import;; 
 982                 read-tree)        : plumbing;; 
 983                 receive-pack)     : plumbing;; 
 985                 remote-*)         : transport;; 
 986                 repo-config)      : deprecated;; 
 988                 rev-list)         : plumbing;; 
 989                 rev-parse)        : plumbing;; 
 990                 runstatus)        : plumbing;; 
 991                 sh-setup)         : internal;; 
 993                 show-ref)         : plumbing;; 
 994                 send-pack)        : plumbing;; 
 995                 show-index)       : plumbing;; 
 997                 stripspace)       : plumbing;; 
 998                 symbolic-ref)     : plumbing;; 
 999                 tar-tree)         : deprecated;; 
1000                 unpack-file)      : plumbing;; 
1001                 unpack-objects)   : plumbing;; 
1002                 update-index)     : plumbing;; 
1003                 update-ref)       : plumbing;; 
1004                 update-server-info) : daemon;; 
1005                 upload-archive)   : plumbing;; 
1006                 upload-pack)      : plumbing;; 
1007                 write-tree)       : plumbing;; 
1009                 verify-pack)      : infrequent;; 
1010                 verify-tag)       : plumbing;; 
1016 __git_porcelain_commands= 
1017 __git_compute_porcelain_commands () 
1019         __git_compute_all_commands 
1020         : ${__git_porcelain_commands:=$(__git_list_porcelain_commands)} 
1026         for i in $(git --git-dir="$(__gitdir)" config 
--get-regexp "alias\..*" 2>/dev
/null
); do 
1036 # __git_aliased_command requires 1 argument 
1037 __git_aliased_command 
() 
1039         local word cmdline
=$(git --git-dir="$(__gitdir)" \ 
1040                 config --get "alias.
$1") 
1041         for word in $cmdline; do 
1047                 \!*)    : shell command alias ;; 
1049                 *=*)    : setting env ;; 
1050                 git)    : git itself ;; 
1058 # __git_find_on_cmdline requires 1 argument 
1059 __git_find_on_cmdline () 
1061         local word subcommand c=1 
1063         while [ $c -lt $COMP_CWORD ]; do 
1064                 word="${COMP_WORDS[c]}" 
1065                 for subcommand in $1; do 
1066                         if [ "$subcommand" = "$word" ]; then 
1075 __git_has_doubledash () 
1078         while [ $c -lt $COMP_CWORD ]; do 
1079                 if [ "--" = "${COMP_WORDS[c]}" ]; then 
1087 __git_whitespacelist="nowarn warn error error
-all fix
" 
1091         local cur="${COMP_WORDS[COMP_CWORD]}" dir="$(__gitdir)" 
1092         if [ -d "$dir"/rebase-apply ]; then 
1093                 __gitcomp "--skip --continue --resolved --abort" 
1098                 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}" 
1103                         --3way --committer-date-is-author-date --ignore-date 
1104                         --ignore-whitespace --ignore-space-change 
1105                         --interactive --keep --no-utf8 --signoff --utf8 
1106                         --whitespace= --scissors 
1115         local cur="${COMP_WORDS[COMP_CWORD]}" 
1118                 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}" 
1123                         --stat --numstat --summary --check --index 
1124                         --cached --index-info --reverse --reject --unidiff-zero 
1125                         --apply --no-add --exclude= 
1126                         --ignore-whitespace --ignore-space-change 
1127                         --whitespace= --inaccurate-eof --verbose 
1136         __git_has_doubledash && return 
1138         local cur="${COMP_WORDS[COMP_CWORD]}" 
1142                         --interactive --refresh --patch --update --dry-run 
1143                         --ignore-errors --intent-to-add 
1152         local cur="${COMP_WORDS[COMP_CWORD]}" 
1155                 __gitcomp "$(git archive --list)" "" "${cur##--format=}" 
1159                 __gitcomp "$(__git_remotes)" "" "${cur##--remote=}" 
1164                         --format= --list --verbose 
1165                         --prefix= --remote= --exec= 
1175         __git_has_doubledash && return 
1177         local subcommands="start bad good skip 
reset visualize replay log run
" 
1178         local subcommand="$(__git_find_on_cmdline "$subcommands")" 
1179         if [ -z "$subcommand" ]; then 
1180                 __gitcomp "$subcommands" 
1184         case "$subcommand" in 
1185         bad|good|reset|skip) 
1186                 __gitcomp "$(__git_refs)" 
1196         local i c=1 only_local_ref="n
" has_r="n
" 
1198         while [ $c -lt $COMP_CWORD ]; do 
1199                 i="${COMP_WORDS[c]}" 
1201                 -d|-m)  only_local_ref="y
" ;; 
1207         case "${COMP_WORDS[COMP_CWORD]}" in 
1210                         --color --no-color --verbose --abbrev= --no-abbrev 
1211                         --track --no-track --contains --merged --no-merged 
1216                 if [ $only_local_ref = "y
" -a $has_r = "n
" ]; then 
1217                         __gitcomp "$(__git_heads)" 
1219                         __gitcomp "$(__git_refs)" 
1227         local cmd="${COMP_WORDS[1]}" 
1229         case "${COMP_WORDS[COMP_CWORD-1]}" in 
1231                 __gitcomp "create list
-heads verify unbundle
" 
1234                 __git_complete_revlist 
1236         list-heads|verify|unbundle|*) 
1237                 # looking for a file 
1244         __git_has_doubledash && return 
1246         local cur="${COMP_WORDS[COMP_CWORD]}" 
1249                 __gitcomp "diff3 merge
" "" "${cur##--conflict=}" 
1253                         --quiet --ours --theirs --track --no-track --merge 
1254                         --conflict= --orphan --patch 
1258                 __gitcomp "$(__git_refs)" 
1265         __gitcomp "$(__git_refs)" 
1270         local cur="${COMP_WORDS[COMP_CWORD]}" 
1273                 __gitcomp "--edit --no-commit" 
1276                 __gitcomp "$(__git_refs)" 
1283         __git_has_doubledash && return 
1285         local cur="${COMP_WORDS[COMP_CWORD]}" 
1288                 __gitcomp "--dry-run --quiet" 
1297         local cur="${COMP_WORDS[COMP_CWORD]}" 
1322         __git_has_doubledash && return 
1324         local cur="${COMP_WORDS[COMP_CWORD]}" 
1327                 __gitcomp "default strip verbatim whitespace
 
1328                         " "" "${cur##--cleanup=}" 
1332                 __gitcomp "$(__git_refs)" "" "${cur##--reuse-message=}" 
1336                 __gitcomp "$(__git_refs)" "" "${cur##--reedit-message=}" 
1339         --untracked-files=*) 
1340                 __gitcomp "all no normal
" "" "${cur##--untracked-files=}" 
1345                         --all --author= --signoff --verify --no-verify 
1346                         --edit --amend --include --only --interactive 
1347                         --dry-run --reuse-message= --reedit-message= 
1348                         --reset-author --file= --message= --template= 
1349                         --cleanup= --untracked-files --untracked-files= 
1359         local cur="${COMP_WORDS[COMP_CWORD]}" 
1363                         --all --tags --contains --abbrev= --candidates= 
1364                         --exact-match --debug --long --match --always 
1368         __gitcomp "$(__git_refs)" 
1371 __git_diff_common_options="--stat --numstat --shortstat --summary 
1372                         --patch-with-stat --name-only --name-status --color 
1373                         --no-color --color-words --no-renames --check 
1374                         --full-index --binary --abbrev --diff-filter= 
1375                         --find-copies-harder 
1376                         --text --ignore-space-at-eol --ignore-space-change 
1377                         --ignore-all-space --exit-code --quiet --ext-diff 
1379                         --no-prefix --src-prefix= --dst-prefix= 
1380                         --inter-hunk-context= 
1383                         --dirstat --dirstat= --dirstat-by-file 
1384                         --dirstat-by-file= --cumulative 
1389         __git_has_doubledash && return 
1391         local cur="${COMP_WORDS[COMP_CWORD]}" 
1394                 __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex 
1395                         --base --ours --theirs 
1396                         $__git_diff_common_options 
1404 __git_mergetools_common="diffuse ecmerge emerge kdiff3 meld opendiff
 
1405                         tkdiff vimdiff gvimdiff xxdiff araxis p4merge
 
1410         __git_has_doubledash && return 
1412         local cur="${COMP_WORDS[COMP_CWORD]}" 
1415                 __gitcomp "$__git_mergetools_common kompare
" "" "${cur##--tool=}" 
1419                 __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex 
1420                         --base --ours --theirs 
1421                         --no-renames --diff-filter= --find-copies-harder 
1422                         --relative --ignore-submodules 
1430 __git_fetch_options=" 
1431         --quiet --verbose --append --upload-pack --force --keep --depth= 
1432         --tags --no-tags --all --prune --dry-run 
1437         local cur="${COMP_WORDS[COMP_CWORD]}" 
1440                 __gitcomp "$__git_fetch_options" 
1444         __git_complete_remote_or_refspec 
1447 _git_format_patch () 
1449         local cur="${COMP_WORDS[COMP_CWORD]}" 
1454                         " "" "${cur##--thread=}" 
1459                         --stdout --attach --no-attach --thread --thread= 
1461                         --numbered --start-number 
1464                         --signoff --signature --no-signature 
1465                         --in-reply-to= --cc= 
1466                         --full-index --binary 
1469                         --no-prefix --src-prefix= --dst-prefix= 
1470                         --inline --suffix= --ignore-if-in-upstream 
1476         __git_complete_revlist 
1481         local cur="${COMP_WORDS[COMP_CWORD]}" 
1485                         --tags --root --unreachable --cache --no-reflogs --full 
1486                         --strict --verbose --lost-found 
1496         local cur="${COMP_WORDS[COMP_CWORD]}" 
1499                 __gitcomp "--prune --aggressive" 
1513         __git_has_doubledash && return 
1515         local cur="${COMP_WORDS[COMP_CWORD]}" 
1520                         --text --ignore-case --word-regexp --invert-match 
1522                         --extended-regexp --basic-regexp --fixed-strings 
1523                         --files-with-matches --name-only 
1524                         --files-without-match 
1527                         --and --or --not --all-match 
1533         __gitcomp "$(__git_refs)" 
1538         local cur="${COMP_WORDS[COMP_CWORD]}" 
1541                 __gitcomp "--all --info --man --web" 
1545         __git_compute_all_commands 
1546         __gitcomp "$__git_all_commands 
1547                 attributes cli core
-tutorial cvs
-migration 
1548                 diffcore gitk glossary hooks ignore modules
 
1549                 repository
-layout tutorial tutorial
-2 
1556         local cur="${COMP_WORDS[COMP_CWORD]}" 
1560                         false true 
umask group all world everybody
 
1561                         " "" "${cur##--shared=}" 
1565                 __gitcomp "--quiet --bare --template= --shared --shared=" 
1574         __git_has_doubledash && return 
1576         local cur="${COMP_WORDS[COMP_CWORD]}" 
1579                 __gitcomp "--cached --deleted --modified --others --ignored 
1580                         --stage --directory --no-empty-directory --unmerged 
1581                         --killed --exclude= --exclude-from= 
1582                         --exclude-per-directory= --exclude-standard 
1583                         --error-unmatch --with-tree= --full-name 
1584                         --abbrev --ignored --exclude-per-directory 
1594         __gitcomp "$(__git_remotes)" 
1602 # Options that go well for log, shortlog and gitk 
1603 __git_log_common_options=" 
1605         --branches --tags --remotes 
1606         --first-parent --merges --no-merges 
1608         --max-age= --since= --after= 
1609         --min-age= --until= --before= 
1611 # Options that go well for log and gitk (not shortlog) 
1612 __git_log_gitk_options=" 
1613         --dense --sparse --full-history 
1614         --simplify-merges --simplify-by-decoration 
1617 # Options that go well for log and shortlog (not gitk) 
1618 __git_log_shortlog_options=" 
1619         --author= --committer= --grep= 
1623 __git_log_pretty_formats="oneline short medium full fuller email raw format
:" 
1624 __git_log_date_formats="relative iso8601 rfc2822 short 
local default raw
" 
1628         __git_has_doubledash && return 
1630         local cur="${COMP_WORDS[COMP_CWORD]}" 
1631         local g="$(git rev-parse --git-dir 2>/dev/null)" 
1633         if [ -f "$g/MERGE_HEAD
" ]; then 
1638                 __gitcomp "$__git_log_pretty_formats 
1639                         " "" "${cur##--pretty=}" 
1643                 __gitcomp "$__git_log_pretty_formats 
1644                         " "" "${cur##--format=}" 
1648                 __gitcomp "$__git_log_date_formats" "" "${cur##--date=}" 
1652                 __gitcomp "long short
" "" "${cur##--decorate=}" 
1657                         $__git_log_common_options 
1658                         $__git_log_shortlog_options 
1659                         $__git_log_gitk_options 
1660                         --root --topo-order --date-order --reverse 
1661                         --follow --full-diff 
1662                         --abbrev-commit --abbrev= 
1663                         --relative-date --date= 
1664                         --pretty= --format= --oneline 
1667                         --decorate --decorate= 
1669                         --parents --children 
1671                         $__git_diff_common_options 
1672                         --pickaxe-all --pickaxe-regex 
1677         __git_complete_revlist 
1680 __git_merge_options=" 
1681         --no-commit --no-stat --log --no-log --squash --strategy 
1682         --commit --stat --no-squash --ff --no-ff --ff-only 
1687         __git_complete_strategy && return 
1689         local cur="${COMP_WORDS[COMP_CWORD]}" 
1692                 __gitcomp "$__git_merge_options" 
1695         __gitcomp "$(__git_refs)" 
1700         local cur="${COMP_WORDS[COMP_CWORD]}" 
1703                 __gitcomp "$__git_mergetools_common tortoisemerge
" "" "${cur##--tool=}" 
1716         __gitcomp "$(__git_refs)" 
1721         local cur="${COMP_WORDS[COMP_CWORD]}" 
1724                 __gitcomp "--dry-run" 
1733         __gitcomp "--tags --all --stdin" 
1738         local subcommands="edit show
" 
1739         if [ -z "$(__git_find_on_cmdline "$subcommands")" ]; then 
1740                 __gitcomp "$subcommands" 
1744         case "${COMP_WORDS[COMP_CWORD-1]}" in 
1749                 __gitcomp "$(__git_refs)" 
1756         __git_complete_strategy && return 
1758         local cur="${COMP_WORDS[COMP_CWORD]}" 
1762                         --rebase --no-rebase 
1763                         $__git_merge_options 
1764                         $__git_fetch_options 
1769         __git_complete_remote_or_refspec 
1774         local cur="${COMP_WORDS[COMP_CWORD]}" 
1775         case "${COMP_WORDS[COMP_CWORD-1]}" in 
1777                 __gitcomp "$(__git_remotes)" 
1782                 __gitcomp "$(__git_remotes)" "" "${cur##--repo=}" 
1787                         --all --mirror --tags --dry-run --force --verbose 
1788                         --receive-pack= --repo= 
1793         __git_complete_remote_or_refspec 
1798         local cur="${COMP_WORDS[COMP_CWORD]}" dir="$(__gitdir)" 
1799         if [ -d "$dir"/rebase-apply ] || [ -d "$dir"/rebase-merge ]; then 
1800                 __gitcomp "--continue --skip --abort" 
1803         __git_complete_strategy && return 
1806                 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}" 
1811                         --onto --merge --strategy --interactive 
1812                         --preserve-merges --stat --no-stat 
1813                         --committer-date-is-author-date --ignore-date 
1814                         --ignore-whitespace --whitespace= 
1820         __gitcomp "$(__git_refs)" 
1823 __git_send_email_confirm_options="always never auto cc compose
" 
1824 __git_send_email_suppresscc_options="author self cc bodycc sob cccmd body all
" 
1828         local cur="${COMP_WORDS[COMP_CWORD]}" 
1832                         $__git_send_email_confirm_options 
1833                         " "" "${cur##--confirm=}" 
1838                         $__git_send_email_suppresscc_options 
1839                         " "" "${cur##--suppress-cc=}" 
1843         --smtp-encryption=*) 
1844                 __gitcomp "ssl tls
" "" "${cur##--smtp-encryption=}" 
1848                 __gitcomp "--annotate --bcc --cc --cc-cmd --chain-reply-to 
1849                         --compose --confirm= --dry-run --envelope-sender 
1851                         --in-reply-to --no-chain-reply-to --no-signed-off-by-cc 
1852                         --no-suppress-from --no-thread --quiet 
1853                         --signed-off-by-cc --smtp-pass --smtp-server 
1854                         --smtp-server-port --smtp-encryption= --smtp-user 
1855                         --subject --suppress-cc= --suppress-from --thread --to 
1856                         --validate --no-validate" 
1868 __git_config_get_set_variables () 
1870         local prevword word config_file= c=$COMP_CWORD 
1871         while [ $c -gt 1 ]; do 
1872                 word="${COMP_WORDS[c]}" 
1874                 --global|--system|--file=*) 
1879                         config_file="$word $prevword" 
1887         git --git-dir="$(__gitdir)" config $config_file --list 2>/dev/null | 
1900         local cur="${COMP_WORDS[COMP_CWORD]}" 
1901         local prv="${COMP_WORDS[COMP_CWORD-1]}" 
1904                 __gitcomp "$(__git_remotes)" 
1908                 __gitcomp "$(__git_refs)" 
1912                 local remote="${prv#remote.}" 
1913                 remote="${remote%.fetch}" 
1914                 __gitcomp "$(__git_refs_remotes "$remote")" 
1918                 local remote="${prv#remote.}" 
1919                 remote="${remote%.push}" 
1920                 __gitcomp "$(git --git-dir="$(__gitdir)" \ 
1921                         for-each-ref --format='%(refname):%(refname)' \ 
1925         pull.twohead
|pull.octopus
) 
1926                 __git_compute_merge_strategies
 
1927                 __gitcomp 
"$__git_merge_strategies" 
1930         color.branch
|color.
diff|color.interactive
|\
 
1931         color.showbranch
|color.status
|color.ui
) 
1932                 __gitcomp 
"always never auto" 
1936                 __gitcomp 
"false true" 
1941                         normal black red green yellow blue magenta cyan white 
1942                         bold dim ul blink reverse 
1947                 __gitcomp 
"man info web html" 
1951                 __gitcomp 
"$__git_log_date_formats" 
1954         sendemail.aliasesfiletype
) 
1955                 __gitcomp 
"mutt mailrc pine elm gnus" 
1959                 __gitcomp 
"$__git_send_email_confirm_options" 
1962         sendemail.suppresscc
) 
1963                 __gitcomp 
"$__git_send_email_suppresscc_options" 
1966         --get|--get-all|--unset|--unset-all) 
1967                 __gitcomp 
"$(__git_config_get_set_variables)" 
1978                         --global --system --file= 
1979                         --list --replace-all 
1980                         --get --get-all --get-regexp 
1981                         --add --unset --unset-all 
1982                         --remove-section --rename-section 
1987                 local pfx
="${cur%.*}." 
1989                 __gitcomp 
"remote merge mergeoptions rebase" "$pfx" "$cur" 
1993                 local pfx
="${cur%.*}." 
1995                 __gitcomp 
"$(__git_heads)" "$pfx" "$cur" "." 
1999                 local pfx
="${cur%.*}." 
2002                         argprompt cmd confirm needsfile noconsole norescan 
2003                         prompt revprompt revunmerged title 
2008                 local pfx
="${cur%.*}." 
2010                 __gitcomp 
"cmd path" "$pfx" "$cur" 
2014                 local pfx
="${cur%.*}." 
2016                 __gitcomp 
"cmd path" "$pfx" "$cur" 
2020                 local pfx
="${cur%.*}." 
2022                 __gitcomp 
"cmd path trustExitCode" "$pfx" "$cur" 
2026                 local pfx
="${cur%.*}." 
2028                 __git_compute_all_commands
 
2029                 __gitcomp 
"$__git_all_commands" "$pfx" "$cur" 
2033                 local pfx
="${cur%.*}." 
2036                         url proxy fetch push mirror skipDefaultUpdate 
2037                         receivepack uploadpack tagopt pushurl 
2042                 local pfx
="${cur%.*}." 
2044                 __gitcomp 
"$(__git_remotes)" "$pfx" "$cur" "." 
2048                 local pfx
="${cur%.*}." 
2050                 __gitcomp 
"insteadOf pushInsteadOf" "$pfx" "$cur" 
2057                 apply.ignorewhitespace 
2059                 branch.autosetupmerge 
2060                 branch.autosetuprebase 
2063                 color.branch.current 
2074                 color.diff.whitespace 
2079                 color.interactive.header 
2080                 color.interactive.help 
2081                 color.interactive.prompt 
2086                 color.status.changed 
2088                 color.status.nobranch 
2089                 color.status.untracked 
2090                 color.status.updated 
2097                 core.deltaBaseCacheLimit 
2101                 core.fsyncobjectfiles 
2103                 core.ignoreCygwinFSTricks 
2105                 core.logAllRefUpdates 
2106                 core.loosecompression 
2108                 core.packedGitWindowSize 
2110                 core.preferSymlinkRefs 
2113                 core.repositoryFormatVersion 
2115                 core.sharedRepository 
2118                 core.warnAmbiguousRefs 
2121                 diff.autorefreshindex 
2127                 diff.suppressBlankEmpty 
2140                 format.subjectprefix 
2149                 gc.reflogexpireunreachable 
2153                 gitcvs.commitmsgannotation 
2154                 gitcvs.dbTableNamePrefix 
2165                 gui.copyblamethreshold 
2169                 gui.matchtrackingbranch 
2170                 gui.newbranchtemplate 
2171                 gui.pruneduringfetch 
2172                 gui.spellingdictionary 
2188                 i18n.logOutputEncoding 
2193                 imap.preformattedHTML 
2202                 interactive.singlekey 
2215                 mergetool.keepBackup 
2218                 pack.deltaCacheLimit 
2231                 receive.denyCurrentBranch 
2233                 receive.denyNonFastForwards 
2236                 repack.usedeltabaseoffset 
2239                 sendemail.aliasesfile 
2240                 sendemail.aliasesfiletype 
2244                 sendemail.chainreplyto 
2246                 sendemail.envelopesender 
2248                 sendemail.signedoffbycc 
2249                 sendemail.smtpencryption 
2251                 sendemail.smtpserver 
2252                 sendemail.smtpserverport 
2254                 sendemail.suppresscc 
2255                 sendemail.suppressfrom 
2260                 status.relativePaths 
2261                 status.showUntrackedFiles 
2263                 transfer.unpackLimit 
2275         local subcommands
="add rename rm show prune update set-head" 
2276         local subcommand
="$(__git_find_on_cmdline "$subcommands")" 
2277         if [ -z "$subcommand" ]; then 
2278                 __gitcomp 
"$subcommands" 
2282         case "$subcommand" in 
2283         rename
|rm|show
|prune
) 
2284                 __gitcomp 
"$(__git_remotes)" 
2287                 local i c
='' IFS
=$
'\n' 
2288                 for i 
in $(git --git-dir="$(__gitdir)" config --get-regexp "remotes\..
*" 2>/dev/null); do 
2302         __gitcomp "$(__git_refs)" 
2307         __git_has_doubledash && return 
2309         local cur="${COMP_WORDS[COMP_CWORD]}" 
2312                 __gitcomp "--merge --mixed --hard --soft --patch" 
2316         __gitcomp "$(__git_refs)" 
2321         local cur="${COMP_WORDS[COMP_CWORD]}" 
2324                 __gitcomp "--edit --mainline --no-edit --no-commit --signoff" 
2328         __gitcomp "$(__git_refs)" 
2333         __git_has_doubledash && return 
2335         local cur="${COMP_WORDS[COMP_CWORD]}" 
2338                 __gitcomp "--cached --dry-run --ignore-unmatch --quiet" 
2347         __git_has_doubledash && return 
2349         local cur="${COMP_WORDS[COMP_CWORD]}" 
2353                         $__git_log_common_options 
2354                         $__git_log_shortlog_options 
2355                         --numbered --summary 
2360         __git_complete_revlist 
2365         __git_has_doubledash && return 
2367         local cur="${COMP_WORDS[COMP_CWORD]}" 
2370                 __gitcomp "$__git_log_pretty_formats 
2371                         " "" "${cur##--pretty=}" 
2375                 __gitcomp "$__git_log_pretty_formats 
2376                         " "" "${cur##--format=}" 
2380                 __gitcomp "--pretty= --format= --abbrev-commit --oneline 
2381                         $__git_diff_common_options 
2391         local cur="${COMP_WORDS[COMP_CWORD]}" 
2395                         --all --remotes --topo-order --current --more= 
2396                         --list --independent --merge-base --no-name 
2398                         --sha1-name --sparse --topics --reflog 
2403         __git_complete_revlist 
2408         local cur="${COMP_WORDS[COMP_CWORD]}" 
2409         local save_opts='--keep-index --no-keep-index --quiet --patch' 
2410         local subcommands='save list show apply clear drop pop create branch' 
2411         local subcommand="$(__git_find_on_cmdline "$subcommands")" 
2412         if [ -z "$subcommand" ]; then 
2415                         __gitcomp "$save_opts" 
2418                         if [ -z "$(__git_find_on_cmdline "$save_opts")" ]; then 
2419                                 __gitcomp "$subcommands" 
2426                 case "$subcommand,$cur" in 
2428                         __gitcomp "$save_opts" 
2431                         __gitcomp "--index --quiet" 
2433                 show,--*|drop,--*|branch,--*) 
2436                 show,*|apply,*|drop,*|pop,*|branch,*) 
2437                         __gitcomp "$(git --git-dir="$(__gitdir)" stash list \ 
2438                                         | sed -n -e 's/:.*//p')" 
2449         __git_has_doubledash 
&& return 
2451         local subcommands
="add status init update summary foreach sync" 
2452         if [ -z "$(__git_find_on_cmdline "$subcommands")" ]; then 
2453                 local cur
="${COMP_WORDS[COMP_CWORD]}" 
2456                         __gitcomp 
"--quiet --cached" 
2459                         __gitcomp 
"$subcommands" 
2469                 init fetch clone rebase dcommit log find-rev 
2470                 set-tree commit-diff info create-ignore propget 
2471                 proplist show-ignore show-externals branch tag blame 
2472                 migrate mkdirs reset gc 
2474         local subcommand
="$(__git_find_on_cmdline "$subcommands")" 
2475         if [ -z "$subcommand" ]; then 
2476                 __gitcomp 
"$subcommands" 
2478                 local remote_opts
="--username= --config-dir= --no-auth-cache" 
2480                         --follow-parent --authors-file= --repack= 
2481                         --no-metadata --use-svm-props --use-svnsync-props 
2482                         --log-window-size= --no-checkout --quiet 
2483                         --repack-flags --use-log-author --localtime 
2484                         --ignore-paths= $remote_opts 
2487                         --template= --shared= --trunk= --tags= 
2488                         --branches= --stdlayout --minimize-url 
2489                         --no-metadata --use-svm-props --use-svnsync-props 
2490                         --rewrite-root= --prefix= --use-log-author 
2491                         --add-author-from $remote_opts 
2494                         --edit --rmdir --find-copies-harder --copy-similarity= 
2497                 local cur
="${COMP_WORDS[COMP_CWORD]}" 
2498                 case "$subcommand,$cur" in 
2500                         __gitcomp 
"--revision= --fetch-all $fc_opts" 
2503                         __gitcomp 
"--revision= $fc_opts $init_opts" 
2506                         __gitcomp 
"$init_opts" 
2510                                 --merge --strategy= --verbose --dry-run 
2511                                 --fetch-all --no-rebase --commit-url 
2512                                 --revision $cmt_opts $fc_opts 
2516                         __gitcomp 
"--stdin $cmt_opts $fc_opts" 
2518                 create
-ignore,--*|propget
,--*|proplist
,--*|show
-ignore,--*|\
 
2519                 show
-externals,--*|mkdirs
,--*) 
2520                         __gitcomp 
"--revision=" 
2524                                 --limit= --revision= --verbose --incremental 
2525                                 --oneline --show-commit --non-recursive 
2526                                 --authors-file= --color 
2531                                 --merge --verbose --strategy= --local 
2532                                 --fetch-all --dry-run $fc_opts 
2536                         __gitcomp 
"--message= --file= --revision= $cmt_opts" 
2542                         __gitcomp 
"--dry-run --message --tag" 
2545                         __gitcomp 
"--dry-run --message" 
2548                         __gitcomp 
"--git-format" 
2552                                 --config-dir= --ignore-paths= --minimize 
2553                                 --no-auth-cache --username= 
2557                         __gitcomp 
"--revision= --parent" 
2569         while [ $c -lt $COMP_CWORD ]; do 
2570                 i
="${COMP_WORDS[c]}" 
2573                         __gitcomp 
"$(__git_tags)" 
2583         case "${COMP_WORDS[COMP_CWORD-1]}" in 
2589                         __gitcomp 
"$(__git_tags)" 
2595                 __gitcomp 
"$(__git_refs)" 
2607         local i c
=1 command __git_dir
 
2609         while [ $c -lt $COMP_CWORD ]; do 
2610                 i
="${COMP_WORDS[c]}" 
2612                 --git-dir=*) __git_dir
="${i#--git-dir=}" ;; 
2613                 --bare)      __git_dir
="." ;; 
2614                 --version|-p|--paginate) ;; 
2615                 --help) command="help"; break ;; 
2616                 *) command="$i"; break ;; 
2621         if [ -z "$command" ]; then 
2622                 case "${COMP_WORDS[COMP_CWORD]}" in 
2635                 *)     __git_compute_porcelain_commands
 
2636                        __gitcomp 
"$__git_porcelain_commands $(__git_aliases)" ;; 
2641         local completion_func
="_git_${command//-/_}" 
2642         declare -F $completion_func >/dev
/null 
&& $completion_func && return 
2644         local expansion
=$(__git_aliased_command "$command") 
2645         if [ -n "$expansion" ]; then 
2646                 completion_func
="_git_${expansion//-/_}" 
2647                 declare -F $completion_func >/dev
/null 
&& $completion_func 
2653         __git_has_doubledash 
&& return 
2655         local cur
="${COMP_WORDS[COMP_CWORD]}" 
2656         local g
="$(__gitdir)" 
2658         if [ -f "$g/MERGE_HEAD" ]; then 
2664                         $__git_log_common_options 
2665                         $__git_log_gitk_options 
2671         __git_complete_revlist
 
2674 complete 
-o bashdefault 
-o default 
-o nospace 
-F _git git 
2>/dev
/null \
 
2675         || complete 
-o default 
-o nospace 
-F _git git
 
2676 complete 
-o bashdefault 
-o default 
-o nospace 
-F _gitk gitk 
2>/dev
/null \
 
2677         || complete 
-o default 
-o nospace 
-F _gitk gitk
 
2679 # The following are necessary only for Cygwin, and only are needed 
2680 # when the user has tab-completed the executable name and consequently 
2681 # included the '.exe' suffix. 
2683 if [ Cygwin 
= "$(uname -o 2>/dev/null)" ]; then 
2684 complete 
-o bashdefault 
-o default 
-o nospace 
-F _git git.exe 
2>/dev
/null \
 
2685         || complete 
-o default 
-o nospace 
-F _git git.exe
 
2688 # These are the standard set of aliases enabled by default in all 
2689 # git-sh sessions. Aliases defined in the gitconfig [alias] section override 
2692 gitalias a
='git add' 
2693 gitalias b
='git branch' 
2694 gitalias c
='git checkout' 
2695 gitalias d
='git diff' 
2696 gitalias f
='git fetch --prune' 
2697 gitalias k
='git cherry-pick' 
2698 gitalias l
='git log --pretty=oneline --abbrev-commit' 
2699 gitalias n
='git commit --verbose --amend' 
2700 gitalias r
='git remote' 
2701 gitalias s
='git commit --dry-run --short' 
2702 gitalias t
='git diff --cached' 
2704 # git add and the staging area 
2705 gitalias a
='git add' 
2706 gitalias aa
='git add --update'          # mnemonic: "add all" 
2707 gitalias stage
='git add' 
2708 gitalias ap
='git add --patch' 
2709 gitalias p
='git diff --cached'          # mnemonic: "patch" 
2710 gitalias ps
='git diff --cached --stat'  # mnemonic: "patch stat" 
2711 gitalias unstage
='git reset HEAD' 
2713 # commits and history 
2714 gitalias ci
='git commit --verbose' 
2715 gitalias ca
='git commit --verbose --all' 
2716 gitalias amend
='git commit --verbose --amend' 
2717 gitalias n
='git commit --verbose --amend' 
2718 gitalias k
='git cherry-pick' 
2719 gitalias re
='git rebase --interactive' 
2720 gitalias pop
='git reset --soft HEAD^' 
2721 gitalias peek
='git log -p --max-count=1' 
2724 gitalias f
='git fetch' 
2725 gitalias pm
='git pull'          # mnemonic: pull merge 
2726 gitalias 
pr='git pull --rebase' # mnemonic: pull rebase 
2729 gitalias d
='git diff' 
2730 gitalias ds
='git diff --stat'    # mnemonic: "diff stat" 
2733 gitalias hard
='git reset --hard' 
2734 gitalias soft
='git reset --soft' 
2735 gitalias scrap
='git checkout HEAD' 
2737 # CONFIG ============================================================== 
2739 # load gitconfig [alias] section as top-level aliases. 
2742 # source the system-wide rc file 
2743 [ -r /etc
/gitshrc 
] && . 
/etc
/gitshrc
 
2745 # source the user's rc file 
2746 [ -r ~
/.gitshrc 
] && . ~
/.gitshrc