{"thread":{"id":"53886","subject":"[PATCH] git-prompt: changes == to = for zsh's sake","startedAt":"2020-07-20T23:17:37Z","lastAt":"2020-07-21T00:41:02Z","messageCount":6,"participants":["David J. Malan via GitGitGadget","Junio C Hamano","Aaron Schrab","Elijah Newren"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"401790","messageId":"pull.679.git.1595287052428.gitgitgadget@gmail.com","threadId":"53886","inReplyTo":null,"subject":"[PATCH] git-prompt: changes == to = for zsh's sake","fromName":"David J. Malan via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-07-20T23:17:32Z","receivedAt":"2020-07-20T23:17:37Z","isPatch":true,"sender":{"key":"name:David J. Malan","avatar":null},"body":"From: \"David J. Malan\" <malan@harvard.edu>\n\nWhen using git-prompt.sh with Zsh, __git_ps1 currently errs\nwhen inside a repo with:\n\n__git_ps1:96: = not found\n\nThis commit changes `==` to `=` for both Bash and Zsh.\n\nSigned-off-by: David J. Malan <malan@harvard.edu>\n---\n    Changes == to = for zsh's sake in git-prompt.sh\n    \n    Upon installing git-prompt.sh\n    [https://github.com/gitgitgadget/git/blob/master/contrib/completion/git-prompt.sh] \n    on macOS Catalina, I noticed that \n    https://github.com/gitgitgadget/git/commit/afda36dbf3b4f5a489ab44c00d5210c1fa894a40 \n    seems to have introduced an issue for Zsh whereby __git_ps1 errs with\n    \n    __git_ps1:96: = not found\n    \n    when inside a repo. Changing == to = would seem to address for both Bash\n    and Zsh.\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-679%2Fdmalan%2Fpatch-1-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-679/dmalan/patch-1-v1\nPull-Request: https://github.com/gitgitgadget/git/pull/679\n\n contrib/completion/git-prompt.sh | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh\nindex e6cd5464e5..16260bab73 100644\n--- a/contrib/completion/git-prompt.sh\n+++ b/contrib/completion/git-prompt.sh\n@@ -433,7 +433,7 @@ __git_ps1 ()\n \tlocal sparse=\"\"\n \tif [ -z \"${GIT_PS1_COMPRESSSPARSESTATE}\" ] &&\n \t   [ -z \"${GIT_PS1_OMITSPARSESTATE}\" ] &&\n-\t   [ \"$(git config --bool core.sparseCheckout)\" == \"true\" ]; then\n+\t   [ \"$(git config --bool core.sparseCheckout)\" = \"true\" ]; then\n \t\tsparse=\"|SPARSE\"\n \tfi\n \n@@ -542,7 +542,7 @@ __git_ps1 ()\n \t\tfi\n \n \t\tif [ -n \"${GIT_PS1_COMPRESSSPARSESTATE}\" ] &&\n-\t\t   [ \"$(git config --bool core.sparseCheckout)\" == \"true\" ]; then\n+\t\t   [ \"$(git config --bool core.sparseCheckout)\" = \"true\" ]; then\n \t\t\th=\"?\"\n \t\tfi\n \n\nbase-commit: ae46588be0cd730430dded4491246dfb4eac5557\n-- \ngitgitgadget\n"},{"id":"401791","messageId":"xmqqpn8p91sy.fsf@gitster.c.googlers.com","threadId":"53886","inReplyTo":"pull.679.git.1595287052428.gitgitgadget@gmail.com","subject":"Re: [PATCH] git-prompt: changes == to = for zsh's sake","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-07-20T23:58:21Z","receivedAt":"2020-07-20T23:58:29Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"David J. Malan via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> From: \"David J. Malan\" <malan@harvard.edu>\n> Subject: Re: [PATCH] git-prompt: changes == to = for zsh's sake\n\ns/changes/change/\n\n> When using git-prompt.sh with Zsh, __git_ps1 currently errs\n> when inside a repo with:\n>\n> __git_ps1:96: = not found\n\nOK.\n\n> This commit changes `==` to `=` for both Bash and Zsh.\n\nWe prefer to see \"why\" instead of \"what\", as the latter can easily\nbe read from the patch text.\n\n    Avoid using non-portable \"==\" that is only understood by bash\n    and not zsh to \"=\"; that way the prompt script becomes usable\n    with zsh again.\n\nor something like that.\n\nElijah, I think this is a minor regression in this cycle, and the\nfix is obvious enough that it deserves to be in the upcoming\nrelease.  Agreed?\n\nThank you, David, for a fix.\n\n\n> Signed-off-by: David J. Malan <malan@harvard.edu>\n> ---\n>     Changes == to = for zsh's sake in git-prompt.sh\n>     \n>     Upon installing git-prompt.sh\n>     [https://github.com/gitgitgadget/git/blob/master/contrib/completion/git-prompt.sh] \n>     on macOS Catalina, I noticed that \n>     https://github.com/gitgitgadget/git/commit/afda36dbf3b4f5a489ab44c00d5210c1fa894a40 \n>     seems to have introduced an issue for Zsh whereby __git_ps1 errs with\n>     \n>     __git_ps1:96: = not found\n>     \n>     when inside a repo. Changing == to = would seem to address for both Bash\n>     and Zsh.\n>\n> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-679%2Fdmalan%2Fpatch-1-v1\n> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-679/dmalan/patch-1-v1\n> Pull-Request: https://github.com/gitgitgadget/git/pull/679\n>\n>  contrib/completion/git-prompt.sh | 4 ++--\n>  1 file changed, 2 insertions(+), 2 deletions(-)\n>\n> diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh\n> index e6cd5464e5..16260bab73 100644\n> --- a/contrib/completion/git-prompt.sh\n> +++ b/contrib/completion/git-prompt.sh\n> @@ -433,7 +433,7 @@ __git_ps1 ()\n>  \tlocal sparse=\"\"\n>  \tif [ -z \"${GIT_PS1_COMPRESSSPARSESTATE}\" ] &&\n>  \t   [ -z \"${GIT_PS1_OMITSPARSESTATE}\" ] &&\n> -\t   [ \"$(git config --bool core.sparseCheckout)\" == \"true\" ]; then\n> +\t   [ \"$(git config --bool core.sparseCheckout)\" = \"true\" ]; then\n>  \t\tsparse=\"|SPARSE\"\n>  \tfi\n>  \n> @@ -542,7 +542,7 @@ __git_ps1 ()\n>  \t\tfi\n>  \n>  \t\tif [ -n \"${GIT_PS1_COMPRESSSPARSESTATE}\" ] &&\n> -\t\t   [ \"$(git config --bool core.sparseCheckout)\" == \"true\" ]; then\n> +\t\t   [ \"$(git config --bool core.sparseCheckout)\" = \"true\" ]; then\n>  \t\t\th=\"?\"\n>  \t\tfi\n>  \n>\n> base-commit: ae46588be0cd730430dded4491246dfb4eac5557\n"},{"id":"401793","messageId":"pull.679.v2.git.1595290531264.gitgitgadget@gmail.com","threadId":"53886","inReplyTo":"pull.679.git.1595287052428.gitgitgadget@gmail.com","subject":"[PATCH v2] git-prompt: change == to = for zsh's sake","fromName":"David J. Malan via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-07-21T00:15:31Z","receivedAt":"2020-07-21T00:15:35Z","isPatch":true,"sender":{"key":"name:David J. Malan","avatar":null},"body":"From: \"David J. Malan\" <malan@harvard.edu>\n\nWhen using git-prompt.sh with zsh, __git_ps1 currently errs\nwhen inside a repo with:\n\n__git_ps1:96: = not found\n\nAvoid using non-portable \"==\" that is only understood by bash\nand not zsh. Change to \"=\" so that the prompt script becomes\nusable with zsh again.\n\nSigned-off-by: David J. Malan <malan@harvard.edu>\n---\n    Change == to = for zsh's sake in git-prompt.sh\n    \n    Upon installing git-prompt.sh\n    [https://github.com/gitgitgadget/git/blob/master/contrib/completion/git-prompt.sh] \n    on macOS Catalina, I noticed that \n    https://github.com/gitgitgadget/git/commit/afda36dbf3b4f5a489ab44c00d5210c1fa894a40 \n    seems to have introduced an issue for Zsh whereby __git_ps1 errs with\n    \n    __git_ps1:96: = not found\n    \n    when inside a repo. Changing == to = would seem to address for both Bash\n    and Zsh.\n    \n    Changes since v1:\n    \n     * Commit message rewritten to use imperative mood.\n     * Commit message rewritten to elaborate on reason for change.\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-679%2Fdmalan%2Fpatch-1-v2\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-679/dmalan/patch-1-v2\nPull-Request: https://github.com/gitgitgadget/git/pull/679\n\nRange-diff vs v1:\n\n 1:  95be513ed1 ! 1:  f5402f1512 git-prompt: changes == to = for zsh's sake\n     @@ Metadata\n      Author: David J. Malan <malan@harvard.edu>\n      \n       ## Commit message ##\n     -    git-prompt: changes == to = for zsh's sake\n     +    git-prompt: change == to = for zsh's sake\n      \n     -    When using git-prompt.sh with Zsh, __git_ps1 currently errs\n     +    When using git-prompt.sh with zsh, __git_ps1 currently errs\n          when inside a repo with:\n      \n          __git_ps1:96: = not found\n      \n     -    This commit changes `==` to `=` for both Bash and Zsh.\n     +    Avoid using non-portable \"==\" that is only understood by bash\n     +    and not zsh. Change to \"=\" so that the prompt script becomes\n     +    usable with zsh again.\n      \n          Signed-off-by: David J. Malan <malan@harvard.edu>\n      \n\n\n contrib/completion/git-prompt.sh | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh\nindex e6cd5464e5..16260bab73 100644\n--- a/contrib/completion/git-prompt.sh\n+++ b/contrib/completion/git-prompt.sh\n@@ -433,7 +433,7 @@ __git_ps1 ()\n \tlocal sparse=\"\"\n \tif [ -z \"${GIT_PS1_COMPRESSSPARSESTATE}\" ] &&\n \t   [ -z \"${GIT_PS1_OMITSPARSESTATE}\" ] &&\n-\t   [ \"$(git config --bool core.sparseCheckout)\" == \"true\" ]; then\n+\t   [ \"$(git config --bool core.sparseCheckout)\" = \"true\" ]; then\n \t\tsparse=\"|SPARSE\"\n \tfi\n \n@@ -542,7 +542,7 @@ __git_ps1 ()\n \t\tfi\n \n \t\tif [ -n \"${GIT_PS1_COMPRESSSPARSESTATE}\" ] &&\n-\t\t   [ \"$(git config --bool core.sparseCheckout)\" == \"true\" ]; then\n+\t\t   [ \"$(git config --bool core.sparseCheckout)\" = \"true\" ]; then\n \t\t\th=\"?\"\n \t\tfi\n \n\nbase-commit: ae46588be0cd730430dded4491246dfb4eac5557\n-- \ngitgitgadget\n"},{"id":"401797","messageId":"20200721002309.GA178512@pug.qqx.org","threadId":"53886","inReplyTo":"pull.679.git.1595287052428.gitgitgadget@gmail.com","subject":"Re: [PATCH] git-prompt: changes == to = for zsh's sake","fromName":"Aaron Schrab","fromEmail":"aaron@schrab.com","sentAt":"2020-07-21T00:23:09Z","receivedAt":"2020-07-21T00:23:13Z","isPatch":true,"sender":{"key":"aaron@schrab.com","avatar":"https://avatars.githubusercontent.com/u/39620?v=4"},"body":"At 23:17 +0000 20 Jul 2020, \"David J. Malan via GitGitGadget\" <gitgitgadget@gmail.com> wrote:\n>From: \"David J. Malan\" <malan@harvard.edu>\n>\n>When using git-prompt.sh with Zsh, __git_ps1 currently errs\n>when inside a repo with:\n>\n>__git_ps1:96: = not found\n\nThat depends if zsh's `equals` option is set or not. If it's set (as it \nis by default) you'll get that behavior. If it's unset (`setopt \nno_equals`) that should behave as in bash. But, it fixing the code to \nwork regardless of shell options is definitely a good thing.\n\n>This commit changes `==` to `=` for both Bash and Zsh.\n\nAn alternate fix would be to switch to using double square brackets \ninstead of single square brackets for the test. Since contents of double \nbrackets have their own parsing rules the `equals` option doesn't apply \nthere, and so `==` is available for checking equality same as in bash.  \nIMHO, this provides saner behavior in general; although it's definitely \nnot POSIX compliant.\n"},{"id":"401798","messageId":"xmqqh7u18zu1.fsf@gitster.c.googlers.com","threadId":"53886","inReplyTo":"20200721002309.GA178512@pug.qqx.org","subject":"Re: [PATCH] git-prompt: changes == to = for zsh's sake","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-07-21T00:40:54Z","receivedAt":"2020-07-21T00:40:59Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Aaron Schrab <aaron@schrab.com> writes:\n\n> An alternate fix would be to switch to using double square brackets\n> instead of single square brackets for the test. Since contents of\n> double brackets have their own parsing rules the `equals` option\n> doesn't apply there, and so `==` is available for checking equality\n> same as in bash.  IMHO, this provides saner behavior in general;\n> although it's definitely not POSIX compliant.\n\nIt won't be but it does not have to be POSIX compliant anyway; after\nall this is prompt support for bash with support for zsh added on\nthe side, neither is limited to strict POSIX.\n\nI'd say that the patch posted is good as-is.\n\nThanks.\n"},{"id":"401799","messageId":"CABPp-BGm4UuRsL0K5=rAxyXaQYTgWicmFKNcRRfJziQ7BmSP1g@mail.gmail.com","threadId":"53886","inReplyTo":"xmqqpn8p91sy.fsf@gitster.c.googlers.com","subject":"Re: [PATCH] git-prompt: changes == to = for zsh's sake","fromName":"Elijah Newren","fromEmail":"newren@gmail.com","sentAt":"2020-07-21T00:40:46Z","receivedAt":"2020-07-21T00:41:02Z","isPatch":true,"sender":{"key":"newren@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5455730?v=4"},"body":"On Mon, Jul 20, 2020 at 4:58 PM Junio C Hamano <gitster@pobox.com> wrote:\n>\n> \"David J. Malan via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n>\n> > From: \"David J. Malan\" <malan@harvard.edu>\n> > Subject: Re: [PATCH] git-prompt: changes == to = for zsh's sake\n>\n> s/changes/change/\n>\n> > When using git-prompt.sh with Zsh, __git_ps1 currently errs\n> > when inside a repo with:\n> >\n> > __git_ps1:96: = not found\n>\n> OK.\n>\n> > This commit changes `==` to `=` for both Bash and Zsh.\n>\n> We prefer to see \"why\" instead of \"what\", as the latter can easily\n> be read from the patch text.\n>\n>     Avoid using non-portable \"==\" that is only understood by bash\n>     and not zsh to \"=\"; that way the prompt script becomes usable\n>     with zsh again.\n>\n> or something like that.\n>\n> Elijah, I think this is a minor regression in this cycle, and the\n> fix is obvious enough that it deserves to be in the upcoming\n> release.  Agreed?\n\nYeah, it's a pretty obvious and very localized fix for a regression\nfrom this cycle.  I'd say putting it in the upcoming release makes\nsense.\n\n> Thank you, David, for a fix.\n\n+1.\n\n> > Signed-off-by: David J. Malan <malan@harvard.edu>\n> > ---\n> >     Changes == to = for zsh's sake in git-prompt.sh\n> >\n> >     Upon installing git-prompt.sh\n> >     [https://github.com/gitgitgadget/git/blob/master/contrib/completion/git-prompt.sh]\n> >     on macOS Catalina, I noticed that\n> >     https://github.com/gitgitgadget/git/commit/afda36dbf3b4f5a489ab44c00d5210c1fa894a40\n> >     seems to have introduced an issue for Zsh whereby __git_ps1 errs with\n> >\n> >     __git_ps1:96: = not found\n> >\n> >     when inside a repo. Changing == to = would seem to address for both Bash\n> >     and Zsh.\n> >\n> > Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-679%2Fdmalan%2Fpatch-1-v1\n> > Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-679/dmalan/patch-1-v1\n> > Pull-Request: https://github.com/gitgitgadget/git/pull/679\n> >\n> >  contrib/completion/git-prompt.sh | 4 ++--\n> >  1 file changed, 2 insertions(+), 2 deletions(-)\n> >\n> > diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh\n> > index e6cd5464e5..16260bab73 100644\n> > --- a/contrib/completion/git-prompt.sh\n> > +++ b/contrib/completion/git-prompt.sh\n> > @@ -433,7 +433,7 @@ __git_ps1 ()\n> >       local sparse=\"\"\n> >       if [ -z \"${GIT_PS1_COMPRESSSPARSESTATE}\" ] &&\n> >          [ -z \"${GIT_PS1_OMITSPARSESTATE}\" ] &&\n> > -        [ \"$(git config --bool core.sparseCheckout)\" == \"true\" ]; then\n> > +        [ \"$(git config --bool core.sparseCheckout)\" = \"true\" ]; then\n> >               sparse=\"|SPARSE\"\n> >       fi\n> >\n> > @@ -542,7 +542,7 @@ __git_ps1 ()\n> >               fi\n> >\n> >               if [ -n \"${GIT_PS1_COMPRESSSPARSESTATE}\" ] &&\n> > -                [ \"$(git config --bool core.sparseCheckout)\" == \"true\" ]; then\n> > +                [ \"$(git config --bool core.sparseCheckout)\" = \"true\" ]; then\n> >                       h=\"?\"\n> >               fi\n> >\n> >\n> > base-commit: ae46588be0cd730430dded4491246dfb4eac5557\n"}]}