From: Junio C Hamano <gitster@pobox.com>
To: Martin Bektchiev via GitGitGadget <gitgitgadget@gmail.com>
Cc: Johannes Schindelin <Johannes.Schindelin@gmx.de>,
git@vger.kernel.org, Martin Bektchiev <martinb@gmail.com>,
Martin Bektchiev <martin.bektchiev@progress.com>
Subject: Re: [PATCH] commit: correctly escape @ of stashes
Date: Wed, 08 Jul 2020 13:53:56 -0700 [thread overview]
Message-ID: <xmqqo8op20ez.fsf@gitster.c.googlers.com> (raw)
In-Reply-To: <nycvar.QRO.7.76.6.2007070114060.50@tvgsbejvaqbjf.bet> (Johannes Schindelin's message of "Tue, 7 Jul 2020 01:14:59 +0200 (CEST)")
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
>> 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.
>
> The problem is visible when you have more than one stash. If
> you press TABm autocompletion stops at the `{` and if you then
> press TAB once more for a list of all stashes instead of that
> the completion changes to `stashstash{` and becomes broken at
> this point.
That does not reproduce for me.
$ git stash show stas<TAB>
completes to
$ git stash show stash@{
and any more <TAB> changes the command line, which is what I expect,
as it would be stupid to offer stash@{0} and stash@{1} (and others)
as possible completion candidates.
Also I just tried this (manually)
$ git stash show stash\@{<TAB>
and did not get any more extra completion.
$ set | grep ^BASH_VERSION=
BASH_VERSION='5.0.16(1)-release'
As long as the change does not make things worse for users of newer
bash, it is OK to make things better for users of ancient versions
of bash. It might already be considered a worse end-user experience
than what we have now to show partly-spelled stash reference as
"stash\@{" with backslash, though.
Another thing I noticed is that you shouldn't need two separate
processes of "sed" to do what you want to do.
>> > @@ -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/@/\\@/')"
The first and the original one -n -e "s/:.*//p" wants to show no
lines by default, unless it finds a colon on the line and strip it
and everything that follows. You then further want to tweak that
and prefix a backslash before the first '@' you find. So perhaps
something along the lines of...
sed -n -e '/:/{
s/:.*//
s/@/\\@/
p
}'
... which is "show no lines by default, but on a line with a colon,
strip the colon and everything that follows, and then prefix the
first '@' on the line, if exists, with backslash, and show the result".
Having said that, I am very skeptical to any "solution" that has to
show "stash\@{" to end-users. And with the patch, newer versions of
bash does seem to show the stupid "all stash entries, numbered",
i.e.
$ git stash show stas<TAB>
-->
$ git stash show stash\@{
$ git stash show stash\@{<TAB>
stash\@{0} stash\@{1}
I wonder what unpleasant end-user experience I may have to endure if
I had dozens of stash entries. The list shows only the numbers, so
it does not help me decide which number to type at all.
A solution to allow older versions of bash to complete
$ git stash show stas<TAB>
-->
$ git stash show stash@{
$ git stash show stash@{<TAB>
-->
$ git stash show stash@{
would be very much welcomed, though.
Thanks.
next prev parent reply other threads:[~2020-07-08 20:54 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
2020-07-06 23:14 ` Johannes Schindelin
2020-07-08 20:53 ` Junio C Hamano [this message]
[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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqo8op20ez.fsf@gitster.c.googlers.com \
--to=gitster@pobox.com \
--cc=Johannes.Schindelin@gmx.de \
--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.
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 NNTP newsgroup(s).