prompt: fix show upstream with svn and zsh
PATCH 1/1 prompt: fix show upstream with svn and zsh
Currently the __git_ps1 git prompt gives the following error with a repository converted by git-svn, when used with zsh:
__git_ps1_show_upstream:19: bad pattern: svn_remote[
This was introduced by 6d158cba (bash completion: Support "divergence from upstream" messages in __git_ps1), when the script was for bash only. Make it compatible with zsh.
---
Tested with bash 4.2.45 and zsh 5.0.2.
contrib/completion/git-prompt.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
contrib/completion/git-prompt.sh +3 -3
@@ -124,7 +124,7 @@ __git_ps1_show_upstream () fi ;; svn-remote.*.url) - svn_remote[ $((${#svn_remote[@]} + 1)) ]="$value" + svn_remote[$((${#svn_remote[@]} + 1))]="$value" svn_url_pattern+="\\|$value" upstream=svn+git # default upstream is SVN if available, else git ;;
@@ -146,8 +146,8 @@ __git_ps1_show_upstream () svn*) # get the upstream from the "git-svn-id: ..." in a commit message # (git-svn uses essentially the same procedure internally) - local svn_upstream=($(git log --first-parent -1 \ - --grep="^git-svn-id: \(${svn_url_pattern#??}\)" 2>/dev/null)) + set -a svn_upstream "$(git log --first-parent -1 \ + --grep="^git-svn-id: \(${svn_url_pattern#??}\)" 2>/dev/null)" if [[ 0 -ne ${#svn_upstream[@]} ]]; then svn_upstream=${svn_upstream[ ${#svn_upstream[@]} - 2 ]} svn_upstream=${svn_upstream%@*}
Signature · 1 line
1.8.3.rc2.359.g2fb82f5
PATCH v2 1/1 prompt: fix show upstream with svn and zsh
Currently the __git_ps1 git prompt gives the following error with a repository converted by git-svn, when used with zsh:
__git_ps1_show_upstream:19: bad pattern: svn_remote[ __git_ps1_show_upstream:45: bad substitution
To reproduce the problem, the __git_ps1_show_upstream function can be executed in a repository converted with git-svn. Both those errors are triggered by spaces after the '['.
Zsh also doesn't support initializing an array with local var=(...). This triggers the following error:
__git_ps1_show_upstream:41: bad pattern: svn_upstream=(commit
Use
local -a
var=(...)
instead to make is compatible.
This was introduced by 6d158cba (bash completion: Support "divergence from upstream" messages in __git_ps1), when the script was for bash only.
--- contrib/completion/git-prompt.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
contrib/completion/git-prompt.sh +4 -3
@@ -124,7 +124,7 @@ __git_ps1_show_upstream () fi ;; svn-remote.*.url) - svn_remote[ $((${#svn_remote[@]} + 1)) ]="$value" + svn_remote[$((${#svn_remote[@]} + 1))]="$value" svn_url_pattern+="\\|$value" upstream=svn+git # default upstream is SVN if available, else git ;;
@@ -146,10 +146,11 @@ __git_ps1_show_upstream () svn*) # get the upstream from the "git-svn-id: ..." in a commit message # (git-svn uses essentially the same procedure internally) - local svn_upstream=($(git log --first-parent -1 \ + local -a svn_upstream + svn_upstream=($(git log --first-parent -1 \ --grep="^git-svn-id: \(${svn_url_pattern#??}\)" 2>/dev/null)) if [[ 0 -ne ${#svn_upstream[@]} ]]; then - svn_upstream=${svn_upstream[ ${#svn_upstream[@]} - 2 ]} + svn_upstream=${svn_upstream[${#svn_upstream[@]} - 2]} svn_upstream=${svn_upstream%@*} local n_stop="${#svn_remote[@]}" for ((n=1; n <= n_stop; n++)); do
Signature · 1 line
1.8.3.rc2.359.g2fb82f5
Quoted 20 lines · Thomas Gummerer
Currently the
__git_ps1git prompt gives the following error with a repository converted by git-svn, when used with zsh:__git_ps1_show_upstream:19: bad pattern: svn_remote[ __git_ps1_show_upstream:45: bad substitution
To reproduce the problem, the
__git_ps1_show_upstreamfunction can be executed in a repository converted with git-svn. Both those errors are triggered by spaces after the '['.Zsh also doesn't support initializing an array with
local var=(...). This triggers the following error:__git_ps1_show_upstream:41: bad pattern: svn_upstream=(commit
Use
local -a
var=(...)
instead to make is compatible.
Quoted 5 lines
This was introduced by
6d158cba(bash completion: Support "divergence from upstream" messages in__git_ps1), when the script was for bash only.Signed-off-by Thomas Gummerer <[email protected]>
I think there's no need to be so verbose in the commit message, but hey, that's just an opinion.
Signature · 1 line
Felipe Contreras
Hi,
Quoted 8 lines · Thomas Gummerer
Currently the
__git_ps1git prompt gives the following error with a repository converted by git-svn, when used with zsh:__git_ps1_show_upstream:19: bad pattern: svn_remote[
This was introduced by
6d158cba(bash completion: Support "divergence from upstream" messages in__git_ps1), when the script was for bash only. Make it compatible with zsh.
What is the actual cause of this problem/incompatibility and how/why do these changes fix it?
contrib/completion/git-prompt.sh __git_ps1_show_upstream () · line 127
Quoted 2 lines
contrib/completion/git-prompt.sh +1
-1- svn_remote[ $((${#svn_remote[@]} + 1)) ]="$value" + svn_remote[$((${#svn_remote[@]} + 1))]="$value"
I mean, did zsh really complained because of the space after the '[' ?!
contrib/completion/git-prompt.sh __git_ps1_show_upstream () · line 152
Quoted 10 lines
contrib/completion/git-prompt.sh +2
-2@@ -146,8 +146,8 @@ __git_ps1_show_upstream () svn*) # get the upstream from the "git-svn-id: ..." in a commit message # (git-svn uses essentially the same procedure internally) - local svn_upstream=($(git log --first-parent -1 \ - --grep="^git-svn-id: \(${svn_url_pattern#??}\)" 2>/dev/null)) + set -a svn_upstream "$(git log --first-parent -1 \ + --grep="^git-svn-id: \(${svn_url_pattern#??}\)" 2>/dev/null)" if [[ 0 -ne ${#svn_upstream[@]} ]]; then svn_upstream=${svn_upstream[ ${#svn_upstream[@]} - 2 ]}
If so, then what about this one?
Best,
Gábor
Quoted 13 lines · SZEDER Gábor
Hi,
Quoted 8 lines · Thomas Gummerer
Currently the
__git_ps1git prompt gives the following error with a repository converted by git-svn, when used with zsh:__git_ps1_show_upstream:19: bad pattern: svn_remote[
This was introduced by
6d158cba(bash completion: Support "divergence from upstream" messages in__git_ps1), when the script was for bash only. Make it compatible with zsh.
Quoted 7 lines
What is the actual cause of this problem/incompatibility and how/why do these changes fix it?
contrib/completion/git-prompt.sh __git_ps1_show_upstream () · line 127
Quoted 2 lines
contrib/completion/git-prompt.sh +1
-1- svn_remote[ $((${#svn_remote[@]} + 1)) ]="$value" + svn_remote[$((${#svn_remote[@]} + 1))]="$value"I mean, did zsh really complained because of the space after the '[' ?!
Yes, removing the spaces after the '[' fixes the problem. I'm not very proficient in shell scripting, so I can't tell if there is another cause.
Quoted 4 lines
Quoted 4 lines
contrib/completion/git-prompt.sh +0
-0@@ -146,8 +146,8 @@ __git_ps1_show_upstream () svn*) # get the upstream from the "git-svn-id: ..." in a commit message # (git-svn uses essentially the same procedure internally)
Quoted 8 lines
contrib/completion/git-prompt.sh __git_ps1_show_upstream () · line 152
Quoted 6 lines
contrib/completion/git-prompt.sh +2
-2- local svn_upstream=($(git log --first-parent -1 \ - --grep="^git-svn-id: \(${svn_url_pattern#??}\)" 2>/dev/null)) + set -a svn_upstream "$(git log --first-parent -1 \ + --grep="^git-svn-id: \(${svn_url_pattern#??}\)" 2>/dev/null)" if [[ 0 -ne ${#svn_upstream[@]} ]]; then svn_upstream=${svn_upstream[ ${#svn_upstream[@]} - 2 ]}If so, then what about this one?
You're right, this line gives an error too, the code just wasn't following that path before. I'll fix it in the re-roll. Other than those two I couldn't spot any other occurrence of this pattern.
Quoted 2 lines
Best,
Gábor
Thanks,
Thomas
Hi,
Quoted 10 lines · Thomas Gummerer
Quoted 5 lines · SZEDER Gábor
contrib/completion/git-prompt.sh __git_ps1_show_upstream () · line 127
Quoted 2 lines · Thomas Gummerer
contrib/completion/git-prompt.sh +1
-1- svn_remote[ $((${#svn_remote[@]} + 1)) ]="$value" + svn_remote[$((${#svn_remote[@]} + 1))]="$value"I mean, did zsh really complained because of the space after the '[' ?!
Yes, removing the spaces after the '[' fixes the problem. I'm not very proficient in shell scripting, so I can't tell if there is another cause.
Thanks. I first suspected that this was just an independent style cleanup, that's why I asked for clarification.
Gábor
Quoted 4 lines · SZEDER Gábor
Quoted 3 lines · Thomas Gummerer
Currently the
__git_ps1git prompt gives the following error with a repository converted by git-svn, when used with zsh:
Quoted 8 lines
Quoted 5 lines
__git_ps1_show_upstream:19: bad pattern: svn_remote[
This was introduced by
6d158cba(bash completion: Support "divergence from upstream" messages in__git_ps1), when the script was for bash only. Make it compatible with zsh.What is the actual cause of this problem/incompatibility and how/why do these changes fix it?
I think the commit message makes that very clear.
Signature · 1 line
Felipe Contreras
Quoted 8 lines · Felipe Contreras
Quoted 6 lines · SZEDER Gábor
Quoted 5 lines · Thomas Gummerer
Currently the
__git_ps1git prompt gives the following error with a repository converted by git-svn, when used with zsh:__git_ps1_show_upstream:19: bad pattern: svn_remote[
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
This was introduced by
6d158cba(bash completion: Support "divergence from upstream" messages in__git_ps1), when the script was for bash only. Make it compatible with zsh.What is the actual cause of this problem/incompatibility and how/why do these changes fix it?
I think the commit message makes that very clear.
If that were the case I wouldn't have asked in the first place.
Hth,
Gábor
Quoted 13 lines · SZEDER Gábor
Quoted 12 lines · Felipe Contreras
Quoted 10 lines · SZEDER Gábor
Quoted 8 lines · Thomas Gummerer
Currently the
__git_ps1git prompt gives the following error with a repository converted by git-svn, when used with zsh:__git_ps1_show_upstream:19: bad pattern: svn_remote[
This was introduced by
6d158cba(bash completion: Support "divergence from upstream" messages in__git_ps1), when the script was for bash only. Make it compatible with zsh.
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
What is the actual cause of this problem/incompatibility and how/why do these changes fix it?
I think the commit message makes that very clear.
If that were the case I wouldn't have asked in the first place.
You are not the authority on what *I think*, or if you meant s/If that were the case/If the message was clear/, still; you are not the authority on what is or is not true. Only on what is your opinion.
Signature · 1 line
Felipe Contreras
Quoted 17 lines · Felipe Contreras
Quoted 16 lines · SZEDER Gábor
Quoted 15 lines · Felipe Contreras
Quoted 12 lines · SZEDER Gábor
Quoted 8 lines · Thomas Gummerer
Currently the
__git_ps1git prompt gives the following error with a repository converted by git-svn, when used with zsh:__git_ps1_show_upstream:19: bad pattern: svn_remote[
This was introduced by
6d158cba(bash completion: Support "divergence from upstream" messages in__git_ps1), when the script was for bash only. Make it compatible with zsh.What is the actual cause of this problem/incompatibility and how/why do these changes fix it?
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
I think the commit message makes that very clear.
If that were the case I wouldn't have asked in the first place.
You are not the authority on what *I think*, or if you meant s/If that were the case/If the message was clear/, still; you are not the authority on what is or is not true. Only on what is your opinion.
I would have preferred a more constructive reply, perhaps with answers to the questions I asked earlier...
Bye,
Gábor
Quoted 20 lines · SZEDER Gábor
Quoted 19 lines · Felipe Contreras
Quoted 18 lines · SZEDER Gábor
Quoted 16 lines · Felipe Contreras
Quoted 4 lines · SZEDER Gábor
Quoted 3 lines · Thomas Gummerer
Currently the
__git_ps1git prompt gives the following error with a repository converted by git-svn, when used with zsh:Quoted 8 lines
Quoted 5 lines
__git_ps1_show_upstream:19: bad pattern: svn_remote[
This was introduced by
6d158cba(bash completion: Support "divergence from upstream" messages in__git_ps1), when the script was for bash only. Make it compatible with zsh.What is the actual cause of this problem/incompatibility and how/why do these changes fix it?
I think the commit message makes that very clear.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
If that were the case I wouldn't have asked in the first place.
You are not the authority on what *I think*, or if you meant s/If that were the case/If the message was clear/, still; you are not the authority on what is or is not true. Only on what is your opinion.
I would have preferred a more constructive reply, perhaps with answers to the questions I asked earlier...
That's the job of the patch submitter, all I did was express my option about the commit message. You have no say as to what is my option.
You are the one not being constructive by claiming that all opinions contrary to yours are wrong.
Signature · 1 line
Felipe Contreras
Quoted 27 lines · Felipe Contreras
Quoted 26 lines · SZEDER Gábor
Quoted 24 lines · Felipe Contreras
Quoted 13 lines · SZEDER Gábor
Quoted 12 lines · Felipe Contreras
Quoted 10 lines · SZEDER Gábor
Quoted 8 lines · Thomas Gummerer
Currently the
__git_ps1git prompt gives the following error with a repository converted by git-svn, when used with zsh:__git_ps1_show_upstream:19: bad pattern: svn_remote[
This was introduced by
6d158cba(bash completion: Support "divergence from upstream" messages in__git_ps1), when the script was for bash only. Make it compatible with zsh.Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
What is the actual cause of this problem/incompatibility and how/why do these changes fix it?
I think the commit message makes that very clear.
If that were the case I wouldn't have asked in the first place.
You are not the authority on what *I think*, or if you meant s/If that were the case/If the message was clear/, still; you are not the authority on what is or is not true. Only on what is your opinion.
Quoted 8 lines
Quoted 2 lines
I would have preferred a more constructive reply, perhaps with answers to the questions I asked earlier...
That's the job of the patch submitter, all I did was express my option about the commit message. You have no say as to what is my option.
You are the one not being constructive by claiming that all opinions contrary to yours are wrong.
Seriously!? Alright, I won't waste any more time on this, sorry.
Gábor
Quoted 10 lines · Thomas Gummerer
Currently the
__git_ps1git prompt gives the following error with a repository converted by git-svn, when used with zsh:__git_ps1_show_upstream:19: bad pattern: svn_remote[
This was introduced by
6d158cba(bash completion: Support "divergence from upstream" messages in__git_ps1), when the script was for bash only. Make it compatible with zsh.Signed-off-by Thomas Gummerer <[email protected]>
This patch is fine by me. I would like to see an example of how to trigger the issue with a standalone command in the commit message, but it's not necessary. It would also make sense to address the comment from Szeder that does raise questions about other places in the code where 'array[ $foo ]' is used, maybe there's a caveat we are not considering, or maybe your use-case did not execute that code.
And finally, I don't recall seen 'set -a' used elsewhere in the code. If memory serves well, we have replaced 'local -a foo=value' with 'local -a foo\nfoo=value' before to fix zsh issues, I think that would be safer.
But this patch is needed regardless, that, or the patch that broke things should be reverted for v1.8.3.
Thomas, if you don't have time, let me know and I can take a look.
Cheers.
Signature · 1 line
Felipe Contreras
Quoted 10 lines · Felipe Contreras
Quoted 9 lines · Thomas Gummerer
Currently the
__git_ps1git prompt gives the following error with a repository converted by git-svn, when used with zsh:__git_ps1_show_upstream:19: bad pattern: svn_remote[
This was introduced by
6d158cba(bash completion: Support "divergence from upstream" messages in__git_ps1), when the script was for bash only. Make it compatible with zsh.
Quoted 8 lines
Quoted 1 line
Signed-off-by Thomas Gummerer <[email protected]>This patch is fine by me. I would like to see an example of how to trigger the issue with a standalone command in the commit message, but it's not necessary. It would also make sense to address the comment from Szeder that does raise questions about other places in the code where 'array[ $foo ]' is used, maybe there's a caveat we are not considering, or maybe your use-case did not execute that code.
Yes, the code was not executed, it will be fixed in the re-roll.
Quoted 4 lines
And finally, I don't recall seen 'set -a' used elsewhere in the code. If memory serves well, we have replaced 'local -a foo=value' with 'local -a foo\nfoo=value' before to fix zsh issues, I think that would be safer.
Yes, thanks for the suggestion, that works.
Quoted 2 lines
But this patch is needed regardless, that, or the patch that broke things should be reverted for v1.8.3.
I don't think anything should or can be reverted, as this code was introduced in 2010, but nobody triggered it until now.
Quoted 6 lines
Thomas, if you don't have time, let me know and I can take a look.
Cheers.
--
Felipe Contreras
Thanks,
Thomas