]> asedeno.scripts.mit.edu Git - git.git/blobdiff - contrib/completion/git-completion.bash
Merge branch 'mh/cherry-default'
[git.git] / contrib / completion / git-completion.bash
index 39a1ce5a3979e6160b8450a0d9dd08ec6b6cd7a2..7b074d79854813ffa38f781218bd878a79cbb505 100755 (executable)
@@ -154,11 +154,8 @@ __git_heads ()
 {
        local cmd i is_hash=y dir="$(__gitdir "$1")"
        if [ -d "$dir" ]; then
-               for i in $(git --git-dir="$dir" \
-                       for-each-ref --format='%(refname)' \
-                       refs/heads ); do
-                       echo "${i#refs/heads/}"
-               done
+               git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
+                       refs/heads
                return
        fi
        for i in $(git ls-remote "$1" 2>/dev/null); do
@@ -175,11 +172,8 @@ __git_tags ()
 {
        local cmd i is_hash=y dir="$(__gitdir "$1")"
        if [ -d "$dir" ]; then
-               for i in $(git --git-dir="$dir" \
-                       for-each-ref --format='%(refname)' \
-                       refs/tags ); do
-                       echo "${i#refs/tags/}"
-               done
+               git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
+                       refs/tags
                return
        fi
        for i in $(git ls-remote "$1" 2>/dev/null); do
@@ -194,19 +188,22 @@ __git_tags ()
 
 __git_refs ()
 {
-       local cmd i is_hash=y dir="$(__gitdir "$1")"
+       local i is_hash=y dir="$(__gitdir "$1")"
+       local cur="${COMP_WORDS[COMP_CWORD]}" format refs
        if [ -d "$dir" ]; then
-               if [ -e "$dir/HEAD" ]; then echo HEAD; fi
-               for i in $(git --git-dir="$dir" \
-                       for-each-ref --format='%(refname)' \
-                       refs/tags refs/heads refs/remotes); do
-                       case "$i" in
-                               refs/tags/*)    echo "${i#refs/tags/}" ;;
-                               refs/heads/*)   echo "${i#refs/heads/}" ;;
-                               refs/remotes/*) echo "${i#refs/remotes/}" ;;
-                               *)              echo "$i" ;;
-                       esac
-               done
+               case "$cur" in
+               refs|refs/*)
+                       format="refname"
+                       refs="${cur%/*}"
+                       ;;
+               *)
+                       if [ -e "$dir/HEAD" ]; then echo HEAD; fi
+                       format="refname:short"
+                       refs="refs/tags refs/heads refs/remotes"
+                       ;;
+               esac
+               git --git-dir="$dir" for-each-ref --format="%($format)" \
+                       $refs
                return
        fi
        for i in $(git ls-remote "$dir" 2>/dev/null); do
@@ -566,7 +563,7 @@ _git_add ()
        --*)
                __gitcomp "
                        --interactive --refresh --patch --update --dry-run
-                       --ignore-errors
+                       --ignore-errors --intent-to-add
                        "
                return
        esac
@@ -650,21 +647,12 @@ _git_branch ()
 
 _git_bundle ()
 {
-       local mycword="$COMP_CWORD"
-       case "${COMP_WORDS[0]}" in
-       git)
-               local cmd="${COMP_WORDS[2]}"
-               mycword="$((mycword-1))"
-               ;;
-       git-bundle*)
-               local cmd="${COMP_WORDS[1]}"
-               ;;
-       esac
-       case "$mycword" in
-       1)
+       local cmd="${COMP_WORDS[2]}"
+       case "$COMP_CWORD" in
+       2)
                __gitcomp "create list-heads verify unbundle"
                ;;
-       2)
+       3)
                # looking for a file
                ;;
        *)
@@ -788,6 +776,7 @@ _git_diff ()
                        --no-ext-diff
                        --no-prefix --src-prefix= --dst-prefix=
                        --base --ours --theirs
+                       --inter-hunk-context=
                        "
                return
                ;;
@@ -812,12 +801,7 @@ _git_fetch ()
                        __gitcomp "$(__git_refs)" "$pfx" "${cur#*:}"
                        ;;
                *)
-                       local remote
-                       case "${COMP_WORDS[0]}" in
-                       git-fetch) remote="${COMP_WORDS[1]}" ;;
-                       git)       remote="${COMP_WORDS[2]}" ;;
-                       esac
-                       __gitcomp "$(__git_refs2 "$remote")"
+                       __gitcomp "$(__git_refs2 "${COMP_WORDS[2]}")"
                        ;;
                esac
        fi
@@ -895,6 +879,7 @@ _git_help ()
                attributes cli core-tutorial cvs-migration
                diffcore gitk glossary hooks ignore modules
                repository-layout tutorial tutorial-2
+               workflows
                "
 }
 
@@ -983,6 +968,7 @@ _git_log ()
                        --color-words --walk-reflogs
                        --parents --children --full-history
                        --merge
+                       --inter-hunk-context=
                        "
                return
                ;;
@@ -1060,12 +1046,7 @@ _git_pull ()
        if [ "$COMP_CWORD" = 2 ]; then
                __gitcomp "$(__git_remotes)"
        else
-               local remote
-               case "${COMP_WORDS[0]}" in
-               git-pull)  remote="${COMP_WORDS[1]}" ;;
-               git)       remote="${COMP_WORDS[2]}" ;;
-               esac
-               __gitcomp "$(__git_refs "$remote")"
+               __gitcomp "$(__git_refs "${COMP_WORDS[2]}")"
        fi
 }
 
@@ -1078,19 +1059,13 @@ _git_push ()
        else
                case "$cur" in
                *:*)
-                       local remote
-                       case "${COMP_WORDS[0]}" in
-                       git-push)  remote="${COMP_WORDS[1]}" ;;
-                       git)       remote="${COMP_WORDS[2]}" ;;
-                       esac
-
                        local pfx=""
                        case "$COMP_WORDBREAKS" in
                        *:*) : great ;;
                        *)   pfx="${cur%%:*}:" ;;
                        esac
 
-                       __gitcomp "$(__git_refs "$remote")" "$pfx" "${cur#*:}"
+                       __gitcomp "$(__git_refs "${COMP_WORDS[2]}")" "$pfx" "${cur#*:}"
                        ;;
                +*)
                        __gitcomp "$(__git_refs)" + "${cur#+}"
@@ -1137,7 +1112,8 @@ _git_send_email ()
                        --no-suppress-from --no-thread --quiet
                        --signed-off-by-cc --smtp-pass --smtp-server
                        --smtp-server-port --smtp-ssl --smtp-user --subject
-                       --suppress-cc --suppress-from --thread --to"
+                       --suppress-cc --suppress-from --thread --to
+                       --validate --no-validate"
                return
                ;;
        esac
@@ -1181,7 +1157,7 @@ _git_config ()
                ;;
        color.*.*)
                __gitcomp "
-                       black red green yellow blue magenta cyan white
+                       normal black red green yellow blue magenta cyan white
                        bold dim ul blink reverse
                        "
                return
@@ -1205,7 +1181,7 @@ _git_config ()
        branch.*.*)
                local pfx="${cur%.*}."
                cur="${cur##*.}"
-               __gitcomp "remote merge" "$pfx" "$cur"
+               __gitcomp "remote merge mergeoptions" "$pfx" "$cur"
                return
                ;;
        branch.*)
@@ -1218,7 +1194,7 @@ _git_config ()
                local pfx="${cur%.*}."
                cur="${cur##*.}"
                __gitcomp "
-                       url fetch push skipDefaultUpdate
+                       url proxy fetch push mirror skipDefaultUpdate
                        receivepack uploadpack tagopt
                        " "$pfx" "$cur"
                return
@@ -1232,85 +1208,161 @@ _git_config ()
        esac
        __gitcomp "
                apply.whitespace
-               core.fileMode
-               core.gitProxy
-               core.ignoreStat
-               core.preferSymlinkRefs
-               core.logAllRefUpdates
-               core.loosecompression
-               core.repositoryFormatVersion
-               core.sharedRepository
-               core.warnAmbiguousRefs
-               core.compression
-               core.packedGitWindowSize
-               core.packedGitLimit
+               branch.autosetupmerge
+               branch.autosetuprebase
                clean.requireForce
                color.branch
                color.branch.current
                color.branch.local
-               color.branch.remote
                color.branch.plain
+               color.branch.remote
                color.diff
-               color.diff.plain
-               color.diff.meta
+               color.diff.commit
                color.diff.frag
-               color.diff.old
+               color.diff.meta
                color.diff.new
-               color.diff.commit
+               color.diff.old
+               color.diff.plain
                color.diff.whitespace
+               color.interactive
+               color.interactive.header
+               color.interactive.help
+               color.interactive.prompt
                color.pager
                color.status
-               color.status.header
                color.status.added
                color.status.changed
+               color.status.header
+               color.status.nobranch
                color.status.untracked
+               color.status.updated
+               color.ui
+               commit.template
+               core.autocrlf
+               core.bare
+               core.compression
+               core.deltaBaseCacheLimit
+               core.editor
+               core.excludesfile
+               core.fileMode
+               core.fsyncobjectfiles
+               core.gitProxy
+               core.ignoreCygwinFSTricks
+               core.ignoreStat
+               core.logAllRefUpdates
+               core.loosecompression
+               core.packedGitLimit
+               core.packedGitWindowSize
+               core.pager
+               core.preferSymlinkRefs
+               core.preloadindex
+               core.quotepath
+               core.repositoryFormatVersion
+               core.safecrlf
+               core.sharedRepository
+               core.symlinks
+               core.trustctime
+               core.warnAmbiguousRefs
+               core.whitespace
+               core.worktree
+               diff.autorefreshindex
+               diff.external
+               diff.mnemonicprefix
                diff.renameLimit
+               diff.renameLimit.
                diff.renames
                fetch.unpackLimit
                format.headers
-               format.subjectprefix
-               gitcvs.enabled
-               gitcvs.logfile
-               gitcvs.allbinary
-               gitcvs.dbname gitcvs.dbdriver gitcvs.dbuser gitcvs.dbpass
-               gitcvs.dbtablenameprefix
+               format.numbered
+               format.pretty
+               format.suffix
+               gc.aggressiveWindow
+               gc.auto
+               gc.autopacklimit
                gc.packrefs
+               gc.pruneexpire
                gc.reflogexpire
                gc.reflogexpireunreachable
                gc.rerereresolved
                gc.rerereunresolved
-               http.sslVerify
-               http.sslCert
-               http.sslKey
-               http.sslCAInfo
-               http.sslCAPath
-               http.maxRequests
+               gitcvs.allbinary
+               gitcvs.dbTableNamePrefix
+               gitcvs.dbdriver
+               gitcvs.dbname
+               gitcvs.dbpass
+               gitcvs.dbuser
+               gitcvs.enabled
+               gitcvs.logfile
+               gitcvs.usecrlfattr
+               gui.blamehistoryctx
+               gui.commitmsgwidth
+               gui.copyblamethreshold
+               gui.diffcontext
+               gui.encoding
+               gui.fastcopyblame
+               gui.matchtrackingbranch
+               gui.newbranchtemplate
+               gui.pruneduringfetch
+               gui.spellingdictionary
+               gui.trustmtime
+               help.autocorrect
+               help.browser
+               help.format
                http.lowSpeedLimit
                http.lowSpeedTime
+               http.maxRequests
                http.noEPSV
+               http.proxy
+               http.sslCAInfo
+               http.sslCAPath
+               http.sslCert
+               http.sslKey
+               http.sslVerify
                i18n.commitEncoding
                i18n.logOutputEncoding
+               instaweb.browser
+               instaweb.httpd
+               instaweb.local
+               instaweb.modulepath
+               instaweb.port
+               log.date
                log.showroot
+               man.viewer
+               merge.conflictstyle
+               merge.log
+               merge.renameLimit
+               merge.stat
                merge.tool
-               merge.summary
                merge.verbosity
-               pack.window
-               pack.depth
-               pack.windowMemory
+               mergetool.keepBackup
                pack.compression
-               pack.deltaCacheSize
                pack.deltaCacheLimit
+               pack.deltaCacheSize
+               pack.depth
+               pack.indexVersion
+               pack.packSizeLimit
+               pack.threads
+               pack.window
+               pack.windowMemory
                pull.octopus
                pull.twohead
-               repack.useDeltaBaseOffset
+               receive.denyCurrentBranch
+               receive.denyDeletes
+               receive.denyNonFastForwards
+               receive.fsckObjects
+               receive.unpackLimit
+               repack.usedeltabaseoffset
+               rerere.autoupdate
+               rerere.enabled
                showbranch.default
+               status.relativePaths
+               status.showUntrackedFiles
                tar.umask
                transfer.unpackLimit
-               receive.unpackLimit
-               receive.denyNonFastForwards
-               user.name
                user.email
+               user.name
                user.signingkey
+               web.browser
                branch. remote.
        "
 }
@@ -1353,7 +1405,7 @@ _git_reset ()
        local cur="${COMP_WORDS[COMP_CWORD]}"
        case "$cur" in
        --*)
-               __gitcomp "--mixed --hard --soft"
+               __gitcomp "--merge --mixed --hard --soft"
                return
                ;;
        esac
@@ -1369,7 +1421,7 @@ _git_revert ()
                return
                ;;
        esac
-       COMPREPLY=()
+       __gitcomp "$(__git_refs)"
 }
 
 _git_rm ()
@@ -1477,7 +1529,7 @@ _git_submodule ()
 {
        __git_has_doubledash && return
 
-       local subcommands="add status init update"
+       local subcommands="add status init update summary foreach sync"
        if [ -z "$(__git_find_subcommand "$subcommands")" ]; then
                local cur="${COMP_WORDS[COMP_CWORD]}"
                case "$cur" in
@@ -1591,7 +1643,7 @@ _git_tag ()
        -m|-F)
                COMPREPLY=()
                ;;
-       -*|tag|git-tag)
+       -*|tag)
                if [ $f = 1 ]; then
                        __gitcomp "$(__git_tags)"
                else
@@ -1686,6 +1738,7 @@ _git ()
        show)        _git_show ;;
        show-branch) _git_show_branch ;;
        stash)       _git_stash ;;
+       stage)       _git_add ;;
        submodule)   _git_submodule ;;
        svn)         _git_svn ;;
        tag)         _git_tag ;;