clone: add a --no-tags option to clone without tags
[gitweb.git] / contrib / completion / git-completion.bash
index bd07d9a7461021be6ab58b5083c34169e455f965..6da997cf426666019368162972f1a8e84fe28b29 100644 (file)
@@ -1102,6 +1102,7 @@ _git_apply ()
                        --apply --no-add --exclude=
                        --ignore-whitespace --ignore-space-change
                        --whitespace= --inaccurate-eof --verbose
+                       --recount --directory=
                        "
                return
        esac
@@ -1113,13 +1114,17 @@ _git_add ()
        --*)
                __gitcomp "
                        --interactive --refresh --patch --update --dry-run
-                       --ignore-errors --intent-to-add
+                       --ignore-errors --intent-to-add --force --edit --chmod=
                        "
                return
        esac
 
-       # XXX should we check for --update and --all options ?
-       __git_complete_index_file "--others --modified --directory --no-empty-directory"
+       local complete_opt="--others --modified --directory --no-empty-directory"
+       if test -n "$(__git_find_on_cmdline "-u --update")"
+       then
+               complete_opt="--modified"
+       fi
+       __git_complete_index_file "$complete_opt"
 }
 
 _git_archive ()
@@ -1136,7 +1141,7 @@ _git_archive ()
        --*)
                __gitcomp "
                        --format= --list --verbose
-                       --prefix= --remote= --exec=
+                       --prefix= --remote= --exec= --output
                        "
                return
                ;;
@@ -1189,9 +1194,10 @@ _git_branch ()
        --*)
                __gitcomp "
                        --color --no-color --verbose --abbrev= --no-abbrev
-                       --track --no-track --contains --merged --no-merged
+                       --track --no-track --contains --no-contains --merged --no-merged
                        --set-upstream-to= --edit-description --list
                        --unset-upstream --delete --move --remotes
+                       --column --no-column --sort= --points-at
                        "
                ;;
        *)
@@ -1303,8 +1309,11 @@ _git_clone ()
                        --template=
                        --depth
                        --single-branch
+                       --no-tags
                        --branch
                        --recurse-submodules
+                       --no-single-branch
+                       --shallow-submodules
                        "
                return
                ;;
@@ -1346,6 +1355,7 @@ _git_commit ()
                        --reset-author --file= --message= --template=
                        --cleanup= --untracked-files --untracked-files=
                        --verbose --quiet --fixup= --squash=
+                       --patch --short --date --allow-empty
                        "
                return
        esac
@@ -1364,7 +1374,8 @@ _git_describe ()
        --*)
                __gitcomp "
                        --all --tags --contains --abbrev= --candidates=
-                       --exact-match --debug --long --match --always
+                       --exact-match --debug --long --match --always --first-parent
+                       --exclude
                        "
                return
        esac
@@ -1447,6 +1458,7 @@ __git_fetch_recurse_submodules="yes on-demand no"
 __git_fetch_options="
        --quiet --verbose --append --upload-pack --force --keep --depth=
        --tags --no-tags --all --prune --dry-run --recurse-submodules=
+       --unshallow --update-shallow
 "
 
 _git_fetch ()
@@ -1496,7 +1508,7 @@ _git_fsck ()
        --*)
                __gitcomp "
                        --tags --root --unreachable --cache --no-reflogs --full
-                       --strict --verbose --lost-found
+                       --strict --verbose --lost-found --name-objects
                        "
                return
                ;;
@@ -1518,8 +1530,43 @@ _git_gitk ()
        _gitk
 }
 
-__git_match_ctag() {
-       awk "/^${1//\//\\/}/ { print \$1 }" "$2"
+# Lists matching symbol names from a tag (as in ctags) file.
+# 1: List symbol names matching this word.
+# 2: The tag file to list symbol names from.
+# 3: A prefix to be added to each listed symbol name (optional).
+# 4: A suffix to be appended to each listed symbol name (optional).
+__git_match_ctag () {
+       awk -v pfx="${3-}" -v sfx="${4-}" "
+               /^${1//\//\\/}/ { print pfx \$1 sfx }
+               " "$2"
+}
+
+# Complete symbol names from a tag file.
+# Usage: __git_complete_symbol [<option>]...
+# --tags=<file>: The tag file to list symbol names from instead of the
+#                default "tags".
+# --pfx=<prefix>: A prefix to be added to each symbol name.
+# --cur=<word>: The current symbol name to be completed.  Defaults to
+#               the current word to be completed.
+# --sfx=<suffix>: A suffix to be appended to each symbol name instead
+#                 of the default space.
+__git_complete_symbol () {
+       local tags=tags pfx="" cur_="${cur-}" sfx=" "
+
+       while test $# != 0; do
+               case "$1" in
+               --tags=*)       tags="${1##--tags=}" ;;
+               --pfx=*)        pfx="${1##--pfx=}" ;;
+               --cur=*)        cur_="${1##--cur=}" ;;
+               --sfx=*)        sfx="${1##--sfx=}" ;;
+               *)              return 1 ;;
+               esac
+               shift
+       done
+
+       if test -r "$tags"; then
+               __gitcomp_direct "$(__git_match_ctag "$cur_" "$tags" "$pfx" "$sfx")"
+       fi
 }
 
 _git_grep ()
