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         'format-patch   alias  stdcmpl' 
 109         'ls-remote      alias  stdcmpl' 
 110         'ls-tree        alias  stdcmpl' 
 111         'merge          alias  stdcmpl' 
 122         'rebase         alias  stdcmpl' 
 124         'remote         alias  stdcmpl' 
 128         'reset          alias  stdcmpl' 
 137         'show-branch           logcmpl' 
 138         'stash          alias  stdcmpl' 
 141         'submodule      alias  stdcmpl' 
 147         'whatchanged    alias  logcmpl' 
 150 for cfg 
in "${_git_cmd_cfg[@]}" ; do 
 151         read cmd opts 
<<< $cfg 
 152         for opt 
in $opts ; do 
 154                         alias)   alias $cmd="git $cmd" ;; 
 155                         stdcmpl
) complete 
-o default 
-o nospace 
-F _git_
${cmd//-/_} $cmd ;; 
 156                         logcmpl
) complete 
-o default 
-o nospace 
-F _git_log         
$cmd ;; 
 161 # Create aliases for everything defined in the gitconfig [alias] section. 
 162 _git_import_aliases 
() { 
 164                 git config --get-regexp 'alias\..*' | 
 166                 while read key command 
 168                         if expr -- "$command" : '!' >/dev/null 
 169                         then echo "alias $key='${command#!}'" 
 170                         else echo "gitalias 
$key='git $command'" 
 176 # PROMPT ======================================================================= 
 178 PS1
='`_git_headname`!`_git_workdir``_git_dirty`> ' 
 180 ANSI_RESET
="\001$(git config --get-color "" "reset")\002" 
 182 # detect whether the tree is in a dirty state. returns 
 184         if git status 
2>/dev
/null 
| fgrep 
-q '(working directory clean)'; then 
 187         local dirty_marker
="`git config gitsh.dirty || echo ' *'`" 
 188         _git_apply_color 
"$dirty_marker" "color.sh.dirty" "red" 
 191 # detect the current branch; use 7-sha when not on branch 
 193         local br
=`git symbolic-ref -q HEAD 2>/dev/null` 
 195                 br
=${br#refs/heads/} || 
 196                 br
=`git rev-parse --short HEAD 2>/dev/null` 
 197         _git_apply_color 
"$br" "color.sh.branch" "yellow reverse" 
 200 # detect working directory relative to working tree root 
 202         subdir
=`git rev-parse --show-prefix 2>/dev/null` 
 204         workdir
="${PWD%/$subdir}" 
 205         _git_apply_color 
"${workdir/*\/}${subdir:+/$subdir}" "color.sh.workdir" "blue bold" 
 208 # determine whether color should be enabled. this checks git's color.ui 
 209 # option and then color.sh. 
 210 _git_color_enabled
() { 
 211         [ `git config --get-colorbool color.sh true` = "true" ] 
 214 # apply a color to the first argument 
 216         local output
="$1" color
="$2" default
="$3" 
 217         if _git_color_enabled 
; then 
 218                 color
=`_git_color "$color" "$default"` 
 219                 echo -ne "${color}${output}${ANSI_RESET}" 
 225 # retrieve an ANSI color escape sequence from git config 
 228         color
=`git config --get-color "$1" "$2" 2>/dev/null` 
 229         [ -n "$color" ] && echo -ne "\001$color\002" 
 232 # HELP ======================================================================== 
 236         # show git's inbuilt help, after some tweaking... 
 237         git 
--help | grep -v "See 'git help" 
 239         # show aliases defined in ~/.gitconfig 
 240         echo "Command aliases:" 
 241         git config 
--get-regexp 'alias\..*' | 
 244         while read name value
 
 245         do printf "   %-10s %-65s\n" "$name" "$value" 
 248         printf "\nSee 'help COMMAND' for more information on a specific command.\n" 
 252         local _git_pager
=$(git config core.pager) 
 255         else (_help_display 
| ${_git_pager:-${PAGER:-less}}) 
 258 complete 
-o default 
-o nospace 
-F _git 
help 
 260 # vim: tw=80 noexpandtab 
 263 # bash completion support for core Git. 
 265 # Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org> 
 266 # Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/). 
 267 # Distributed under the GNU General Public License, version 2.0. 
 269 # The contained completion routines provide support for completing: 
 271 #    *) local and remote branch names 
 272 #    *) local and remote tag names 
 273 #    *) .git/remotes file names 
 274 #    *) git 'subcommands' 
 275 #    *) tree paths within 'ref:path/to/file' expressions 
 276 #    *) common --long-options 
 278 # To use these routines: 
 280 #    1) Copy this file to somewhere (e.g. ~/.git-completion.sh). 
 281 #    2) Added the following line to your .bashrc: 
 282 #        source ~/.git-completion.sh 
 284 #    3) You may want to make sure the git executable is available 
 285 #       in your PATH before this script is sourced, as some caching 
 286 #       is performed while the script loads.  If git isn't found 
 287 #       at source time then all lookups will be done on demand, 
 288 #       which may be slightly slower. 
 290 #    4) Consider changing your PS1 to also show the current branch: 
 291 #        PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ ' 
 293 #       The argument to __git_ps1 will be displayed only if you 
 294 #       are currently in a git repository.  The %s token will be 
 295 #       the name of the current branch. 
 297 #       In addition, if you set GIT_PS1_SHOWDIRTYSTATE to a nonempty 
 298 #       value, unstaged (*) and staged (+) changes will be shown next 
 299 #       to the branch name.  You can configure this per-repository 
 300 #       with the bash.showDirtyState variable, which defaults to true 
 301 #       once GIT_PS1_SHOWDIRTYSTATE is enabled. 
 303 #       You can also see if currently something is stashed, by setting 
 304 #       GIT_PS1_SHOWSTASHSTATE to a nonempty value. If something is stashed, 
 305 #       then a '$' will be shown next to the branch name. 
 307 #       If you would like to see if there're untracked files, then you can 
 308 #       set GIT_PS1_SHOWUNTRACKEDFILES to a nonempty value. If there're 
 309 #       untracked files, then a '%' will be shown next to the branch name. 
 313 #    *) Read Documentation/SubmittingPatches 
 314 #    *) Send all patches to the current maintainer: 
 316 #       "Shawn O. Pearce" <spearce@spearce.org> 
 318 #    *) Always CC the Git mailing list: 
 320 #       git@vger.kernel.org 
 323 case "$COMP_WORDBREAKS" in 
 325 *)   COMP_WORDBREAKS
="$COMP_WORDBREAKS:" 
 328 # __gitdir accepts 0 or 1 arguments (i.e., location) 
 329 # returns location of .git repo 
 332         if [ -z "${1-}" ]; then 
 333                 if [ -n "${__git_dir-}" ]; then 
 335                 elif [ -d .git 
]; then 
 338                         git 
rev-parse --git-dir 2>/dev
/null
 
 340         elif [ -d "$1/.git" ]; then 
 347 # __git_ps1 accepts 0 or 1 arguments (i.e., format string) 
 348 # returns text to add to bash PS1 prompt (includes branch name) 
 351         local g
="$(__gitdir)" 
 355                 if [ -f "$g/rebase-merge/interactive" ]; then 
 357                         b
="$(cat "$g/rebase-merge/head-name")" 
 358                 elif [ -d "$g/rebase-merge" ]; then 
 360                         b
="$(cat "$g/rebase-merge/head-name")" 
 362                         if [ -d "$g/rebase-apply" ]; then 
 363                                 if [ -f "$g/rebase-apply/rebasing" ]; then 
 365                                 elif [ -f "$g/rebase-apply/applying" ]; then 
 370                         elif [ -f "$g/MERGE_HEAD" ]; then 
 372                         elif [ -f "$g/BISECT_LOG" ]; then 
 376                         b
="$(git symbolic-ref HEAD 2>/dev/null)" || { 
 379                                 case "${GIT_PS1_DESCRIBE_STYLE-}" in 
 381                                         git describe --contains HEAD ;; 
 383                                         git describe --contains --all HEAD ;; 
 387                                         git describe --exact-match HEAD ;; 
 388                                 esac 2>/dev/null)" || 
 390                                 b
="$(cut -c1-7 "$g/HEAD" 2>/dev/null)..." || 
 402                 if [ "true" = "$(git rev-parse --is-inside-git-dir 2>/dev/null)" ]; then 
 403                         if [ "true" = "$(git rev-parse --is-bare-repository 2>/dev/null)" ]; then 
 408                 elif [ "true" = "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]; then 
 409                         if [ -n "${GIT_PS1_SHOWDIRTYSTATE-}" ]; then 
 410                                 if [ "$(git config --bool bash.showDirtyState)" != "false" ]; then 
 411                                         git 
diff --no-ext-diff --ignore-submodules \
 
 412                                                 --quiet --exit-code || w
="*" 
 413                                         if git 
rev-parse --quiet --verify HEAD 
>/dev
/null
; then 
 414                                                 git 
diff-index --cached --quiet \
 
 415                                                         --ignore-submodules HEAD 
-- || i
="+" 
 421                         if [ -n "${GIT_PS1_SHOWSTASHSTATE-}" ]; then 
 422                                 git 
rev-parse --verify refs
/stash 
>/dev
/null 
2>&1 && s
="$" 
 425                         if [ -n "${GIT_PS1_SHOWUNTRACKEDFILES-}" ]; then 
 426                            if [ -n "$(git ls-files --others --exclude-standard)" ]; then 
 432                 if [ -n "${1-}" ]; then 
 433                         printf "$1" "$c${b##refs/heads/}$w$i$s$u$r" 
 435                         printf " (%s)" "$c${b##refs/heads/}$w$i$s$u$r" 
 440 # __gitcomp_1 requires 2 arguments 
 443         local c IFS
=' '$
'\t'$
'\n' 
 446                 --*=*) printf %s$
'\n' "$c$2" ;; 
 447                 *.
)    printf %s$
'\n' "$c$2" ;; 
 448                 *)     printf %s$
