Subject: [PATCH] commit: correctly escape @ of stashes

From: "Martin Bektchiev via GitGitGadget" <[email-masked]>
Date: Fri, 03 Jul 2020 09:30:55 +0000

From: Martin Bektchiev <[email-masked]>

Autocomplete suggestions for stashes are broken due to `stash@`
being suggested without escaping.

Reproducible on `GNU bash, version 3.2.57(1)-release` and
`macOS Catalina 10.15.5`.

Signed-off-by: Martin Bektchiev <[email-masked]>
---
    Correctly escape @ of stashes
    
    Autocomplete suggestions for stashes are broken due to stash@being
    suggested without escaping.
    
    Reproducible on GNU bash, version 3.2.57(1)-release
    (x86_64-apple-darwin19)and macOS Catalina 10.15.5.

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-815%2Fmbektchiev%2Fpatch-1-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-815/mbektchiev/patch-1-v1
Pull-Request: https://github.com/git/git/pull/815

 contrib/completion/git-completion.bash | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index de5d0fbbd1..986a7352ef 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -2999,12 +2999,14 @@ _git_stash ()
 				__git_complete_refs
 			else
 				__gitcomp_nl "$(__git stash list \
-						| sed -n -e 's/:.*//p')"
+						| sed -n -e 's/:.*//p' \
+						| sed 's/@/\\@/')"
 			fi
 			;;
 		show,*|apply,*|drop,*|pop,*)
 			__gitcomp_nl "$(__git stash list \
-					| sed -n -e 's/:.*//p')"
+					| sed -n -e 's/:.*//p' \
+					| sed 's/@/\\@/')"
 			;;
 		*)
 			;;

base-commit: a08a83db2bf27f015bec9a435f6d73e223c21c5e
-- 
gitgitgadget