[PATCH v2 15/26] completion: bash: improve __gitcomp suffix code
- From
Felipe Contreras <felipe.contreras@gmail.com>
- Date
- Nov 10, 2020, 21:21 UTC
- Message-ID
- <20201110212136.870769-16-felipe.contreras@gmail.com>
- In-Reply-To
- <20201110212136.870769-1-felipe.contreras@gmail.com>
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 <felipe.contreras@gmail.com> --- 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