@@ -1540,6 +1587,8 @@ _git_grep ()
                        --max-depth
                        --count
                        --and --or --not --all-match
+                       --break --heading --show-function --function-context
+                       --untracked --no-index
                        "
                return
                ;;
@@ -1547,10 +1596,7 @@ _git_grep ()
 
        case "$cword,$prev" in
        2,*|*,-*)
-               if test -r tags; then
-                       __gitcomp_nl "$(__git_match_ctag "$cur" tags)"
-                       return
-               fi
+               __git_complete_symbol && return
                ;;
        esac
 
@@ -1612,6 +1658,12 @@ _git_ls_files ()
 
 _git_ls_remote ()
 {
+       case "$cur" in
+       --*)
+               __gitcomp "--heads --tags --refs --get-url --symref"
+               return
+               ;;
+       esac
        __gitcomp_nl "$(__git_remotes)"
 }
 
@@ -1655,6 +1707,19 @@ _git_log ()
        if [ -f "$__git_repo_path/MERGE_HEAD" ]; then
                merge="--merge"
        fi
+       case "$prev,$cur" in
+       -L,:*:*)
+               return  # fall back to Bash filename completion
+               ;;
+       -L,:*)
+               __git_complete_symbol --cur="${cur#:}" --sfx=":"
+               return
+               ;;
+       -G,*|-S,*)
+               __git_complete_symbol
+               return
+               ;;
+       esac
        case "$cur" in
        --pretty=*|--format=*)
                __gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases)
@@ -1700,6 +1765,21 @@ _git_log ()
                        "
                return
                ;;
+       -L:*:*)
+               return  # fall back to Bash filename completion
+               ;;
+       -L:*)
+               __git_complete_symbol --cur="${cur#-L:}" --sfx=":"
+               return
+               ;;
+       -G*)
+               __git_complete_symbol --pfx="-G" --cur="${cur#-G}"
+               return
+               ;;
+       -S*)
+               __git_complete_symbol --pfx="-S" --cur="${cur#-S}"
+               return
+               ;;
        esac
        __git_complete_revlist
 }
@@ -1733,7 +1813,7 @@ _git_mergetool ()
                return
                ;;
        --*)
-               __gitcomp "--tool="
+               __gitcomp "--tool= --prompt --no-prompt"
                return
                ;;
        esac
@@ -1841,7 +1921,7 @@ _git_pull ()
        __git_complete_remote_or_refspec
 }
 
-__git_push_recurse_submodules="check on-demand"
+__git_push_recurse_submodules="check on-demand only"
 
 __git_complete_force_with_lease ()
 {
@@ -2537,40 +2617,88 @@ _git_config ()
 
 _git_remote ()
 {
-       local subcommands="add rename remove set-head set-branches set-url show prune update"
+       local subcommands="
+               add rename remove set-head set-branches
+               get-url set-url show prune update
+               "
        local subcommand="$(__git_find_on_cmdline "$subcommands")"
        if [ -z "$subcommand" ]; then
-               __gitcomp "$subcommands"
+               case "$cur" in
+               --*)
+                       __gitcomp "--verbose"
+                       ;;
+               *)
+                       __gitcomp "$subcommands"
+                       ;;
+               esac
                return
        fi
 
-       case "$subcommand" in
-       rename|remove|set-url|show|prune)
-               __gitcomp_nl "$(__git_remotes)"
+       case "$subcommand,$cur" in
+       add,--*)
+               __gitcomp "--track --master --fetch --tags --no-tags --mirror="
+               ;;
+       add,*)
+               ;;
+       set-head,--*)
+               __gitcomp "--auto --delete"
+               ;;
+       set-branches,--*)
+               __gitcomp "--add"
                ;;
-       set-head|set-branches)
+       set-head,*|set-branches,*)
                __git_complete_remote_or_refspec
                ;;
