[PATCH v2 15/26] completion: bash: improve __gitcomp suffix code
From: Felipe Contreras <hidden>
Date: 2020-11-10 21:22:11
Subsystem:
the rest · Maintainer:
Linus Torvalds
From: Felipe Contreras <hidden>
Date: 2020-11-10 21:22:11
Subsystem:
the rest · Maintainer:
Linus Torvalds
There's no point in adding a suffix after a suffix. If a suffix is provided, we add it, if not, then the default heuristic is used. There's no functional change since most callers don't specify a suffix, and the ones that do use an =, which by default doesn't add an additional suffix. Signed-off-by: Felipe Contreras <redacted> --- contrib/completion/git-completion.bash | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 829985e4fb..594e41276e 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash@@ -325,7 +325,7 @@ __gitcomp () return fi - local c i=0 IFS=$' \t\n' + local c i=0 IFS=$' \t\n' sfx for c in $1; do if [[ $c == "--" ]]; then if [[ "$cur_" == --no-* ]]; then
@@ -338,12 +338,11 @@ __gitcomp () break fi if [[ $c == "$cur_"* ]]; then - c="$c${4-}" case $c in - *=|*.) ;; - *) c="$c " ;; + *=|*.) sfx="" ;; + *) sfx=" " ;; esac - COMPREPLY[i++]="${2-}$c" + COMPREPLY[i++]="${2-}$c${4:-$sfx}" fi done }
--
2.29.2