* [PATCH] commit: correctly escape @ of stashes @ 2020-07-03 9:30 Martin Bektchiev via GitGitGadget 2020-07-06 6:39 ` Junio C Hamano 0 siblings, 1 reply; 5+ messages in thread From: Martin Bektchiev via GitGitGadget @ 2020-07-03 9:30 UTC (permalink / raw) To: git; +Cc: Martin Bektchiev, Martin Bektchiev From: Martin Bektchiev <martin.bektchiev@progress.com> 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 <martin.bektchiev@progress.com> --- 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 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] commit: correctly escape @ of stashes 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 0 siblings, 1 reply; 5+ messages in thread From: Junio C Hamano @ 2020-07-06 6:39 UTC (permalink / raw) To: Martin Bektchiev via GitGitGadget; +Cc: git, Martin Bektchiev, Martin Bektchiev "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 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] commit: correctly escape @ of stashes 2020-07-06 6:39 ` Junio C Hamano @ 2020-07-06 23:14 ` Johannes Schindelin 2020-07-08 20:53 ` Junio C Hamano 0 siblings, 1 reply; 5+ messages in thread From: Johannes Schindelin @ 2020-07-06 23:14 UTC (permalink / raw) To: Junio C Hamano Cc: Martin Bektchiev via GitGitGadget, git, Martin Bektchiev, Martin Bektchiev Mirroring https://github.com/git/git/pull/815#issuecomment-654683996 manually, as I lack the time to figure out why Martin's mails don't make it to the mailing list: Hi Junio, Thank you for reviewing this patch! I've amended and pushed the branch and you can find my comments inline: > "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. 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. > > > @@ -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. Fixed. > > > fi > > ;; > > show,*|apply,*|drop,*|pop,*) > > __gitcomp_nl "$(__git stash list \ > > - | sed -n -e 's/:.*//p')" > > + | sed -n -e 's/:.*//p' \ > > + | sed 's/@/\\@/')" > > Ditto. Fixed. > > > ;; > > *) > > ;; > > > > base-commit: a08a83db2bf27f015bec9a435f6d73e223c21c5e > P.S. I responded with `git send-email` but since I still cannot see my email received it might have not been sent successfully. Hopefully you'll see my comment here ... -- You are receiving this because you commented. Reply to this email directly or view it on GitHub: https://github.com/git/git/pull/815#issuecomment-654683996 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] commit: correctly escape @ of stashes 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> 0 siblings, 1 reply; 5+ messages in thread From: Junio C Hamano @ 2020-07-08 20:53 UTC (permalink / raw) To: Martin Bektchiev via GitGitGadget Cc: Johannes Schindelin, git, Martin Bektchiev, Martin Bektchiev 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. ^ permalink raw reply [flat|nested] 5+ messages in thread
[parent not found: <CAEVR=HRrtT-vae8edN=Ltnp=amApMfUrt0j+6guWYMWZyz8Ohw@mail.gmail.com>]
* Re: [PATCH] commit: correctly escape @ of stashes [not found] ` <CAEVR=HRrtT-vae8edN=Ltnp=amApMfUrt0j+6guWYMWZyz8Ohw@mail.gmail.com> @ 2020-07-09 9:13 ` Johannes Schindelin 0 siblings, 0 replies; 5+ messages in thread From: Johannes Schindelin @ 2020-07-09 9:13 UTC (permalink / raw) To: martinb Cc: Junio C Hamano, Martin Bektchiev via GitGitGadget, git, Martin Bektchiev Hi Martin, On Thu, 9 Jul 2020, martinb wrote: > Ok, then I think it's best if I just close this PR. I didn't know that it > worked alright in newer versions of BASH. And I haven't found a way to make > it work without the escaping of @. It seems that the patch doesn't bring > any value to the community after all... > > Cheers and thanks once more for the review and insights! > > Best wishes, > Martin I think I figured out why it does not arrive at the Git mailing list. The mailing list administrators installed a rule where HTML mails are rejected, and your mail came with a plain text _and_ an HTML part. So it was rejected. Ciao, Johannes > > On Wed, Jul 8, 2020, 23:54 Junio C Hamano <gitster@pobox.com> wrote: > > > 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. > > > > > > > ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-07-09 9:13 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 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 [not found] ` <CAEVR=HRrtT-vae8edN=Ltnp=amApMfUrt0j+6guWYMWZyz8Ohw@mail.gmail.com> 2020-07-09 9:13 ` Johannes Schindelin
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).