-       update)
+       update,--*)
+               __gitcomp "--prune"
+               ;;
+       update,*)
                __gitcomp "$(__git_get_config_variables "remotes")"
                ;;
+       set-url,--*)
+               __gitcomp "--push --add --delete"
+               ;;
+       get-url,--*)
+               __gitcomp "--push --all"
+               ;;
+       prune,--*)
+               __gitcomp "--dry-run"
+               ;;
        *)
+               __gitcomp_nl "$(__git_remotes)"
                ;;
        esac
 }
 
 _git_replace ()
 {
+       case "$cur" in
+       --*)
+               __gitcomp "--edit --graft --format= --list --delete"
+               return
+               ;;
+       esac
        __git_complete_refs
 }
 
+_git_rerere ()
+{
+       local subcommands="clear forget diff remaining status gc"
+       local subcommand="$(__git_find_on_cmdline "$subcommands")"
+       if test -z "$subcommand"
+       then
+               __gitcomp "$subcommands"
+               return
+       fi
+}
+
 _git_reset ()
 {
        __git_has_doubledash && return
 
        case "$cur" in
        --*)
-               __gitcomp "--merge --mixed --hard --soft --patch"
+               __gitcomp "--merge --mixed --hard --soft --patch --keep"
                return
                ;;
        esac
@@ -2586,7 +2714,10 @@ _git_revert ()
        fi
        case "$cur" in
        --*)
-               __gitcomp "--edit --mainline --no-edit --no-commit --signoff"
+               __gitcomp "
+                       --edit --mainline --no-edit --no-commit --signoff
+                       --strategy= --strategy-option=
+                       "
                return
                ;;
        esac
@@ -2614,7 +2745,7 @@ _git_shortlog ()
                __gitcomp "
                        $__git_log_common_options
                        $__git_log_shortlog_options
-                       --numbered --summary
+                       --numbered --summary --email
                        "
                return
                ;;
@@ -2719,10 +2850,11 @@ _git_submodule ()
        __git_has_doubledash && return
 
        local subcommands="add status init deinit update summary foreach sync"
-       if [ -z "$(__git_find_on_cmdline "$subcommands")" ]; then
+       local subcommand="$(__git_find_on_cmdline "$subcommands")"
+       if [ -z "$subcommand" ]; then
                case "$cur" in
                --*)
-                       __gitcomp "--quiet --cached"
+                       __gitcomp "--quiet"
                        ;;
                *)
                        __gitcomp "$subcommands"
@@ -2730,6 +2862,33 @@ _git_submodule ()
                esac
                return
        fi
+
+       case "$subcommand,$cur" in
+       add,--*)
+               __gitcomp "--branch --force --name --reference --depth"
+               ;;
+       status,--*)
+               __gitcomp "--cached --recursive"
+               ;;
+       deinit,--*)
+               __gitcomp "--force --all"
+               ;;
+       update,--*)
+               __gitcomp "
+                       --init --remote --no-fetch
+                       --recommend-shallow --no-recommend-shallow
+                       --force --rebase --merge --reference --depth --recursive --jobs
+               "
+               ;;
+       summary,--*)
+               __gitcomp "--cached --files --summary-limit"
+               ;;
+       foreach,--*|sync,--*)
+               __gitcomp "--recursive"
+               ;;
+       *)
+               ;;
+       esac
 }
 
 _git_svn ()
@@ -2750,14 +2909,14 @@ _git_svn ()
                        --no-metadata --use-svm-props --use-svnsync-props
                        --log-window-size= --no-checkout --quiet
                        --repack-flags --use-log-author --localtime
+                       --add-author-from
                        --ignore-paths= --include-paths= $remote_opts
                        "
                local init_opts="
                        --template= --shared= --trunk= --tags=
                        --branches= --stdlayout --minimize-url
                        --no-metadata --use-svm-props --use-svnsync-props
-                       --rewrite-root= --prefix= --use-log-author
-                       --add-author-from $remote_opts
+                       --rewrite-root= --prefix= $remote_opts
                        "
                local cmt_opts="
                        --edit --rmdir --find-copies-harder --copy-similarity=
@@ -2864,8 +3023,8 @@ _git_tag ()
        --*)
                __gitcomp "
                        --list --delete --verify --annotate --message --file
-                       --sign --cleanup --local-user --force --column --sort
-                       --contains --points-at
+                       --sign --cleanup --local-user --force --column --sort=
+                       --contains --no-contains --points-at --merged --no-merged --create-reflog
                        "
                ;;
        esac