@@ -339,44 +339,28 @@ __gitcomp ()
return
fi
- case "$cur_" in
- --no-*)
- local c i=0 IFS=$' \t\n'
- for c in $1; do
- if [[ $c == "--" ]]; then
+ local c i=0 IFS=$' \t\n'
+ for c in $1; do
+ if [[ $c == "--" ]]; then
+ if [[ "$cur_" == --no-* ]]; then
continue
fi
- c="$c${4-}"
- if [[ $c == "$cur_"* ]]; then
- case $c in
- *=|*.) ;;
- *) c="$c " ;;
- esac
- COMPREPLY[i++]="${2-}$c"
- fi
- done
- ;;
- *)
- local c i=0 IFS=$' \t\n'
- for c in $1; do
- if [[ $c == "--" ]]; then
- c="--no-...${4-}"
- if [[ $c == "$cur_"* ]]; then
- COMPREPLY[i++]="${2-}$c "
- fi
- break
- fi
- c="$c${4-}"
+
+ c="--no-...${4-}"
if [[ $c == "$cur_"* ]]; then
- case $c in
- *=|*.) ;;
- *) c="$c " ;;
- esac
- COMPREPLY[i++]="${2-}$c"
+ COMPREPLY[i++]="${2-}$c "
fi
- done
- ;;
- esac
+ break
+ fi
+ c="$c${4-}"
+ if [[ $c == "$cur_"* ]]; then
+ case $c in
+ *=|*.) ;;
+ *) c="$c " ;;
+ esac
+ COMPREPLY[i++]="${2-}$c"
+ fi
+ done
}
# Clear the variables caching builtins' options when (re-)sourcing
@@ -58,42 +58,22 @@ __gitcomp ()
[[ "$cur_" == *= ]] && return
- case "$cur_" in
- --no-*)
- local c IFS=$' \t\n'
- local -a array
- for c in ${=1}; do
- if [[ $c == "--" ]]; then
- continue
- fi
- c="$c${4-}"
- case $c in
- *=|*.) ;;
- *) c="$c " ;;
- esac
- array+=("$c")
- done
- compadd -Q -S '' -p "${2-}" -a -- array && _ret=0
- ;;
- *)
- local c IFS=$' \t\n'
- local -a array
- for c in ${=1}; do
- if [[ $c == "--" ]]; then
- c="--no-...${4-}"
- array+=("$c ")
- break
- fi
- c="$c${4-}"
- case $c in
- *=|*.) ;;
- *) c="$c " ;;
- esac
- array+=("$c")
- done
- compadd -Q -S '' -p "${2-}" -a -- array && _ret=0
- ;;
- esac
+ local c IFS=$' \t\n'
+ local -a array
+ for c in ${=1}; do
+ if [[ $c == "--" ]]; then
+ [[ "$cur_" == --no-* ]] && continue
+ array+=("--no-...${4-} ")
+ break
+ fi
+ c="$c${4-}"
+ case $c in
+ *=|*.) ;;
+ *) c="$c " ;;
+ esac
+ array+=("$c")
+ done
+ compadd -Q -S '' -p "${2-}" -a -- array && _ret=0
}
__gitcomp_direct ()
We have two chunks of code doing exactly the same, there's no need for that. No functional changes. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> --- contrib/completion/git-completion.bash | 52 +++++++++----------------- contrib/completion/git-completion.zsh | 52 ++++++++------------------ 2 files changed, 34 insertions(+), 70 deletions(-)