{"thread":{"id":"33889","subject":"[PATCH] prompt: fix show upstream with svn and zsh","startedAt":"2013-05-21T20:54:27Z","lastAt":"2013-05-28T10:30:50Z","messageCount":14,"participants":["Thomas Gummerer","SZEDER Gábor","Felipe Contreras"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"218093","messageId":"1369169667-25166-1-git-send-email-t.gummerer@gmail.com","threadId":"33889","inReplyTo":null,"subject":"[PATCH] prompt: fix show upstream with svn and zsh","fromName":"Thomas Gummerer","fromEmail":"t.gummerer@gmail.com","sentAt":"2013-05-21T20:54:27Z","receivedAt":"2013-05-21T20:54:27Z","isPatch":true,"sender":{"key":"t.gummerer@gmail.com","avatar":"https://avatars.githubusercontent.com/u/191004?v=4"},"body":"Currently the __git_ps1 git prompt gives the following error with a\nrepository converted by git-svn, when used with zsh:\n\n\t   __git_ps1_show_upstream:19: bad pattern: svn_remote[\n\nThis was introduced by 6d158cba (bash completion: Support \"divergence\nfrom upstream\" messages in __git_ps1), when the script was for bash\nonly.  Make it compatible with zsh.\n\nSigned-off-by: Thomas Gummerer <t.gummerer@gmail.com>\n---\nTested with bash 4.2.45 and zsh 5.0.2.\n\n contrib/completion/git-prompt.sh | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh\nindex eaf5c36..e537300 100644\n--- a/contrib/completion/git-prompt.sh\n+++ b/contrib/completion/git-prompt.sh\n@@ -124,7 +124,7 @@ __git_ps1_show_upstream ()\n \t\t\tfi\n \t\t\t;;\n \t\tsvn-remote.*.url)\n-\t\t\tsvn_remote[ $((${#svn_remote[@]} + 1)) ]=\"$value\"\n+\t\t\tsvn_remote[$((${#svn_remote[@]} + 1))]=\"$value\"\n \t\t\tsvn_url_pattern+=\"\\\\|$value\"\n \t\t\tupstream=svn+git # default upstream is SVN if available, else git\n \t\t\t;;\n@@ -146,8 +146,8 @@ __git_ps1_show_upstream ()\n \tsvn*)\n \t\t# get the upstream from the \"git-svn-id: ...\" in a commit message\n \t\t# (git-svn uses essentially the same procedure internally)\n-\t\tlocal svn_upstream=($(git log --first-parent -1 \\\n-\t\t\t\t\t--grep=\"^git-svn-id: \\(${svn_url_pattern#??}\\)\" 2>/dev/null))\n+\t\tset -a svn_upstream \"$(git log --first-parent -1 \\\n+\t\t\t\t\t--grep=\"^git-svn-id: \\(${svn_url_pattern#??}\\)\" 2>/dev/null)\"\n \t\tif [[ 0 -ne ${#svn_upstream[@]} ]]; then\n \t\t\tsvn_upstream=${svn_upstream[ ${#svn_upstream[@]} - 2 ]}\n \t\t\tsvn_upstream=${svn_upstream%@*}\n-- \n1.8.3.rc2.359.g2fb82f5\n"},{"id":"218107","messageId":"20130521224119.GF30969@goldbirke","threadId":"33889","inReplyTo":"1369169667-25166-1-git-send-email-t.gummerer@gmail.com","subject":"Re: [PATCH] prompt: fix show upstream with svn and zsh","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2013-05-21T22:41:19Z","receivedAt":"2013-05-21T22:41:19Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"Hi,\n\n\nOn Tue, May 21, 2013 at 10:54:27PM +0200, Thomas Gummerer wrote:\n> Currently the __git_ps1 git prompt gives the following error with a\n> repository converted by git-svn, when used with zsh:\n> \n> \t   __git_ps1_show_upstream:19: bad pattern: svn_remote[\n> \n> This was introduced by 6d158cba (bash completion: Support \"divergence\n> from upstream\" messages in __git_ps1), when the script was for bash\n> only.  Make it compatible with zsh.\n\nWhat is the actual cause of this problem/incompatibility and how/why do\nthese changes fix it?\n\n> -\t\t\tsvn_remote[ $((${#svn_remote[@]} + 1)) ]=\"$value\"\n> +\t\t\tsvn_remote[$((${#svn_remote[@]} + 1))]=\"$value\"\n\nI mean, did zsh really complained because of the space after the '[' ?!\n\n> @@ -146,8 +146,8 @@ __git_ps1_show_upstream ()\n>  \tsvn*)\n>  \t\t# get the upstream from the \"git-svn-id: ...\" in a commit message\n>  \t\t# (git-svn uses essentially the same procedure internally)\n> -\t\tlocal svn_upstream=($(git log --first-parent -1 \\\n> -\t\t\t\t\t--grep=\"^git-svn-id: \\(${svn_url_pattern#??}\\)\" 2>/dev/null))\n> +\t\tset -a svn_upstream \"$(git log --first-parent -1 \\\n> +\t\t\t\t\t--grep=\"^git-svn-id: \\(${svn_url_pattern#??}\\)\" 2>/dev/null)\"\n>  \t\tif [[ 0 -ne ${#svn_upstream[@]} ]]; then\n>  \t\t\tsvn_upstream=${svn_upstream[ ${#svn_upstream[@]} - 2 ]}\n\nIf so, then what about this one?\n\n\nBest,\nGábor\n"},{"id":"218109","messageId":"CAMP44s1cbO-xzUAHR4THz4MPdqxY6SHG7uf_da_OM8YCDbTi+A@mail.gmail.com","threadId":"33889","inReplyTo":"20130521224119.GF30969@goldbirke","subject":"Re: [PATCH] prompt: fix show upstream with svn and zsh","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-21T23:04:35Z","receivedAt":"2013-05-21T23:04:35Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"On Tue, May 21, 2013 at 5:41 PM, SZEDER Gábor <szeder@ira.uka.de> wrote:\n\n> On Tue, May 21, 2013 at 10:54:27PM +0200, Thomas Gummerer wrote:\n>> Currently the __git_ps1 git prompt gives the following error with a\n>> repository converted by git-svn, when used with zsh:\n>>\n>>          __git_ps1_show_upstream:19: bad pattern: svn_remote[\n>>\n>> This was introduced by 6d158cba (bash completion: Support \"divergence\n>> from upstream\" messages in __git_ps1), when the script was for bash\n>> only.  Make it compatible with zsh.\n>\n> What is the actual cause of this problem/incompatibility and how/why do\n> these changes fix it?\n\nI think the commit message makes that very clear.\n\n-- \nFelipe Contreras\n"},{"id":"218113","messageId":"20130521233617.GG30969@goldbirke","threadId":"33889","inReplyTo":"CAMP44s1cbO-xzUAHR4THz4MPdqxY6SHG7uf_da_OM8YCDbTi+A@mail.gmail.com","subject":"Re: [PATCH] prompt: fix show upstream with svn and zsh","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2013-05-21T23:36:17Z","receivedAt":"2013-05-21T23:36:17Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"On Tue, May 21, 2013 at 06:04:35PM -0500, Felipe Contreras wrote:\n> On Tue, May 21, 2013 at 5:41 PM, SZEDER Gábor <szeder@ira.uka.de> wrote:\n> \n> > On Tue, May 21, 2013 at 10:54:27PM +0200, Thomas Gummerer wrote:\n> >> Currently the __git_ps1 git prompt gives the following error with a\n> >> repository converted by git-svn, when used with zsh:\n> >>\n> >>          __git_ps1_show_upstream:19: bad pattern: svn_remote[\n> >>\n> >> This was introduced by 6d158cba (bash completion: Support \"divergence\n> >> from upstream\" messages in __git_ps1), when the script was for bash\n> >> only.  Make it compatible with zsh.\n> >\n> > What is the actual cause of this problem/incompatibility and how/why do\n> > these changes fix it?\n> \n> I think the commit message makes that very clear.\n\nIf that were the case I wouldn't have asked in the first place.\n\nHth,\nGábor\n"},{"id":"218114","messageId":"CAMP44s3nMSj5=pr-WmWTd_iUjK4iU_8KnOKHYgRHLAQyyMH9bA@mail.gmail.com","threadId":"33889","inReplyTo":"20130521233617.GG30969@goldbirke","subject":"Re: [PATCH] prompt: fix show upstream with svn and zsh","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-22T00:03:09Z","receivedAt":"2013-05-22T00:03:09Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"On Tue, May 21, 2013 at 6:36 PM, SZEDER Gábor <szeder@ira.uka.de> wrote:\n> On Tue, May 21, 2013 at 06:04:35PM -0500, Felipe Contreras wrote:\n>> On Tue, May 21, 2013 at 5:41 PM, SZEDER Gábor <szeder@ira.uka.de> wrote:\n>>\n>> > On Tue, May 21, 2013 at 10:54:27PM +0200, Thomas Gummerer wrote:\n>> >> Currently the __git_ps1 git prompt gives the following error with a\n>> >> repository converted by git-svn, when used with zsh:\n>> >>\n>> >>          __git_ps1_show_upstream:19: bad pattern: svn_remote[\n>> >>\n>> >> This was introduced by 6d158cba (bash completion: Support \"divergence\n>> >> from upstream\" messages in __git_ps1), when the script was for bash\n>> >> only.  Make it compatible with zsh.\n>> >\n>> > What is the actual cause of this problem/incompatibility and how/why do\n>> > these changes fix it?\n>>\n>> I think the commit message makes that very clear.\n>\n> If that were the case I wouldn't have asked in the first place.\n\nYou are not the authority on what *I think*, or if you meant s/If that\nwere the case/If the message was clear/, still; you are not the\nauthority on what is or is not true. Only on what is your opinion.\n\n-- \nFelipe Contreras\n"},{"id":"218115","messageId":"20130522002028.GH30969@goldbirke","threadId":"33889","inReplyTo":"CAMP44s3nMSj5=pr-WmWTd_iUjK4iU_8KnOKHYgRHLAQyyMH9bA@mail.gmail.com","subject":"Re: [PATCH] prompt: fix show upstream with svn and zsh","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2013-05-22T00:20:28Z","receivedAt":"2013-05-22T00:20:28Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"On Tue, May 21, 2013 at 07:03:09PM -0500, Felipe Contreras wrote:\n> On Tue, May 21, 2013 at 6:36 PM, SZEDER Gábor <szeder@ira.uka.de> wrote:\n> > On Tue, May 21, 2013 at 06:04:35PM -0500, Felipe Contreras wrote:\n> >> On Tue, May 21, 2013 at 5:41 PM, SZEDER Gábor <szeder@ira.uka.de> wrote:\n> >>\n> >> > On Tue, May 21, 2013 at 10:54:27PM +0200, Thomas Gummerer wrote:\n> >> >> Currently the __git_ps1 git prompt gives the following error with a\n> >> >> repository converted by git-svn, when used with zsh:\n> >> >>\n> >> >>          __git_ps1_show_upstream:19: bad pattern: svn_remote[\n> >> >>\n> >> >> This was introduced by 6d158cba (bash completion: Support \"divergence\n> >> >> from upstream\" messages in __git_ps1), when the script was for bash\n> >> >> only.  Make it compatible with zsh.\n> >> >\n> >> > What is the actual cause of this problem/incompatibility and how/why do\n> >> > these changes fix it?\n> >>\n> >> I think the commit message makes that very clear.\n> >\n> > If that were the case I wouldn't have asked in the first place.\n> \n> You are not the authority on what *I think*, or if you meant s/If that\n> were the case/If the message was clear/, still; you are not the\n> authority on what is or is not true. Only on what is your opinion.\n\nI would have preferred a more constructive reply, perhaps with answers\nto the questions I asked earlier...\n\nBye,\nGábor\n"},{"id":"218117","messageId":"CAMP44s3XjJ8AxTAF3OEPDd-3egb9koogxheZj+KdUrvJDOjxmQ@mail.gmail.com","threadId":"33889","inReplyTo":"20130522002028.GH30969@goldbirke","subject":"Re: [PATCH] prompt: fix show upstream with svn and zsh","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-22T00:29:38Z","receivedAt":"2013-05-22T00:29:38Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"On Tue, May 21, 2013 at 7:20 PM, SZEDER Gábor <szeder@ira.uka.de> wrote:\n> On Tue, May 21, 2013 at 07:03:09PM -0500, Felipe Contreras wrote:\n>> On Tue, May 21, 2013 at 6:36 PM, SZEDER Gábor <szeder@ira.uka.de> wrote:\n>> > On Tue, May 21, 2013 at 06:04:35PM -0500, Felipe Contreras wrote:\n>> >> On Tue, May 21, 2013 at 5:41 PM, SZEDER Gábor <szeder@ira.uka.de> wrote:\n>> >>\n>> >> > On Tue, May 21, 2013 at 10:54:27PM +0200, Thomas Gummerer wrote:\n>> >> >> Currently the __git_ps1 git prompt gives the following error with a\n>> >> >> repository converted by git-svn, when used with zsh:\n>> >> >>\n>> >> >>          __git_ps1_show_upstream:19: bad pattern: svn_remote[\n>> >> >>\n>> >> >> This was introduced by 6d158cba (bash completion: Support \"divergence\n>> >> >> from upstream\" messages in __git_ps1), when the script was for bash\n>> >> >> only.  Make it compatible with zsh.\n>> >> >\n>> >> > What is the actual cause of this problem/incompatibility and how/why do\n>> >> > these changes fix it?\n>> >>\n>> >> I think the commit message makes that very clear.\n>> >\n>> > If that were the case I wouldn't have asked in the first place.\n>>\n>> You are not the authority on what *I think*, or if you meant s/If that\n>> were the case/If the message was clear/, still; you are not the\n>> authority on what is or is not true. Only on what is your opinion.\n>\n> I would have preferred a more constructive reply, perhaps with answers\n> to the questions I asked earlier...\n\nThat's the job of the patch submitter, all I did was express my option\nabout the commit message. You have no say as to what is my option.\n\nYou are the one not being constructive by claiming that all opinions\ncontrary to yours are wrong.\n\n-- \nFelipe Contreras\n"},{"id":"218118","messageId":"20130522004429.GI30969@goldbirke","threadId":"33889","inReplyTo":"CAMP44s3XjJ8AxTAF3OEPDd-3egb9koogxheZj+KdUrvJDOjxmQ@mail.gmail.com","subject":"Re: [PATCH] prompt: fix show upstream with svn and zsh","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2013-05-22T00:44:29Z","receivedAt":"2013-05-22T00:44:29Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"On Tue, May 21, 2013 at 07:29:38PM -0500, Felipe Contreras wrote:\n> On Tue, May 21, 2013 at 7:20 PM, SZEDER Gábor <szeder@ira.uka.de> wrote:\n> > On Tue, May 21, 2013 at 07:03:09PM -0500, Felipe Contreras wrote:\n> >> On Tue, May 21, 2013 at 6:36 PM, SZEDER Gábor <szeder@ira.uka.de> wrote:\n> >> > On Tue, May 21, 2013 at 06:04:35PM -0500, Felipe Contreras wrote:\n> >> >> On Tue, May 21, 2013 at 5:41 PM, SZEDER Gábor <szeder@ira.uka.de> wrote:\n> >> >>\n> >> >> > On Tue, May 21, 2013 at 10:54:27PM +0200, Thomas Gummerer wrote:\n> >> >> >> Currently the __git_ps1 git prompt gives the following error with a\n> >> >> >> repository converted by git-svn, when used with zsh:\n> >> >> >>\n> >> >> >>          __git_ps1_show_upstream:19: bad pattern: svn_remote[\n> >> >> >>\n> >> >> >> This was introduced by 6d158cba (bash completion: Support \"divergence\n> >> >> >> from upstream\" messages in __git_ps1), when the script was for bash\n> >> >> >> only.  Make it compatible with zsh.\n> >> >> >\n> >> >> > What is the actual cause of this problem/incompatibility and how/why do\n> >> >> > these changes fix it?\n> >> >>\n> >> >> I think the commit message makes that very clear.\n> >> >\n> >> > If that were the case I wouldn't have asked in the first place.\n> >>\n> >> You are not the authority on what *I think*, or if you meant s/If that\n> >> were the case/If the message was clear/, still; you are not the\n> >> authority on what is or is not true. Only on what is your opinion.\n> >\n> > I would have preferred a more constructive reply, perhaps with answers\n> > to the questions I asked earlier...\n> \n> That's the job of the patch submitter, all I did was express my option\n> about the commit message. You have no say as to what is my option.\n> \n> You are the one not being constructive by claiming that all opinions\n> contrary to yours are wrong.\n\nSeriously!?  Alright, I won't waste any more time on this, sorry.\n\nGábor\n"},{"id":"218141","messageId":"CAMP44s3uEaG3Y+cVoKhCA-f+hi1VZcCpXO5bYCQLvANDdvYwRA@mail.gmail.com","threadId":"33889","inReplyTo":"1369169667-25166-1-git-send-email-t.gummerer@gmail.com","subject":"Re: [PATCH] prompt: fix show upstream with svn and zsh","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-22T03:13:22Z","receivedAt":"2013-05-22T03:13:22Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"On Tue, May 21, 2013 at 3:54 PM, Thomas Gummerer <t.gummerer@gmail.com> wrote:\n> Currently the __git_ps1 git prompt gives the following error with a\n> repository converted by git-svn, when used with zsh:\n>\n>            __git_ps1_show_upstream:19: bad pattern: svn_remote[\n>\n> This was introduced by 6d158cba (bash completion: Support \"divergence\n> from upstream\" messages in __git_ps1), when the script was for bash\n> only.  Make it compatible with zsh.\n>\n> Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>\n\nThis patch is fine by me. I would like to see an example of how to\ntrigger the issue with a standalone command in the commit message, but\nit's not necessary. It would also make sense to address the comment\nfrom Szeder that does raise questions about other places in the code\nwhere 'array[ $foo ]' is used, maybe there's a caveat we are not\nconsidering, or maybe your use-case did not execute that code.\n\nAnd finally, I don't recall seen 'set -a' used elsewhere in the code.\nIf memory serves well, we have replaced 'local -a foo=value' with\n'local -a foo\\nfoo=value' before to fix zsh issues, I think that would\nbe safer.\n\nBut this patch is needed regardless, that, or the patch that broke\nthings should be reverted for v1.8.3.\n\nThomas, if you don't have time, let me know and I can take a look.\n\nCheers.\n\n-- \nFelipe Contreras\n"},{"id":"218150","messageId":"87a9nn31wj.fsf@gmail.com","threadId":"33889","inReplyTo":"20130521224119.GF30969@goldbirke","subject":"Re: [PATCH] prompt: fix show upstream with svn and zsh","fromName":"Thomas Gummerer","fromEmail":"t.gummerer@gmail.com","sentAt":"2013-05-22T07:32:44Z","receivedAt":"2013-05-22T07:32:44Z","isPatch":true,"sender":{"key":"t.gummerer@gmail.com","avatar":"https://avatars.githubusercontent.com/u/191004?v=4"},"body":"SZEDER Gábor <szeder@ira.uka.de> writes:\n\n> Hi,\n>\n>\n> On Tue, May 21, 2013 at 10:54:27PM +0200, Thomas Gummerer wrote:\n>> Currently the __git_ps1 git prompt gives the following error with a\n>> repository converted by git-svn, when used with zsh:\n>>\n>> \t   __git_ps1_show_upstream:19: bad pattern: svn_remote[\n>>\n>> This was introduced by 6d158cba (bash completion: Support \"divergence\n>> from upstream\" messages in __git_ps1), when the script was for bash\n>> only.  Make it compatible with zsh.\n>\n> What is the actual cause of this problem/incompatibility and how/why do\n> these changes fix it?\n>\n>> -\t\t\tsvn_remote[ $((${#svn_remote[@]} + 1)) ]=\"$value\"\n>> +\t\t\tsvn_remote[$((${#svn_remote[@]} + 1))]=\"$value\"\n>\n> I mean, did zsh really complained because of the space after the '[' ?!\n\nYes, removing the spaces after the '[' fixes the problem.  I'm not very\nproficient in shell scripting, so I can't tell if there is another\ncause.\n\n>> @@ -146,8 +146,8 @@ __git_ps1_show_upstream ()\n>>  \tsvn*)\n>>  \t\t# get the upstream from the \"git-svn-id: ...\" in a commit message\n>>  \t\t# (git-svn uses essentially the same procedure internally)\n>> -\t\tlocal svn_upstream=($(git log --first-parent -1 \\\n>> -\t\t\t\t\t--grep=\"^git-svn-id: \\(${svn_url_pattern#??}\\)\" 2>/dev/null))\n>> +\t\tset -a svn_upstream \"$(git log --first-parent -1 \\\n>> +\t\t\t\t\t--grep=\"^git-svn-id: \\(${svn_url_pattern#??}\\)\" 2>/dev/null)\"\n>>  \t\tif [[ 0 -ne ${#svn_upstream[@]} ]]; then\n>>  \t\t\tsvn_upstream=${svn_upstream[ ${#svn_upstream[@]} - 2 ]}\n>\n> If so, then what about this one?\n\nYou're right, this line gives an error too, the code just wasn't\nfollowing that path before.  I'll fix it in the re-roll.  Other than\nthose two I couldn't spot any other occurrence of this pattern.\n\n> Best,\n> Gábor\n\nThanks,\nThomas\n"},{"id":"218152","messageId":"877gir31ql.fsf@gmail.com","threadId":"33889","inReplyTo":"CAMP44s3uEaG3Y+cVoKhCA-f+hi1VZcCpXO5bYCQLvANDdvYwRA@mail.gmail.com","subject":"Re: [PATCH] prompt: fix show upstream with svn and zsh","fromName":"Thomas Gummerer","fromEmail":"t.gummerer@gmail.com","sentAt":"2013-05-22T07:36:18Z","receivedAt":"2013-05-22T07:36:18Z","isPatch":true,"sender":{"key":"t.gummerer@gmail.com","avatar":"https://avatars.githubusercontent.com/u/191004?v=4"},"body":"Felipe Contreras <felipe.contreras@gmail.com> writes:\n\n> On Tue, May 21, 2013 at 3:54 PM, Thomas Gummerer <t.gummerer@gmail.com> wrote:\n>> Currently the __git_ps1 git prompt gives the following error with a\n>> repository converted by git-svn, when used with zsh:\n>>\n>>            __git_ps1_show_upstream:19: bad pattern: svn_remote[\n>>\n>> This was introduced by 6d158cba (bash completion: Support \"divergence\n>> from upstream\" messages in __git_ps1), when the script was for bash\n>> only.  Make it compatible with zsh.\n>>\n>> Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>\n>\n> This patch is fine by me. I would like to see an example of how to\n> trigger the issue with a standalone command in the commit message, but\n> it's not necessary. It would also make sense to address the comment\n> from Szeder that does raise questions about other places in the code\n> where 'array[ $foo ]' is used, maybe there's a caveat we are not\n> considering, or maybe your use-case did not execute that code.\n\nYes, the code was not executed, it will be fixed in the re-roll.\n\n> And finally, I don't recall seen 'set -a' used elsewhere in the code.\n> If memory serves well, we have replaced 'local -a foo=value' with\n> 'local -a foo\\nfoo=value' before to fix zsh issues, I think that would\n> be safer.\n\nYes, thanks for the suggestion, that works.\n\n> But this patch is needed regardless, that, or the patch that broke\n> things should be reverted for v1.8.3.\n\nI don't think anything should or can be reverted, as this code was\nintroduced in 2010, but nobody triggered it until now.\n\n> Thomas, if you don't have time, let me know and I can take a look.\n>\n> Cheers.\n>\n> --\n> Felipe Contreras\n\nThanks,\nThomas\n"},{"id":"218153","messageId":"1369208439-20061-1-git-send-email-t.gummerer@gmail.com","threadId":"33889","inReplyTo":"1369169667-25166-1-git-send-email-t.gummerer@gmail.com","subject":"[PATCH v2] prompt: fix show upstream with svn and zsh","fromName":"Thomas Gummerer","fromEmail":"t.gummerer@gmail.com","sentAt":"2013-05-22T07:40:39Z","receivedAt":"2013-05-22T07:40:39Z","isPatch":true,"sender":{"key":"t.gummerer@gmail.com","avatar":"https://avatars.githubusercontent.com/u/191004?v=4"},"body":"Currently the __git_ps1 git prompt gives the following error with a\nrepository converted by git-svn, when used with zsh:\n\n   __git_ps1_show_upstream:19: bad pattern: svn_remote[\n   __git_ps1_show_upstream:45: bad substitution\n\nTo reproduce the problem, the __git_ps1_show_upstream function can be\nexecuted in a repository converted with git-svn.  Both those errors are\ntriggered by spaces after the '['.\n\nZsh also doesn't support initializing an array with `local var=(...)`.\nThis triggers the following error:\n\n   __git_ps1_show_upstream:41: bad pattern: svn_upstream=(commit\n\nUse\n   local -a\n   var=(...)\ninstead to make is compatible.\n\nThis was introduced by 6d158cba (bash completion: Support \"divergence\nfrom upstream\" messages in __git_ps1), when the script was for bash\nonly.\n\nSigned-off-by: Thomas Gummerer <t.gummerer@gmail.com>\n---\n contrib/completion/git-prompt.sh | 7 ++++---\n 1 file changed, 4 insertions(+), 3 deletions(-)\n\ndiff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh\nindex eaf5c36..b6b1534 100644\n--- a/contrib/completion/git-prompt.sh\n+++ b/contrib/completion/git-prompt.sh\n@@ -124,7 +124,7 @@ __git_ps1_show_upstream ()\n \t\t\tfi\n \t\t\t;;\n \t\tsvn-remote.*.url)\n-\t\t\tsvn_remote[ $((${#svn_remote[@]} + 1)) ]=\"$value\"\n+\t\t\tsvn_remote[$((${#svn_remote[@]} + 1))]=\"$value\"\n \t\t\tsvn_url_pattern+=\"\\\\|$value\"\n \t\t\tupstream=svn+git # default upstream is SVN if available, else git\n \t\t\t;;\n@@ -146,10 +146,11 @@ __git_ps1_show_upstream ()\n \tsvn*)\n \t\t# get the upstream from the \"git-svn-id: ...\" in a commit message\n \t\t# (git-svn uses essentially the same procedure internally)\n-\t\tlocal svn_upstream=($(git log --first-parent -1 \\\n+\t\tlocal -a svn_upstream\n+\t\tsvn_upstream=($(git log --first-parent -1 \\\n \t\t\t\t\t--grep=\"^git-svn-id: \\(${svn_url_pattern#??}\\)\" 2>/dev/null))\n \t\tif [[ 0 -ne ${#svn_upstream[@]} ]]; then\n-\t\t\tsvn_upstream=${svn_upstream[ ${#svn_upstream[@]} - 2 ]}\n+\t\t\tsvn_upstream=${svn_upstream[${#svn_upstream[@]} - 2]}\n \t\t\tsvn_upstream=${svn_upstream%@*}\n \t\t\tlocal n_stop=\"${#svn_remote[@]}\"\n \t\t\tfor ((n=1; n <= n_stop; n++)); do\n-- \n1.8.3.rc2.359.g2fb82f5\n"},{"id":"218155","messageId":"CAMP44s2KhSNXF8rkkYcGvzi7xxr11oXQW4+Yj3-u+aZ1EDHguQ@mail.gmail.com","threadId":"33889","inReplyTo":"1369208439-20061-1-git-send-email-t.gummerer@gmail.com","subject":"Re: [PATCH v2] prompt: fix show upstream with svn and zsh","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-22T07:56:05Z","receivedAt":"2013-05-22T07:56:05Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"On Wed, May 22, 2013 at 2:40 AM, Thomas Gummerer <t.gummerer@gmail.com> wrote:\n> Currently the __git_ps1 git prompt gives the following error with a\n> repository converted by git-svn, when used with zsh:\n>\n>    __git_ps1_show_upstream:19: bad pattern: svn_remote[\n>    __git_ps1_show_upstream:45: bad substitution\n>\n> To reproduce the problem, the __git_ps1_show_upstream function can be\n> executed in a repository converted with git-svn.  Both those errors are\n> triggered by spaces after the '['.\n>\n> Zsh also doesn't support initializing an array with `local var=(...)`.\n> This triggers the following error:\n>\n>    __git_ps1_show_upstream:41: bad pattern: svn_upstream=(commit\n>\n> Use\n>    local -a\n>    var=(...)\n> instead to make is compatible.\n>\n> This was introduced by 6d158cba (bash completion: Support \"divergence\n> from upstream\" messages in __git_ps1), when the script was for bash\n> only.\n>\n> Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>\n\nI think there's no need to be so verbose in the commit message, but\nhey, that's just an opinion.\n\nAcknowledged-by: Felipe Contreras <felipe.contreras@gmail.com>\n\n-- \nFelipe Contreras\n"},{"id":"218640","messageId":"20130528103050.GD2192@goldbirke","threadId":"33889","inReplyTo":"87a9nn31wj.fsf@gmail.com","subject":"Re: [PATCH] prompt: fix show upstream with svn and zsh","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2013-05-28T10:30:50Z","receivedAt":"2013-05-28T10:30:50Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"Hi,\n\nOn Wed, May 22, 2013 at 09:32:44AM +0200, Thomas Gummerer wrote:\n> SZEDER Gábor <szeder@ira.uka.de> writes:\n> > On Tue, May 21, 2013 at 10:54:27PM +0200, Thomas Gummerer wrote:\n> >> -\t\t\tsvn_remote[ $((${#svn_remote[@]} + 1)) ]=\"$value\"\n> >> +\t\t\tsvn_remote[$((${#svn_remote[@]} + 1))]=\"$value\"\n> >\n> > I mean, did zsh really complained because of the space after the '[' ?!\n> \n> Yes, removing the spaces after the '[' fixes the problem.  I'm not very\n> proficient in shell scripting, so I can't tell if there is another\n> cause.\n\nThanks.  I first suspected that this was just an independent style\ncleanup, that's why I asked for clarification.\n\n\nGábor\n"}]}