'\n' "$c$2 " ;; 
 453 # __gitcomp accepts 1, 2, 3, or 4 arguments 
 454 # generates completion reply with compgen 
 457         local cur
="${COMP_WORDS[COMP_CWORD]}" 
 458         if [ $# -gt 2 ]; then 
 467                 COMPREPLY
=($
(compgen 
-P "${2-}" \
 
 468                         -W "$(__gitcomp_1 "${1-}" "${4-}")" \
 
 474 # __git_heads accepts 0 or 1 arguments (to pass to __gitdir) 
 477         local cmd i is_hash
=y dir
="$(__gitdir "${1-}")" 
 478         if [ -d "$dir" ]; then 
 479                 git 
--git-dir="$dir" for-each-ref --format='%(refname:short)' \
 
 483         for i 
in $(git ls-remote "${1-}" 2>/dev/null); do 
 484                 case "$is_hash,$i" in 
 487                 n
,refs
/heads
/*) is_hash
=y
; echo "${i#refs/heads/}" ;; 
 488                 n
,*) is_hash
=y
; echo "$i" ;; 
 493 # __git_tags accepts 0 or 1 arguments (to pass to __gitdir) 
 496         local cmd i is_hash
=y dir
="$(__gitdir "${1-}")" 
 497         if [ -d "$dir" ]; then 
 498                 git 
--git-dir="$dir" for-each-ref --format='%(refname:short)' \
 
 502         for i 
in $(git ls-remote "${1-}" 2>/dev/null); do 
 503                 case "$is_hash,$i" in 
 506                 n
,refs
/tags
/*) is_hash
=y
; echo "${i#refs/tags/}" ;; 
 507                 n
,*) is_hash
=y
; echo "$i" ;; 
 512 # __git_refs accepts 0 or 1 arguments (to pass to __gitdir) 
 515         local i is_hash
=y dir
="$(__gitdir "${1-}")" 
 516         local cur
="${COMP_WORDS[COMP_CWORD]}" format refs
 
 517         if [ -d "$dir" ]; then 
 524                         if [ -e "$dir/HEAD" ]; then echo HEAD
; fi 
 525                         format
="refname:short" 
 526                         refs
="refs/tags refs/heads refs/remotes" 
 529                 git 
--git-dir="$dir" for-each-ref --format="%($format)" \
 
 533         for i 
in $(git ls-remote "$dir" 2>/dev/null); do 
 534                 case "$is_hash,$i" in 
 537                 n
,refs
/tags
/*) is_hash
=y
; echo "${i#refs/tags/}" ;; 
 538                 n
,refs
/heads
/*) is_hash
=y
; echo "${i#refs/heads/}" ;; 
 539                 n
,refs
/remotes
/*) is_hash
=y
; echo "${i#refs/remotes/}" ;; 
 540                 n
,*) is_hash
=y
; echo "$i" ;; 
 545 # __git_refs2 requires 1 argument (to pass to __git_refs) 
 549         for i 
in $(__git_refs "$1"); do 
 554 # __git_refs_remotes requires 1 argument (to pass to ls-remote) 
 555 __git_refs_remotes 
() 
 557         local cmd i is_hash
=y
 
 558         for i 
in $(git ls-remote "$1" 2>/dev/null); do 
 559                 case "$is_hash,$i" in 
 562                         echo "$i:refs/remotes/$1/${i#refs/heads/}" 
 566                 n
,refs
/tags
/*) is_hash
=y
;; 
 574         local i ngoff IFS
=$
'\n' d
="$(__gitdir)" 
 575         shopt -q nullglob 
|| ngoff
=1 
 577         for i 
in "$d/remotes"/*; do 
 578                 echo ${i#$d/remotes/} 
 580         [ "$ngoff" ] && shopt -u nullglob
 
 581         for i 
in $(git --git-dir="$d" config --get-regexp 'remote\..*\.url' 2>/dev/null); do 
 587 __git_merge_strategies 
() 
 589         if [ -n "${__git_merge_strategylist-}" ]; then 
 590                 echo "$__git_merge_strategylist" 
 593         git merge 
-s help 2>&1 | 
 594         sed -n -e '/[Aa]vailable strategies are: /,/^$/{ 
 602 __git_merge_strategylist
= 
 603 __git_merge_strategylist
=$(__git_merge_strategies 2>/dev/null) 
 605 __git_complete_file 
() 
 607         local pfx 
ls ref cur
="${COMP_WORDS[COMP_CWORD]}" 
 624                 case "$COMP_WORDBREAKS" in 
 626                 *)   pfx
="$ref:$pfx" ;; 
 630                 COMPREPLY
=($
(compgen 
-P "$pfx" \
 
 631                         -W "$(git --git-dir="$(__gitdir)" ls-tree "$ls" \
 
 632                                 | sed '/^100... blob /{ 
 648                 __gitcomp "$(__git_refs)" 
 653 __git_complete_revlist () 
 655         local pfx cur="${COMP_WORDS[COMP_CWORD]}" 
 660                 __gitcomp "$(__git_refs)" "$pfx" "$cur" 
 665                 __gitcomp "$(__git_refs)" "$pfx" "$cur" 
 668                 __gitcomp "$(__git_refs)" 
 673 __git_complete_remote_or_refspec () 
 675         local cmd="${COMP_WORDS[0]}" 
 676         local cur="${COMP_WORDS[COMP_CWORD]}" 
 677         local i c=1 remote="" pfx="" lhs=1 no_complete_refspec=0 
 679         # adjust args upward when completing git * 
 680         [ "$cmd" = "git
" ] && { 
 681                 cmd="${COMP_WORDS[1]}" 
 685         while [ $c -lt $COMP_CWORD ]; do 
 688                 --all|--mirror) [ "$cmd" = "push
" ] && no_complete_refspec=1 ;; 
 690                 *) remote="$i"; break ;; 
 694         if [ -z "$remote" ]; then 
 695                 __gitcomp "$(__git_remotes)" 
 698         if [ $no_complete_refspec = 1 ]; then 
 702         [ "$remote" = ".
" ] && remote= 
 705                 case "$COMP_WORDBREAKS" in 
 707                 *)   pfx="${cur%%:*}:" ;; 
 719                 if [ $lhs = 1 ]; then 
 720                         __gitcomp "$(__git_refs2 "$remote")" "$pfx" "$cur" 
 722                         __gitcomp "$(__git_refs)" "$pfx" "$cur" 
 726                 if [ $lhs = 1 ]; then 
 727                         __gitcomp "$(__git_refs "$remote")" "$pfx" "$cur" 
 729                         __gitcomp "$(__git_refs)" "$pfx" "$cur" 
 733                 if [ $lhs = 1 ]; then 
 734                         __gitcomp "$(__git_refs)" "$pfx" "$cur" 
 736                         __gitcomp "$(__git_refs "$remote")" "$pfx" "$cur" 
 742 __git_complete_strategy () 
 744         case "${COMP_WORDS[COMP_CWORD-1]}" in 
 746                 __gitcomp "$(__git_merge_strategies)" 
 749         local cur="${COMP_WORDS[COMP_CWORD]}" 
 752                 __gitcomp "$(__git_merge_strategies)" "" "${cur##--strategy=}" 
 759 __git_all_commands () 
 761         if [ -n "${__git_all_commandlist-}" ]; then 
 762                 echo "$__git_all_commandlist" 
 766         for i in $(git help -a|egrep '^  [a-zA-Z0-9]') 
 769                 *--*)             : helper pattern;; 
 774 __git_all_commandlist= 
 775 __git_all_commandlist="$(__git_all_commands 2>/dev/null)" 
 777 __git_porcelain_commands () 
 779         if [ -n "${__git_porcelain_commandlist-}" ]; then 
 780                 echo "$__git_porcelain_commandlist" 
 784         for i in "help" $(__git_all_commands) 
 787                 *--*)             : helper pattern;; 
 788                 applymbox)        : ask gittus;; 
 789                 applypatch)       : ask gittus;; 
 790                 archimport)       : import;; 
 791                 cat-file)         : plumbing;; 
 792                 check-attr)       : plumbing;; 
 793                 check-ref-format) : plumbing;; 
 794                 checkout-index)   : plumbing;; 
 795                 commit-tree)      : plumbing;; 
 796                 count-objects)    : infrequent;; 
 797                 cvsexportcommit)  : export;; 
 798                 cvsimport)        : import;; 
 799                 cvsserver)        : daemon;; 
 801                 diff-files)       : plumbing;; 
 802                 diff-index)       : plumbing;; 
 803                 diff-tree)        : plumbing;; 
 804                 fast-import)      : import;; 
 805                 fast-export)      : export;; 
 806                 fsck-objects)     : plumbing;; 
 807                 fetch-pack)       : plumbing;; 
 808                 fmt-merge-msg)    : plumbing;; 
 809                 for-each-ref)     : plumbing;; 
 810                 hash-object)      : plumbing;; 
 811                 http-*)           : transport;; 
 812                 index-pack)       : plumbing;; 
 813                 init-db)          : deprecated;; 
 814                 local-fetch)      : plumbing;; 
 815                 lost-found)       : infrequent;; 
 816                 ls-files)         : plumbing;; 
 817                 ls-remote)        : plumbing;; 
 818                 ls-tree)          : plumbing;; 
 819                 mailinfo)         : plumbing;; 
 820                 mailsplit)        : plumbing;; 
 821                 merge-*)          : plumbing;; 
 824                 pack-objects)     : plumbing;; 
 825                 pack-redundant)   : plumbing;; 
 826                 pack-refs)        : plumbing;; 
 827                 parse-remote)     : plumbing;; 
 828                 patch-id)         : plumbing;; 
 829                 peek-remote)      : plumbing;; 
 831                 prune-packed)     : plumbing;; 
 832                 quiltimport)      : import;; 
 833                 read-tree)        : plumbing;; 
 834                 receive-pack)     : plumbing;; 
 836                 repo-config)      : deprecated;; 
 838                 rev-list)         : plumbing;; 
 839                 rev-parse)        : plumbing;; 
 840                 runstatus)        : plumbing;; 
 841                 sh-setup)         : internal;; 
 843                 show-ref)         : plumbing;; 
 844                 send-pack)        : plumbing;; 
 845                 show-index)       : plumbing;; 
 847                 stripspace)       : plumbing;; 
 848                 symbolic-ref)     : plumbing;; 
 849                 tar-tree)         : deprecated;; 
 850                 unpack-file)      : plumbing;; 
 851                 unpack-objects)   : plumbing;; 
 852                 update-index)     : plumbing;; 
 853                 update-ref)       : plumbing;; 
 854                 update-server-info) : daemon;; 
 855                 upload-archive)   : plumbing;; 
 856                 upload-pack)      : plumbing;; 
 857                 write-tree)       : plumbing;; 
 859                 verify-pack)      : infrequent;; 
 860                 verify-tag)       : plumbing;; 
 865 __git_porcelain_commandlist= 
 866 __git_porcelain_commandlist="$(__git_porcelain_commands 2>/dev/null)" 
 871         for i in $(git --git-dir="$(__gitdir)" config 
--get-regexp "alias\..*" 2>/dev
/null
); do 
 881 # __git_aliased_command requires 1 argument 
 882 __git_aliased_command 
() 
 884         local word cmdline
=$(git --git-dir="$(__gitdir)" \ 
 885                 config --get "alias.
$1") 
 886         for word in $cmdline; do 
 887                 if [ "${word##-*}" ]; then 
 894 # __git_find_on_cmdline requires 1 argument 
 895 __git_find_on_cmdline () 
 897         local word subcommand c=1 
 899         while [ $c -lt $COMP_CWORD ]; do 
 900                 word="${COMP_WORDS[c]}" 
 901                 for subcommand in $1; do 
 902                         if [ "$subcommand" = "$word" ]; then 
 911 __git_has_doubledash () 
 914         while [ $c -lt $COMP_CWORD ]; do 
 915                 if [ "--" = "${COMP_WORDS[c]}" ]; then 
 923 __git_whitespacelist="nowarn warn error error
-all fix
" 
 927         local cur="${COMP_WORDS[COMP_CWORD]}" dir="$(__gitdir)" 
 928         if [ -d "$dir"/rebase-apply ]; then 
 929                 __gitcomp "--skip --resolved --abort" 
 934                 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}" 
 939                         --3way --committer-date-is-author-date --ignore-date 
 940                         --ignore-whitespace --ignore-space-change 
 941                         --interactive --keep --no-utf8 --signoff --utf8 
 942                         --whitespace= --scissors 
 951         local cur="${COMP_WORDS[COMP_CWORD]}" 
 954                 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}" 
 959                         --stat --numstat --summary --check --index 
 960                         --cached --index-info --reverse --reject --unidiff-zero 
 961                         --apply --no-add --exclude= 
 962                         --ignore-whitespace --ignore-space-change 
 963                         --whitespace= --inaccurate-eof --verbose 
 972         __git_has_doubledash && return 
 974         local cur="${COMP_WORDS[COMP_CWORD]}" 
 978                         --interactive --refresh --patch --update --dry-run 
 979                         --ignore-errors --intent-to-add 
 988         local cur="${COMP_WORDS[COMP_CWORD]}" 
 991                 __gitcomp "$(git archive --list)" "" "${cur##--format=}" 
 995                 __gitcomp "$(__git_remotes)" "" "${cur##--remote=}" 
1000                         --format= --list --verbose 
1001                         --prefix= --remote= --exec= 
1011         __git_has_doubledash && return 
1013         local subcommands="start bad good skip 
reset visualize replay log run
" 
1014         local subcommand="$(__git_find_on_cmdline "$subcommands")" 
1015         if [ -z "$subcommand" ]; then 
1016                 __gitcomp "$subcommands" 
1020         case "$subcommand" in 
1021         bad|good|reset|skip) 
1022                 __gitcomp "$(__git_refs)" 
1032         local i c=1 only_local_ref="n
" has_r="n
" 
1034         while [ $c -lt $COMP_CWORD ]; do 
1035                 i="${COMP_WORDS[c]}" 
1037                 -d|-m)  only_local_ref="y
" ;; 
1043         case "${COMP_WORDS[COMP_CWORD]}" in 
1046                         --color --no-color --verbose --abbrev= --no-abbrev 
1047                         --track --no-track --contains --merged --no-merged 
1051                 if [ $only_local_ref = "y
" -a $has_r = "n
" ]; then 
1052                         __gitcomp "$(__git_heads)" 
1054                         __gitcomp "$(__git_refs)" 
1062         local cmd="${COMP_WORDS[1]}" 
1063         case "$COMP_CWORD" in 
1065                 __gitcomp "create list
-heads verify unbundle
" 
1068                 # looking for a file 
1073                                 __git_complete_revlist 
1082         __git_has_doubledash && return 
1084         local cur="${COMP_WORDS[COMP_CWORD]}" 
1087                 __gitcomp "diff3 merge
" "" "${cur##--conflict=}" 
1091                         --quiet --ours --theirs --track --no-track --merge 
1096                 __gitcomp "$(__git_refs)" 
1103         __gitcomp "$(__git_refs)" 
1108         local cur="${COMP_WORDS[COMP_CWORD]}" 
1111                 __gitcomp "--edit --no-commit" 
1114                 __gitcomp "$(__git_refs)" 
1121         __git_has_doubledash && return 
1123         local cur="${COMP_WORDS[COMP_CWORD]}" 
1126                 __gitcomp "--dry-run --quiet" 
1135         local cur="${COMP_WORDS[COMP_CWORD]}" 
1160         __git_has_doubledash && return 
1162         local cur="${COMP_WORDS[COMP_CWORD]}" 
1166                         --all --author= --signoff --verify --no-verify 
1167                         --edit --amend --include --only --interactive 
1177         local cur="${COMP_WORDS[COMP_CWORD]}" 
1181                         --all --tags --contains --abbrev= --candidates= 
1182                         --exact-match --debug --long --match --always 
1186         __gitcomp "$(__git_refs)" 
1189 __git_diff_common_options="--stat --numstat --shortstat --summary 
1190                         --patch-with-stat --name-only --name-status --color 
1191                         --no-color --color-words --no-renames --check 
1192                         --full-index --binary --abbrev --diff-filter= 
1193                         --find-copies-harder 
1194                         --text --ignore-space-at-eol --ignore-space-change 
1195                         --ignore-all-space --exit-code --quiet --ext-diff 
1197                         --no-prefix --src-prefix= --dst-prefix= 
1198                         --inter-hunk-context= 
1201                         --dirstat --dirstat= --dirstat-by-file 
1202                         --dirstat-by-file= --cumulative 
1207         __git_has_doubledash && return 
1209         local cur="${COMP_WORDS[COMP_CWORD]}" 
1212                 __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex 
1213                         --base --ours --theirs 
1214                         $__git_diff_common_options 
1222 __git_mergetools_common="diffuse ecmerge emerge kdiff3 meld opendiff
 
1223                         tkdiff vimdiff gvimdiff xxdiff araxis
 
1228         local cur="${COMP_WORDS[COMP_CWORD]}" 
1231                 __gitcomp "$__git_mergetools_common kompare
" "" "${cur##--tool=}" 
1242 __git_fetch_options=" 
1243         --quiet --verbose --append --upload-pack --force --keep --depth= 
1249         local cur="${COMP_WORDS[COMP_CWORD]}" 
1252                 __gitcomp "$__git_fetch_options" 
1256         __git_complete_remote_or_refspec 
1259 _git_format_patch () 
1261         local cur="${COMP_WORDS[COMP_CWORD]}" 
1266                         " "" "${cur##--thread=}" 
1271                         --stdout --attach --no-attach --thread --thread= 
1273                         --numbered --start-number 
1277                         --in-reply-to= --cc= 
1278                         --full-index --binary 
1281                         --no-prefix --src-prefix= --dst-prefix= 
1282                         --inline --suffix= --ignore-if-in-upstream 
1288         __git_complete_revlist 
1293         local cur="${COMP_WORDS[COMP_CWORD]}" 
1297                         --tags --root --unreachable --cache --no-reflogs --full 
1298                         --strict --verbose --lost-found 
1308         local cur="${COMP_WORDS[COMP_CWORD]}" 
1311                 __gitcomp "--prune --aggressive" 
1320         __git_has_doubledash && return 
1322         local cur="${COMP_WORDS[COMP_CWORD]}" 
1327                         --text --ignore-case --word-regexp --invert-match 
1329                         --extended-regexp --basic-regexp --fixed-strings 
1330                         --files-with-matches --name-only 
1331                         --files-without-match 
1334                         --and --or --not --all-match 
1344         local cur="${COMP_WORDS[COMP_CWORD]}" 
1347                 __gitcomp "--all --info --man --web" 
1351         __gitcomp "$(__git_all_commands) 
1352                 attributes cli core
-tutorial cvs
-migration 
1353                 diffcore gitk glossary hooks ignore modules
 
1354                 repository
-layout tutorial tutorial
-2 
1361         local cur="${COMP_WORDS[COMP_CWORD]}" 
1365                         false true 
umask group all world everybody
 
1366                         " "" "${cur##--shared=}" 
1370                 __gitcomp "--quiet --bare --template= --shared --shared=" 
1379         __git_has_doubledash && return 
1381         local cur="${COMP_WORDS[COMP_CWORD]}" 
1384                 __gitcomp "--cached --deleted --modified --others --ignored 
1385                         --stage --directory --no-empty-directory --unmerged 
1386                         --killed --exclude= --exclude-from= 
1387                         --exclude-per-directory= --exclude-standard 
1388                         --error-unmatch --with-tree= --full-name 
1389                         --abbrev --ignored --exclude-per-directory 
1399         __gitcomp "$(__git_remotes)" 
1407 # Options that go well for log, shortlog and gitk 
1408 __git_log_common_options=" 
1410         --branches --tags --remotes 
1411         --first-parent --merges --no-merges 
1413         --max-age= --since= --after= 
1414         --min-age= --until= --before= 
1416 # Options that go well for log and gitk (not shortlog) 
1417 __git_log_gitk_options=" 
1418         --dense --sparse --full-history 
1419         --simplify-merges --simplify-by-decoration 
1422 # Options that go well for log and shortlog (not gitk) 
1423 __git_log_shortlog_options=" 
1424         --author= --committer= --grep= 
1428 __git_log_pretty_formats="oneline short medium full fuller email raw format
:" 
1429 __git_log_date_formats="relative iso8601 rfc2822 short 
local default raw
" 
1433         __git_has_doubledash && return 
1435         local cur="${COMP_WORDS[COMP_CWORD]}" 
1436         local g="$(git rev-parse --git-dir 2>/dev/null)" 
1438         if [ -f "$g/MERGE_HEAD
" ]; then 
1443                 __gitcomp "$__git_log_pretty_formats 
1444                         " "" "${cur##--pretty=}" 
1448                 __gitcomp "$__git_log_pretty_formats 
1449                         " "" "${cur##--format=}" 
1453                 __gitcomp "$__git_log_date_formats" "" "${cur##--date=}" 
1457                 __gitcomp "long short
" "" "${cur##--decorate=}" 
1462                         $__git_log_common_options 
1463                         $__git_log_shortlog_options 
1464                         $__git_log_gitk_options 
1465                         --root --topo-order --date-order --reverse 
1466                         --follow --full-diff 
1467                         --abbrev-commit --abbrev= 
1468                         --relative-date --date= 
1469                         --pretty= --format= --oneline 
1472                         --decorate --decorate= 
1474                         --parents --children 
1476                         $__git_diff_common_options 
1477                         --pickaxe-all --pickaxe-regex 
1482         __git_complete_revlist 
1485 __git_merge_options=" 
1486         --no-commit --no-stat --log --no-log --squash --strategy 
1487         --commit --stat --no-squash --ff --no-ff 
1492         __git_complete_strategy && return 
1494         local cur="${COMP_WORDS[COMP_CWORD]}" 
1497                 __gitcomp "$__git_merge_options" 
1500         __gitcomp "$(__git_refs)" 
1505         local cur="${COMP_WORDS[COMP_CWORD]}" 
1508                 __gitcomp "$__git_mergetools_common tortoisemerge
" "" "${cur##--tool=}" 
1521         __gitcomp "$(__git_refs)" 
1526         local cur="${COMP_WORDS[COMP_CWORD]}" 
1529                 __gitcomp "--dry-run" 
1538         __gitcomp "--tags --all --stdin" 
1543         __git_complete_strategy && return 
1545         local cur="${COMP_WORDS[COMP_CWORD]}" 
1549                         --rebase --no-rebase 
1550                         $__git_merge_options 
1551                         $__git_fetch_options 
1556         __git_complete_remote_or_refspec 
1561         local cur="${COMP_WORDS[COMP_CWORD]}" 
1562         case "${COMP_WORDS[COMP_CWORD-1]}" in 
1564                 __gitcomp "$(__git_remotes)" 
1569                 __gitcomp "$(__git_remotes)" "" "${cur##--repo=}" 
1574                         --all --mirror --tags --dry-run --force --verbose 
1575                         --receive-pack= --repo= 
1580         __git_complete_remote_or_refspec 
1585         local cur="${COMP_WORDS[COMP_CWORD]}" dir="$(__gitdir)" 
1586         if [ -d "$dir"/rebase-apply ] || [ -d "$dir"/rebase-merge ]; then 
1587                 __gitcomp "--continue --skip --abort" 
1590         __git_complete_strategy && return 
1593                 __gitcomp "--onto --merge --strategy --interactive" 
1596         __gitcomp "$(__git_refs)" 
1599 __git_send_email_confirm_options="always never auto cc compose
" 
1600 __git_send_email_suppresscc_options="author self cc bodycc sob cccmd body all
" 
1604         local cur="${COMP_WORDS[COMP_CWORD]}" 
1608                         $__git_send_email_confirm_options 
1609                         " "" "${cur##--confirm=}" 
1614                         $__git_send_email_suppresscc_options 
1615                         " "" "${cur##--suppress-cc=}" 
1619         --smtp-encryption=*) 
1620                 __gitcomp "ssl tls
" "" "${cur##--smtp-encryption=}" 
1624                 __gitcomp "--annotate --bcc --cc --cc-cmd --chain-reply-to 
1625                         --compose --confirm= --dry-run --envelope-sender 
1627                         --in-reply-to --no-chain-reply-to --no-signed-off-by-cc 
1628                         --no-suppress-from --no-thread --quiet 
1629                         --signed-off-by-cc --smtp-pass --smtp-server 
1630                         --smtp-server-port --smtp-encryption= --smtp-user 
1631                         --subject --suppress-cc= --suppress-from --thread --to 
1632                         --validate --no-validate" 
1639 __git_config_get_set_variables () 
1641         local prevword word config_file= c=$COMP_CWORD 
1642         while [ $c -gt 1 ]; do 
1643                 word="${COMP_WORDS[c]}" 
1645                 --global|--system|--file=*) 
1650                         config_file="$word $prevword" 
1658         git --git-dir="$(__gitdir)" config $config_file --list 2>/dev/null | 
1671         local cur="${COMP_WORDS[COMP_CWORD]}" 
1672         local prv="${COMP_WORDS[COMP_CWORD-1]}" 
1675                 __gitcomp "$(__git_remotes)" 
1679                 __gitcomp "$(__git_refs)" 
1683                 local remote="${prv#remote.}" 
1684                 remote="${remote%.fetch}" 
1685                 __gitcomp "$(__git_refs_remotes "$remote")" 
1689                 local remote="${prv#remote.}" 
1690                 remote="${remote%.push}" 
1691                 __gitcomp "$(git --git-dir="$(__gitdir)" \ 
1692                         for-each-ref --format='%(refname):%(refname)' \ 
1696         pull.twohead
|pull.octopus
) 
1697                 __gitcomp 
"$(__git_merge_strategies)" 
1700         color.branch
|color.
diff|color.interactive
|\
 
1701         color.showbranch
|color.status
|color.ui
) 
1702                 __gitcomp 
"always never auto" 
1706                 __gitcomp 
"false true" 
1711                         normal black red green yellow blue magenta cyan white 
1712                         bold dim ul blink reverse 
1717                 __gitcomp 
"man info web html" 
1721                 __gitcomp 
"$__git_log_date_formats" 
1724         sendemail.aliasesfiletype
) 
1725                 __gitcomp 
"mutt mailrc pine elm gnus" 
1729                 __gitcomp 
"$__git_send_email_confirm_options" 
1732         sendemail.suppresscc
) 
1733                 __gitcomp 
"$__git_send_email_suppresscc_options" 
1736         --get|--get-all|--unset|--unset-all) 
1737                 __gitcomp 
"$(__git_config_get_set_variables)" 
1748                         --global --system --file= 
1749                         --list --replace-all 
1750                         --get --get-all --get-regexp 
1751                         --add --unset --unset-all 
1752                         --remove-section --rename-section 
1757                 local pfx
="${cur%.*}." 
1759                 __gitcomp 
"remote merge mergeoptions rebase" "$pfx" "$cur" 
1763                 local pfx
="${cur%.*}." 
1765                 __gitcomp 
"$(__git_heads)" "$pfx" "$cur" "." 
1769                 local pfx
="${cur%.*}." 
1772                         argprompt cmd confirm needsfile noconsole norescan 
1773                         prompt revprompt revunmerged title 
1778                 local pfx
="${cur%.*}." 
1780                 __gitcomp 
"cmd path" "$pfx" "$cur" 
1784                 local pfx
="${cur%.*}." 
1786                 __gitcomp 
"cmd path" "$pfx" "$cur" 
1790                 local pfx
="${cur%.*}." 
1792                 __gitcomp 
"cmd path trustExitCode" "$pfx" "$cur" 
1796                 local pfx
="${cur%.*}." 
1798                 __gitcomp 
"$(__git_all_commands)" "$pfx" "$cur" 
1802                 local pfx
="${cur%.*}." 
1805                         url proxy fetch push mirror skipDefaultUpdate 
1806                         receivepack uploadpack tagopt pushurl 
1811                 local pfx
="${cur%.*}." 
1813                 __gitcomp 
"$(__git_remotes)" "$pfx" "$cur" "." 
1817                 local pfx
="${cur%.*}." 
1819                 __gitcomp 
"insteadOf pushInsteadOf" "$pfx" "$cur" 
1826                 apply.ignorewhitespace 
1828                 branch.autosetupmerge 
1829                 branch.autosetuprebase 
1832                 color.branch.current 
1843                 color.diff.whitespace 
1848                 color.interactive.header 
1849                 color.interactive.help 
1850                 color.interactive.prompt 
1855                 color.status.changed 
1857                 color.status.nobranch 
1858                 color.status.untracked 
1859                 color.status.updated 
1866                 core.deltaBaseCacheLimit 
1870                 core.fsyncobjectfiles 
1872                 core.ignoreCygwinFSTricks 
1874                 core.logAllRefUpdates 
1875                 core.loosecompression 
1877                 core.packedGitWindowSize 
1879                 core.preferSymlinkRefs 
1882                 core.repositoryFormatVersion 
1884                 core.sharedRepository 
1887                 core.warnAmbiguousRefs 
1890                 diff.autorefreshindex 
1896                 diff.suppressBlankEmpty 
1908                 format.subjectprefix 
1917                 gc.reflogexpireunreachable 
1921                 gitcvs.commitmsgannotation 
1922                 gitcvs.dbTableNamePrefix 
1933                 gui.copyblamethreshold 
1937                 gui.matchtrackingbranch 
1938                 gui.newbranchtemplate 
1939                 gui.pruneduringfetch 
1940                 gui.spellingdictionary 
1956                 i18n.logOutputEncoding 
1961                 imap.preformattedHTML 
1970                 interactive.singlekey 
1983                 mergetool.keepBackup 
1986                 pack.deltaCacheLimit 
1999                 receive.denyCurrentBranch 
2001                 receive.denyNonFastForwards 
2004                 repack.usedeltabaseoffset 
2007                 sendemail.aliasesfile 
2008                 sendemail.aliasesfiletype 
2012                 sendemail.chainreplyto 
2014                 sendemail.envelopesender 
2016                 sendemail.signedoffbycc 
2017                 sendemail.smtpencryption 
2019                 sendemail.smtpserver 
2020                 sendemail.smtpserverport 
2022                 sendemail.suppresscc 
2023                 sendemail.suppressfrom 
2028                 status.relativePaths 
2029                 status.showUntrackedFiles 
2031                 transfer.unpackLimit 
2043         local subcommands
="add rename rm show prune update set-head" 
2044         local subcommand
="$(__git_find_on_cmdline "$subcommands")" 
2045         if [ -z "$subcommand" ]; then 
2046                 __gitcomp 
"$subcommands" 
2050         case "$subcommand" in 
2051         rename
|rm|show
|prune
) 
2052                 __gitcomp 
"$(__git_remotes)" 
2055                 local i c
='' IFS
=$
'\n' 
2056                 for i 
in $(git --git-dir="$(__gitdir)" config --get-regexp "remotes\..
*" 2>/dev/null); do 
2070         __gitcomp "$(__git_refs)" 
2075         __git_has_doubledash && return 
2077         local cur="${COMP_WORDS[COMP_CWORD]}" 
2080                 __gitcomp "--merge --mixed --hard --soft --patch" 
2084         __gitcomp "$(__git_refs)" 
2089         local cur="${COMP_WORDS[COMP_CWORD]}" 
2092                 __gitcomp "--edit --mainline --no-edit --no-commit --signoff" 
2096         __gitcomp "$(__git_refs)" 
2101         __git_has_doubledash && return 
2103         local cur="${COMP_WORDS[COMP_CWORD]}" 
2106                 __gitcomp "--cached --dry-run --ignore-unmatch --quiet" 
2115         __git_has_doubledash && return 
2117         local cur="${COMP_WORDS[COMP_CWORD]}" 
2121                         $__git_log_common_options 
2122                         $__git_log_shortlog_options 
2123                         --numbered --summary 
2128         __git_complete_revlist 
2133         __git_has_doubledash && return 
2135         local cur="${COMP_WORDS[COMP_CWORD]}" 
2138                 __gitcomp "$__git_log_pretty_formats 
2139                         " "" "${cur##--pretty=}" 
2143                 __gitcomp "$__git_log_pretty_formats 
2144                         " "" "${cur##--format=}" 
2148                 __gitcomp "--pretty= --format= --abbrev-commit --oneline 
2149                         $__git_diff_common_options 
2159         local cur="${COMP_WORDS[COMP_CWORD]}" 
2163                         --all --remotes --topo-order --current --more= 
2164                         --list --independent --merge-base --no-name 
2166                         --sha1-name --sparse --topics --reflog 
2171         __git_complete_revlist 
2176         local cur="${COMP_WORDS[COMP_CWORD]}" 
2177         local save_opts='--keep-index --no-keep-index --quiet --patch' 
2178         local subcommands='save list show apply clear drop pop create branch' 
2179         local subcommand="$(__git_find_on_cmdline "$subcommands")" 
2180         if [ -z "$subcommand" ]; then 
2183                         __gitcomp "$save_opts" 
2186                         if [ -z "$(__git_find_on_cmdline "$save_opts")" ]; then 
2187                                 __gitcomp "$subcommands" 
2194                 case "$subcommand,$cur" in 
2196                         __gitcomp "$save_opts" 
2199                         __gitcomp "--index --quiet" 
2201                 show,--*|drop,--*|branch,--*) 
2204                 show,*|apply,*|drop,*|pop,*|branch,*) 
2205                         __gitcomp "$(git --git-dir="$(__gitdir)" stash list \ 
2206                                         | sed -n -e 's/:.*//p')" 
2217         __git_has_doubledash 
&& return 
2219         local subcommands
="add status init update summary foreach sync" 
2220         if [ -z "$(__git_find_on_cmdline "$subcommands")" ]; then 
2221                 local cur
="${COMP_WORDS[COMP_CWORD]}" 
2224                         __gitcomp 
"--quiet --cached" 
2227                         __gitcomp 
"$subcommands" 
2237                 init fetch clone rebase dcommit log find-rev 
2238                 set-tree commit-diff info create-ignore propget 
2239                 proplist show-ignore show-externals branch tag blame 
2242         local subcommand
="$(__git_find_on_cmdline "$subcommands")" 
2243         if [ -z "$subcommand" ]; then 
2244                 __gitcomp 
"$subcommands" 
2246                 local remote_opts
="--username= --config-dir= --no-auth-cache" 
2248                         --follow-parent --authors-file= --repack= 
2249                         --no-metadata --use-svm-props --use-svnsync-props 
2250                         --log-window-size= --no-checkout --quiet 
2251                         --repack-flags --use-log-author --localtime 
2252                         --ignore-paths= $remote_opts 
2255                         --template= --shared= --trunk= --tags= 
2256                         --branches= --stdlayout --minimize-url 
2257                         --no-metadata --use-svm-props --use-svnsync-props 
2258                         --rewrite-root= --prefix= --use-log-author 
2259                         --add-author-from $remote_opts 
2262                         --edit --rmdir --find-copies-harder --copy-similarity= 
2265                 local cur
="${COMP_WORDS[COMP_CWORD]}" 
2266                 case "$subcommand,$cur" in 
2268                         __gitcomp 
"--revision= --fetch-all $fc_opts" 
2271                         __gitcomp 
"--revision= $fc_opts $init_opts" 
2274                         __gitcomp 
"$init_opts" 
2278                                 --merge --strategy= --verbose --dry-run 
2279                                 --fetch-all --no-rebase --commit-url 
2280                                 --revision $cmt_opts $fc_opts 
2284                         __gitcomp 
"--stdin $cmt_opts $fc_opts" 
2286                 create
-ignore,--*|propget
,--*|proplist
,--*|show
-ignore,--*|\
 
2288                         __gitcomp 
"--revision=" 
2292                                 --limit= --revision= --verbose --incremental 
2293                                 --oneline --show-commit --non-recursive 
2294                                 --authors-file= --color 
2299                                 --merge --verbose --strategy= --local 
2300                                 --fetch-all --dry-run $fc_opts 
2304                         __gitcomp 
"--message= --file= --revision= $cmt_opts" 
2310                         __gitcomp 
"--dry-run --message --tag" 
2313                         __gitcomp 
"--dry-run --message" 
2316                         __gitcomp 
"--git-format" 
2320                                 --config-dir= --ignore-paths= --minimize 
2321                                 --no-auth-cache --username= 
2334         while [ $c -lt $COMP_CWORD ]; do 
2335                 i
="${COMP_WORDS[c]}" 
2338                         __gitcomp 
"$(__git_tags)" 
2348         case "${COMP_WORDS[COMP_CWORD-1]}" in 
2354                         __gitcomp 
"$(__git_tags)" 
2360                 __gitcomp 
"$(__git_refs)" 
2367         local i c
=1 command __git_dir
 
2369         while [ $c -lt $COMP_CWORD ]; do 
2370                 i
="${COMP_WORDS[c]}" 
2372                 --git-dir=*) __git_dir
="${i#--git-dir=}" ;; 
2373                 --bare)      __git_dir
="." ;; 
2374                 --version|-p|--paginate) ;; 
2375                 --help) command="help"; break ;; 
2376                 *) command="$i"; break ;; 
2381         if [ -z "$command" ]; then 
2382                 case "${COMP_WORDS[COMP_CWORD]}" in 
2395                 *)     __gitcomp 
"$(__git_porcelain_commands) $(__git_aliases)" ;; 
2400         local expansion
=$(__git_aliased_command "$command") 
2401         [ "$expansion" ] && command="$expansion" 
2406         apply
)       _git_apply 
;; 
2407         archive
)     _git_archive 
;; 
2408         bisect
)      _git_bisect 
;; 
2409         bundle
)      _git_bundle 
;; 
2410         branch
)      _git_branch 
;; 
2411         checkout
)    _git_checkout 
;; 
2412         cherry
)      _git_cherry 
;; 
2413         cherry
-pick) _git_cherry_pick 
;; 
2414         clean
)       _git_clean 
;; 
2415         clone
)       _git_clone 
;; 
2416         commit
)      _git_commit 
;; 
2417         config
)      _git_config 
;; 
2418         describe
)    _git_describe 
;; 
2420         difftool
)    _git_difftool 
;; 
2421         fetch
)       _git_fetch 
;; 
2422         format
-patch) _git_format_patch 
;; 
2429         ls-files)    _git_ls_files 
;; 
2430         ls-remote)   _git_ls_remote 
;; 
2431         ls-tree)     _git_ls_tree 
;; 
2433         mergetool
)   _git_mergetool
;; 
2434         merge
-base)  _git_merge_base 
;; 
2436         name
-rev)    _git_name_rev 
;; 
2439         rebase
)      _git_rebase 
;; 
2440         remote
)      _git_remote 
;; 
2441         replace
)     _git_replace 
;; 
2442         reset)       _git_reset 
;; 
2443         revert
)      _git_revert 
;; 
2445         send
-email)  _git_send_email 
;; 
2446         shortlog
)    _git_shortlog 
;; 
2448         show
-branch) _git_show_branch 
;; 
2449         stash
)       _git_stash 
;; 
2451         submodule
)   _git_submodule 
;; 
2454         whatchanged
) _git_log 
;; 
2461         __git_has_doubledash 
&& return 
2463         local cur
="${COMP_WORDS[COMP_CWORD]}" 
2464         local g
="$(__gitdir)" 
2466         if [ -f "$g/MERGE_HEAD" ]; then 
2472                         $__git_log_common_options 
2473                         $__git_log_gitk_options 
2479         __git_complete_revlist
 
