]> git.ipfire.org Git - thirdparty/git.git/commitdiff
completion: fix incorrect bash/zsh string equality check
authorRobert Estelle <robertestelle@gmail.com>
Mon, 25 Oct 2021 22:29:33 +0000 (22:29 +0000)
committerJunio C Hamano <gitster@pobox.com>
Thu, 28 Oct 2021 16:33:19 +0000 (09:33 -0700)
In the basic `[`/`test` command, the string equality operator is a
single `=`. The `==` operator is only available in `[[`, which is a
bash-ism also supported by zsh.

This mix-up was causing the following completion error in zsh:
> __git_ls_files_helper:7: = not found

(That message refers to the extraneous symbol in `==` ← `=`).

This updates that comparison to use a single `=` inside the
basic `[ … ]` test conditional.

Although this fix is inconsistent with the other comparisons in this
file, which use `[[ … == … ]]`, and the two expressions are functionally
identical in this context, that approach was rejected due to a
preference for `[`.

Signed-off-by: Robert Estelle <robertestelle@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
contrib/completion/git-completion.bash

index 8108eda1e8614728063c67f5658bccdc0e1d8ec0..0a20fa5311cc379a5fb6d3e1225b3aee61b91c78 100644 (file)
@@ -515,7 +515,7 @@ __gitcomp_file ()
 # argument, and using the options specified in the second argument.
 __git_ls_files_helper ()
 {
-       if [ "$2" == "--committable" ]; then
+       if [ "$2" = "--committable" ]; then
                __git -C "$1" -c core.quotePath=false diff-index \
                        --name-only --relative HEAD -- "${3//\\/\\\\}*"
        else