git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Martin Bektchiev via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, Martin Bektchiev <martinb@gmail.com>,
	Martin Bektchiev <martin.bektchiev@progress.com>
Subject: Re: [PATCH] commit: correctly escape @ of stashes
Date: Sun, 05 Jul 2020 23:39:04 -0700	[thread overview]
Message-ID: <xmqqv9j19mgn.fsf@gitster.c.googlers.com> (raw)
In-Reply-To: <pull.815.git.git.1593768655179.gitgitgadget@gmail.com> (Martin Bektchiev via GitGitGadget's message of "Fri, 03 Jul 2020 09:30:55 +0000")

"Martin Bektchiev via GitGitGadget" <gitgitgadget@gmail.com> writes:

> From: Martin Bektchiev <martin.bektchiev@progress.com>
>
> 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

  reply	other threads:[~2020-07-06  6:39 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-03  9:30 [PATCH] commit: correctly escape @ of stashes Martin Bektchiev via GitGitGadget
2020-07-06  6:39 ` Junio C Hamano [this message]
2020-07-06 23:14   ` Johannes Schindelin
2020-07-08 20:53     ` Junio C Hamano
     [not found]       ` <CAEVR=HRrtT-vae8edN=Ltnp=amApMfUrt0j+6guWYMWZyz8Ohw@mail.gmail.com>
2020-07-09  9:13         ` Johannes Schindelin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqv9j19mgn.fsf@gitster.c.googlers.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=martin.bektchiev@progress.com \
    --cc=martinb@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).