2482 complete 
-o bashdefault 
-o default 
-o nospace 
-F _git git 
2>/dev
/null \
 
2483         || complete 
-o default 
-o nospace 
-F _git git
 
2484 complete 
-o bashdefault 
-o default 
-o nospace 
-F _gitk gitk 
2>/dev
/null \
 
2485         || complete 
-o default 
-o nospace 
-F _gitk gitk
 
2487 # The following are necessary only for Cygwin, and only are needed 
2488 # when the user has tab-completed the executable name and consequently 
2489 # included the '.exe' suffix. 
2491 if [ Cygwin 
= "$(uname -o 2>/dev/null)" ]; then 
2492 complete 
-o bashdefault 
-o default 
-o nospace 
-F _git git.exe 
2>/dev
/null \
 
2493         || complete 
-o default 
-o nospace 
-F _git git.exe
 
2496 # These are the standard set of aliases enabled by default in all 
2497 # git-sh sessions. Aliases defined in the gitconfig [alias] section override 
2500 gitalias a
='git add' 
2501 gitalias b
='git branch' 
2502 gitalias c
='git checkout' 
2503 gitalias d
='git diff' 
2504 gitalias f
='git fetch --prune' 
2505 gitalias k
='git cherry-pick' 
2506 gitalias l
='git log --pretty=oneline --abbrev-commit' 
2507 gitalias n
='git commit --verbose --amend' 
2508 gitalias r
='git remote' 
2509 gitalias s
='git commit --dry-run --short' 
2510 gitalias t
='git diff --cached' 
2512 # git add and the staging area 
2513 gitalias a
='git add' 
2514 gitalias aa
='git add --update'          # mnemonic: "add all" 
2515 gitalias stage
='git add' 
2516 gitalias ap
='git add --patch' 
2517 gitalias p
='git diff --cached'          # mnemonic: "patch" 
2518 gitalias ps
='git diff --cached --stat'  # mnemonic: "patch stat" 
2519 gitalias unstage
='git reset HEAD' 
2521 # commits and history 
2522 gitalias ci
='git commit --verbose' 
2523 gitalias ca
='git commit --verbose --all' 
2524 gitalias amend
='git commit --verbose --amend' 
2525 gitalias n
='git commit --verbose --amend' 
2526 gitalias k
='git cherry-pick' 
2527 gitalias re
='git rebase --interactive' 
2528 gitalias pop
='git reset --soft HEAD^' 
2529 gitalias peek
='git log -p --max-count=1' 
2532 gitalias f
='git fetch' 
2533 gitalias pm
='git pull'          # mnemonic: pull merge 
2534 gitalias 
pr='git pull --rebase' # mnemonic: pull rebase 
2537 gitalias d
='git diff' 
2538 gitalias ds
='git diff --stat'    # mnemonic: "diff stat" 
2541 gitalias hard
='git reset --hard' 
2542 gitalias soft
='git reset --soft' 
2543 gitalias scrap
='git checkout HEAD' 
2545 # CONFIG ============================================================== 
2547 # load gitconfig [alias] section as top-level aliases. 
2550 # source the system-wide rc file 
2551 [ -r /etc
/gitshrc 
] && . 
/etc
/gitshrc
 
2553 # source the user's rc file 
2554 [ -r ~
/.gitshrc 
] && . ~
/.gitshrc