Code

completion: Allow dash as the first character for __git_ps1
[git.git] / contrib / completion / git-completion.bash
index cc1bdf960949cfeb977d8a188a2324b48bf5c6df..61ff1521b625111a839941325a232c73ac01cda2 100755 (executable)
@@ -111,7 +111,7 @@ __git_ps1_show_upstream ()
 
        # get some config options from git-config
        local output="$(git config -z --get-regexp '^(svn-remote\..*\.url|bash\.showupstream)$' 2>/dev/null | tr '\0\n' '\n ')"
-       while read key value; do
+       while read -r key value; do
                case "$key" in
                bash.showupstream)
                        GIT_PS1_SHOWUPSTREAM="$value"
@@ -313,7 +313,7 @@ __git_ps1 ()
                fi
 
                local f="$w$i$s$u"
-               printf "${1:- (%s)}" "$c${b##refs/heads/}${f:+ $f}$r$p"
+               printf -- "${1:- (%s)}" "$c${b##refs/heads/}${f:+ $f}$r$p"
        fi
 }
 
@@ -589,7 +589,7 @@ __git_refs ()
                        local ref entry
                        git --git-dir="$dir" for-each-ref --shell --format="ref=%(refname:short)" \
                                "refs/remotes/" | \
-                       while read entry; do
+                       while read -r entry; do
                                eval "$entry"
                                ref="${ref#*/}"
                                if [[ "$ref" == "$cur"* ]]; then
@@ -602,7 +602,7 @@ __git_refs ()
        case "$cur" in
        refs|refs/*)
                git ls-remote "$dir" "$cur*" 2>/dev/null | \
-               while read hash i; do
+               while read -r hash i; do
                        case "$i" in
                        *^{}) ;;
                        *) echo "$i" ;;
@@ -611,7 +611,7 @@ __git_refs ()
                ;;
        *)
                git ls-remote "$dir" HEAD ORIG_HEAD 'refs/tags/*' 'refs/heads/*' 'refs/remotes/*' 2>/dev/null | \
-               while read hash i; do
+               while read -r hash i; do
                        case "$i" in
                        *^{}) ;;
                        refs/*) echo "${i#refs/*/}" ;;
@@ -636,7 +636,7 @@ __git_refs_remotes ()
 {
        local i hash
        git ls-remote "$1" 'refs/heads/*' 2>/dev/null | \
-       while read hash i; do
+       while read -r hash i; do
                echo "$i:refs/remotes/$1/${i#refs/heads/}"
        done
 }
@@ -1152,7 +1152,7 @@ _git_branch ()
                __gitcomp "
                        --color --no-color --verbose --abbrev= --no-abbrev
                        --track --no-track --contains --merged --no-merged
-                       --set-upstream
+                       --set-upstream --edit-description --list
                        "
                ;;
        *)
@@ -1622,7 +1622,7 @@ _git_log ()
 
 __git_merge_options="
        --no-commit --no-stat --log --no-log --squash --strategy
-       --commit --stat --no-squash --ff --no-ff --ff-only
+       --commit --stat --no-squash --ff --no-ff --ff-only --edit --no-edit
 "
 
 _git_merge ()
@@ -1863,7 +1863,7 @@ __git_config_get_set_variables ()
        done
 
        git --git-dir="$(__gitdir)" config $config_file --list 2>/dev/null |
-       while read line
+       while read -r line
        do
                case "$line" in
                *.*=*)
@@ -2631,6 +2631,10 @@ _git ()
                # workaround zsh's bug that leaves 'words' as a special
                # variable in versions < 4.3.12
                typeset -h words
+
+               # workaround zsh's bug that quotes spaces in the COMPREPLY
+               # array if IFS doesn't contain spaces.
+               typeset -h IFS
        fi
 
        local cur words cword prev
@@ -2687,6 +2691,10 @@ _gitk ()
                # workaround zsh's bug that leaves 'words' as a special
                # variable in versions < 4.3.12
                typeset -h words
+
+               # workaround zsh's bug that quotes spaces in the COMPREPLY
+               # array if IFS doesn't contain spaces.
+               typeset -h IFS
        fi
 
        local cur words cword prev