From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: Doron Behar <doron.behar@gmail.com>
Cc: zsh-workers@zsh.org
Subject: Re: [BUG] vcs_info - git branch with % in it's name
Date: Mon, 25 Dec 2017 20:17:28 +0000 [thread overview]
Message-ID: <20171225201728.6e2iwqm5loqbbjsr@tarpaulin.shahaf.local2> (raw)
In-Reply-To: <20171225093306.6druy3zqyjx2rcyr@NUC.localdomain>
Doron Behar wrote on Mon, 25 Dec 2017 11:33 +0200:
> I think I found a bug within zsh's module vcs_info.
>
> If a user is in a git repository with a '%' as part of the name of the
> branch and he has '%b' in his prompt, he might get weird results, like:
>
> doron bla9269ello ~/repos/abcde
>
> Instead of:
>
> doron bla%ello ~/repos/abcde
>
> Has anyone encountered this before? I wonder why it happens..
Prompt expansions and zformat both use % as an expando introducer. This is
basically the same form of bug as doing *«printf(argv[1])» in C. %h is:
%h
%! Current history event number.
(Incidentally, it is missing from «print -P %<TAB>» completion)
How about the following? If that is the right fix then the adjacent lines will
need similar tweaking.
diff --git a/Functions/VCS_Info/VCS_INFO_formats b/Functions/VCS_Info/VCS_INFO_formats
index 4d0dd75c2..a46a10286 100644
--- a/Functions/VCS_Info/VCS_INFO_formats
+++ b/Functions/VCS_Info/VCS_INFO_formats
@@ -81,7 +81,7 @@ for i in {1..${#msgs}} ; do
if VCS_INFO_hook "set-message" $(( $i - 1 )) "${msgs[$i]}"; then
zformat -f msg ${msgs[$i]} \
a:${hook_com[action]} \
- b:${hook_com[branch]} \
+ b:${hook_com[branch]//'%'/%%} \
c:${hook_com[staged]} \
i:${hook_com[revision]} \
m:${hook_com[misc]} \
Cheers,
Daniel
next prev parent reply other threads:[~2017-12-25 20:17 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-25 9:33 Doron Behar
2017-12-25 20:17 ` Daniel Shahaf [this message]
2017-12-30 8:56 ` Daniel Shahaf
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=20171225201728.6e2iwqm5loqbbjsr@tarpaulin.shahaf.local2 \
--to=d.s@daniel.shahaf.name \
--cc=doron.behar@gmail.com \
--cc=zsh-workers@zsh.org \
/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://git.vuxu.org/mirror/zsh/
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).