@matheusbsbs / matheus-bagliano / commits / 5447aac755
Fork 0

bash: fix long option with argument double completion

Pressing TAB right after 'git command --long-option=' results in 'git command --long-option=--long-option=' when the long option requires an argument, but we don't provide completion for its arguments (e.g. commit --author=, apply --exclude=). This patch detects these long options and provides empty completion array for them. Signed-off-by: SZEDER Gábor <szeder@ira.uka.de> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

SZEDER Gábor committed Mar 5, 2008 at 20:07 UTC 5447aac755e5cfb948c627762b4665801811b026
1 file changed +15 -7
contrib/completion/git-completion.bash
+15 -7
@@ -121,13 +121,21 @@ __gitcomp ()
121 if [ $# -gt 2 ]; then
122 cur="$3"
123 fi
124 - for c in $1; do
125 - case "$c$4" in
126 - --*=*) all="$all$c$4$s" ;;
127 - *.) all="$all$c$4$s" ;;
128 - *) all="$all$c$4 $s" ;;
129 - esac
130 - done
124 + case "$cur" in
125 + --*=)
126 + COMPREPLY=()
127 + return
128 + ;;
129 + *)
130 + for c in $1; do
131 + case "$c$4" in
132 + --*=*) all="$all$c$4$s" ;;
133 + *.) all="$all$c$4$s" ;;
134 + *) all="$all$c$4 $s" ;;
135 + esac
136 + done
137 + ;;
138 + esac
139 IFS=$s
140 COMPREPLY=($(compgen -P "$2" -W "$all" -- "$cur"))
141 return