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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"Martin Bektchiev via GitGitGadget" <gitgitgadget@xxxxxxxxx> writes:

> From: Martin Bektchiev <martin.bektchiev@xxxxxxxxxxxx>
>
> Autocomplete suggestions for stashes are broken due to `stash@`
> being suggested without escaping.

What is unclear to readers of this sentence is why '@' needs to be
quoted in the first place.  '@' is not like '$' that has a syntactic
significance to the shell.

In fact, I just tried

    $ git stash show stas<TAB>

in a test repository where there is only one stash entry and got it
completed to

    $ git stash show stash@{0}

and pressing <Enter> from this state did exactly what I expected to
see.

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

What did you reproduce?  The completion gave me "stash@{0}" (without
surrounding double quotes) in my above experiment?  If so, that does
seem reproducible, but I do not see "suggestions ... are broken" here.

> @@ -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/@/\\@/')"

This is not a new problem introduced by this patch, but we should
get rid of these unnecessary backslashes and pipe at the beginning
of the second line, both of which make the resulting code harder
than necessary to read.  Ending the line with '|' pipe would give
enough clue to the shell that you haven't finished talking to it,
and you can continue to the next line without any backslashes just
fine.

>  			fi
>  			;;
>  		show,*|apply,*|drop,*|pop,*)
>  			__gitcomp_nl "$(__git stash list \
> -					| sed -n -e 's/:.*//p')"
> +					| sed -n -e 's/:.*//p' \
> +					| sed 's/@/\\@/')"

Ditto.

>  			;;
>  		*)
>  			;;
>
> base-commit: a08a83db2bf27f015bec9a435f6d73e223c21c5e



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux