{"thread":{"id":"57474","subject":"[PATCH 0/4] In PS1 prompt, make upstream state indicators consistent with other state indicators","startedAt":"2022-02-25T11:44:17Z","lastAt":"2022-03-23T20:07:04Z","messageCount":15,"participants":["Justin Donnelly via GitGitGadget","Ævar Arnfjörð Bjarmason","Justin Donnelly","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":4},"messages":[{"id":"449569","messageId":"pull.1162.git.1645789446.gitgitgadget@gmail.com","threadId":"57474","inReplyTo":null,"subject":"[PATCH 0/4] In PS1 prompt, make upstream state indicators consistent with other state indicators","fromName":"Justin Donnelly via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-02-25T11:44:02Z","receivedAt":"2022-02-25T11:44:17Z","isPatch":true,"sender":{"key":"justinrdonnelly@gmail.com","avatar":"https://avatars.githubusercontent.com/u/24846452?v=4"},"body":"These patches are about the characters and words that can be configured to\ndisplay in the PS1 prompt after the branch name. I've been unable to find a\nconsistent terminology. I refer to them as follows: [short | long] [type]\nstate indicator where short is for characters (e.g. ?), long is for words\n(e.g. |SPARSE), and type is the type of indicator (e.g. sparse or upstream).\nI'd be happy to change the commit messages to a different terminology if\nthat's preferred.\n\nThere are a few inconsistencies with the PS1 prompt upstream state indicator\n(GIT_PS1_SHOWUPSTREAM).\n\n * With GIT_PS1_SHOWUPSTREAM=\"auto\", if there are no other short state\n   indicators (e.g. + for staged changes, $ for stashed changes, etc.), the\n   upstream state indicator appears adjacent to the branch name (e.g.\n   (main=)) instead of being separated by SP or GIT_PS1_STATESEPARATOR (e.g.\n   (main =)).\n * If there are long state indicators (e.g. |SPARSE), a short upstream state\n   indicator (i.e. GIT_PS1_SHOWUPSTREAM=\"auto\") is to the right of the long\n   state indicator (e.g. (main +|SPARSE=)) instead of with the other short\n   state indicators (e.g. (main +=|SPARSE)).\n * The long upstream state indicator (e.g. GIT_PS1_SHOWUPSTREAM=\"verbose\")\n   is separated from other (short or long) state indicators by a hard-coded\n   SP. Other long state indicators are separated by a hard-coded pipe (|).\n\nThese patches are to make the upstream state indicators more consistent with\nother state indicators.\n\nJustin Donnelly (4):\n  git-prompt: rename `upstream` to `upstream_type`\n  git-prompt: make upstream state indicator location consistent\n  git-prompt: make long upstream state indicator consistent\n  git-prompt: put upstream comments together\n\n contrib/completion/git-prompt.sh | 59 ++++++++++++++++----------------\n 1 file changed, 30 insertions(+), 29 deletions(-)\n\n\nbase-commit: 4c53a8c20f8984adb226293a3ffd7b88c3f4ac1a\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-1162%2Fjustinrdonnelly%2Fgit-prompt-upstream-consistency-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1162/justinrdonnelly/git-prompt-upstream-consistency-v1\nPull-Request: https://github.com/gitgitgadget/git/pull/1162\n-- \ngitgitgadget\n"},{"id":"449570","messageId":"1db836bb309989c4ad93ed6d32a5ef4075ac7020.1645789446.git.gitgitgadget@gmail.com","threadId":"57474","inReplyTo":"pull.1162.git.1645789446.gitgitgadget@gmail.com","subject":"[PATCH 1/4] git-prompt: rename `upstream` to `upstream_type`","fromName":"Justin Donnelly via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-02-25T11:44:03Z","receivedAt":"2022-02-25T11:44:19Z","isPatch":true,"sender":{"key":"justinrdonnelly@gmail.com","avatar":"https://avatars.githubusercontent.com/u/24846452?v=4"},"body":"From: Justin Donnelly <justinrdonnelly@gmail.com>\n\nIn `__git_ps1_show_upstream` rename the variable `upstream` to\n`upstream_type`. This allows `__git_ps1_show_upstream` to reference a\nvariable named `upstream` that is declared `local` in `__git_ps1`, which\ncalls `__git_ps1_show_upstream`.\n\nSigned-off-by: Justin Donnelly <justinrdonnelly@gmail.com>\n---\n contrib/completion/git-prompt.sh | 26 +++++++++++++-------------\n 1 file changed, 13 insertions(+), 13 deletions(-)\n\ndiff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh\nindex db7c0068fb5..3997e099aa7 100644\n--- a/contrib/completion/git-prompt.sh\n+++ b/contrib/completion/git-prompt.sh\n@@ -115,7 +115,7 @@ __git_ps1_show_upstream ()\n {\n \tlocal key value\n \tlocal svn_remote svn_url_pattern count n\n-\tlocal upstream=git legacy=\"\" verbose=\"\" name=\"\"\n+\tlocal upstream_type=git legacy=\"\" verbose=\"\" name=\"\"\n \n \tsvn_remote=()\n \t# get some config options from git-config\n@@ -132,7 +132,7 @@ __git_ps1_show_upstream ()\n \t\tsvn-remote.*.url)\n \t\t\tsvn_remote[$((${#svn_remote[@]} + 1))]=\"$value\"\n \t\t\tsvn_url_pattern=\"$svn_url_pattern\\\\|$value\"\n-\t\t\tupstream=svn+git # default upstream is SVN if available, else git\n+\t\t\tupstream_type=svn+git # default upstream type is SVN if available, else git\n \t\t\t;;\n \t\tesac\n \tdone <<< \"$output\"\n@@ -141,16 +141,16 @@ __git_ps1_show_upstream ()\n \tlocal option\n \tfor option in ${GIT_PS1_SHOWUPSTREAM}; do\n \t\tcase \"$option\" in\n-\t\tgit|svn) upstream=\"$option\" ;;\n+\t\tgit|svn) upstream_type=\"$option\" ;;\n \t\tverbose) verbose=1 ;;\n \t\tlegacy)  legacy=1  ;;\n \t\tname)    name=1 ;;\n \t\tesac\n \tdone\n \n-\t# Find our upstream\n-\tcase \"$upstream\" in\n-\tgit)    upstream=\"@{upstream}\" ;;\n+\t# Find our upstream type\n+\tcase \"$upstream_type\" in\n+\tgit)    upstream_type=\"@{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@@ -167,12 +167,12 @@ __git_ps1_show_upstream ()\n \n \t\t\tif [[ -z \"$svn_upstream\" ]]; then\n \t\t\t\t# default branch name for checkouts with no layout:\n-\t\t\t\tupstream=${GIT_SVN_ID:-git-svn}\n+\t\t\t\tupstream_type=${GIT_SVN_ID:-git-svn}\n \t\t\telse\n-\t\t\t\tupstream=${svn_upstream#/}\n+\t\t\t\tupstream_type=${svn_upstream#/}\n \t\t\tfi\n-\t\telif [[ \"svn+git\" = \"$upstream\" ]]; then\n-\t\t\tupstream=\"@{upstream}\"\n+\t\telif [[ \"svn+git\" = \"$upstream_type\" ]]; then\n+\t\t\tupstream_type=\"@{upstream}\"\n \t\tfi\n \t\t;;\n \tesac\n@@ -180,11 +180,11 @@ __git_ps1_show_upstream ()\n \t# Find how many commits we are ahead/behind our upstream\n \tif [[ -z \"$legacy\" ]]; then\n \t\tcount=\"$(git rev-list --count --left-right \\\n-\t\t\t\t\"$upstream\"...HEAD 2>/dev/null)\"\n+\t\t\t\t\"$upstream_type\"...HEAD 2>/dev/null)\"\n \telse\n \t\t# produce equivalent output to --count for older versions of git\n \t\tlocal commits\n-\t\tif commits=\"$(git rev-list --left-right \"$upstream\"...HEAD 2>/dev/null)\"\n+\t\tif commits=\"$(git rev-list --left-right \"$upstream_type\"...HEAD 2>/dev/null)\"\n \t\tthen\n \t\t\tlocal commit behind=0 ahead=0\n \t\t\tfor commit in $commits\n@@ -229,7 +229,7 @@ __git_ps1_show_upstream ()\n \t\tesac\n \t\tif [[ -n \"$count\" && -n \"$name\" ]]; then\n \t\t\t__git_ps1_upstream_name=$(git rev-parse \\\n-\t\t\t\t--abbrev-ref \"$upstream\" 2>/dev/null)\n+\t\t\t\t--abbrev-ref \"$upstream_type\" 2>/dev/null)\n \t\t\tif [ $pcmode = yes ] && [ $ps1_expanded = yes ]; then\n \t\t\t\tp=\"$p \\${__git_ps1_upstream_name}\"\n \t\t\telse\n-- \ngitgitgadget\n\n"},{"id":"449571","messageId":"83766e33614dbb90c1162bd9f6d7fc9c11cd2f60.1645789446.git.gitgitgadget@gmail.com","threadId":"57474","inReplyTo":"pull.1162.git.1645789446.gitgitgadget@gmail.com","subject":"[PATCH 3/4] git-prompt: make long upstream state indicator consistent","fromName":"Justin Donnelly via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-02-25T11:44:05Z","receivedAt":"2022-02-25T11:44:21Z","isPatch":true,"sender":{"key":"justinrdonnelly@gmail.com","avatar":"https://avatars.githubusercontent.com/u/24846452?v=4"},"body":"From: Justin Donnelly <justinrdonnelly@gmail.com>\n\nUse a pipe as a delimiter between short state indicators and long\nupstream state indicator (e.g. `(main *|u+2-1 origin/main)` instead of\n`(main * u+2-1 origin/main)`) . This is consistent with long state\nindicators for sparse and in-progress operations (e.g. merge).\n\nSigned-off-by: Justin Donnelly <justinrdonnelly@gmail.com>\n---\n contrib/completion/git-prompt.sh | 10 +++++-----\n 1 file changed, 5 insertions(+), 5 deletions(-)\n\ndiff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh\nindex 613389a53bc..2772f990888 100644\n--- a/contrib/completion/git-prompt.sh\n+++ b/contrib/completion/git-prompt.sh\n@@ -109,7 +109,7 @@\n __git_printf_supports_v=\n printf -v __git_printf_supports_v -- '%s' yes >/dev/null 2>&1\n \n-# stores the divergence from upstream in $p (for short status) or $upstream (for verbose status)\n+# stores the divergence from upstream in $p\n # used by GIT_PS1_SHOWUPSTREAM\n __git_ps1_show_upstream ()\n {\n@@ -219,13 +219,13 @@ __git_ps1_show_upstream ()\n \t\t\"\") # no upstream\n \t\t\tupstream=\"\" ;;\n \t\t\"0\t0\") # equal to upstream\n-\t\t\tupstream=\" u=\" ;;\n+\t\t\tupstream=\"|u=\" ;;\n \t\t\"0\t\"*) # ahead of upstream\n-\t\t\tupstream=\" u+${count#0\t}\" ;;\n+\t\t\tupstream=\"|u+${count#0\t}\" ;;\n \t\t*\"\t0\") # behind upstream\n-\t\t\tupstream=\" u-${count%\t0}\" ;;\n+\t\t\tupstream=\"|u-${count%\t0}\" ;;\n \t\t*)\t    # diverged from upstream\n-\t\t\tupstream=\" u+${count#*\t}-${count%\t*}\" ;;\n+\t\t\tupstream=\"|u+${count#*\t}-${count%\t*}\" ;;\n \t\tesac\n \t\tif [[ -n \"$count\" && -n \"$name\" ]]; then\n \t\t\t__git_ps1_upstream_name=$(git rev-parse \\\n-- \ngitgitgadget\n\n"},{"id":"449572","messageId":"b503cac5ae3e89aa7b6f996567a5d7b4d2a05d29.1645789446.git.gitgitgadget@gmail.com","threadId":"57474","inReplyTo":"pull.1162.git.1645789446.gitgitgadget@gmail.com","subject":"[PATCH 2/4] git-prompt: make upstream state indicator location consistent","fromName":"Justin Donnelly via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-02-25T11:44:04Z","receivedAt":"2022-02-25T11:44:23Z","isPatch":true,"sender":{"key":"justinrdonnelly@gmail.com","avatar":"https://avatars.githubusercontent.com/u/24846452?v=4"},"body":"From: Justin Donnelly <justinrdonnelly@gmail.com>\n\nMake upstream state indicator location more consistent with similar\nstate indicators (e.g. sparse). Group the short state indicator (`=`,\n`<`, `>`, or `<>`) with other short state indicators immediately after\nthe branch name. Group the long state indicator (e.g. `u+2-1\norigin/main`) with other long state indicators after the short state\nindicators. Previously short and long upstream state indicators appeared\nafter all other state indicators.\n\nUse a separator (`SP` or `GIT_PS1_STATESEPARATOR`) between branch name\nand short upstream state indicator. Previously the short upstream state\nindicator would sometimes appear directly adjacent to the branch name\n(e.g. `(main=)`) instead of being separated (e.g. `(main =)`).\n\nSigned-off-by: Justin Donnelly <justinrdonnelly@gmail.com>\n---\n contrib/completion/git-prompt.sh | 25 +++++++++++++------------\n 1 file changed, 13 insertions(+), 12 deletions(-)\n\ndiff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh\nindex 3997e099aa7..613389a53bc 100644\n--- a/contrib/completion/git-prompt.sh\n+++ b/contrib/completion/git-prompt.sh\n@@ -109,7 +109,7 @@\n __git_printf_supports_v=\n printf -v __git_printf_supports_v -- '%s' yes >/dev/null 2>&1\n \n-# stores the divergence from upstream in $p\n+# stores the divergence from upstream in $p (for short status) or $upstream (for verbose status)\n # used by GIT_PS1_SHOWUPSTREAM\n __git_ps1_show_upstream ()\n {\n@@ -214,26 +214,26 @@ __git_ps1_show_upstream ()\n \t\t*)\t    # diverged from upstream\n \t\t\tp=\"<>\" ;;\n \t\tesac\n-\telse\n+\telse # verbose, set upstream instead of p\n \t\tcase \"$count\" in\n \t\t\"\") # no upstream\n-\t\t\tp=\"\" ;;\n+\t\t\tupstream=\"\" ;;\n \t\t\"0\t0\") # equal to upstream\n-\t\t\tp=\" u=\" ;;\n+\t\t\tupstream=\" u=\" ;;\n \t\t\"0\t\"*) # ahead of upstream\n-\t\t\tp=\" u+${count#0\t}\" ;;\n+\t\t\tupstream=\" u+${count#0\t}\" ;;\n \t\t*\"\t0\") # behind upstream\n-\t\t\tp=\" u-${count%\t0}\" ;;\n+\t\t\tupstream=\" u-${count%\t0}\" ;;\n \t\t*)\t    # diverged from upstream\n-\t\t\tp=\" u+${count#*\t}-${count%\t*}\" ;;\n+\t\t\tupstream=\" u+${count#*\t}-${count%\t*}\" ;;\n \t\tesac\n \t\tif [[ -n \"$count\" && -n \"$name\" ]]; then\n \t\t\t__git_ps1_upstream_name=$(git rev-parse \\\n \t\t\t\t--abbrev-ref \"$upstream_type\" 2>/dev/null)\n \t\t\tif [ $pcmode = yes ] && [ $ps1_expanded = yes ]; then\n-\t\t\t\tp=\"$p \\${__git_ps1_upstream_name}\"\n+\t\t\t\tupstream=\"$upstream \\${__git_ps1_upstream_name}\"\n \t\t\telse\n-\t\t\t\tp=\"$p ${__git_ps1_upstream_name}\"\n+\t\t\t\tupstream=\"$upstream ${__git_ps1_upstream_name}\"\n \t\t\t\t# not needed anymore; keep user's\n \t\t\t\t# environment clean\n \t\t\t\tunset __git_ps1_upstream_name\n@@ -512,7 +512,8 @@ __git_ps1 ()\n \tlocal u=\"\"\n \tlocal h=\"\"\n \tlocal c=\"\"\n-\tlocal p=\"\"\n+\tlocal p=\"\" # short version of upstream state indicator\n+\tlocal upstream=\"\" # verbose version of upstream state indicator\n \n \tif [ \"true\" = \"$inside_gitdir\" ]; then\n \t\tif [ \"true\" = \"$bare_repo\" ]; then\n@@ -568,8 +569,8 @@ __git_ps1 ()\n \t\tb=\"\\${__git_ps1_branch_name}\"\n \tfi\n \n-\tlocal f=\"$h$w$i$s$u\"\n-\tlocal gitstring=\"$c$b${f:+$z$f}${sparse}$r$p\"\n+\tlocal f=\"$h$w$i$s$u$p\"\n+\tlocal gitstring=\"$c$b${f:+$z$f}${sparse}$r${upstream}\"\n \n \tif [ $pcmode = yes ]; then\n \t\tif [ \"${__git_printf_supports_v-}\" != yes ]; then\n-- \ngitgitgadget\n\n"},{"id":"449573","messageId":"58ff3d8affed1c0f79a4a56945d23a5a9b0073f0.1645789446.git.gitgitgadget@gmail.com","threadId":"57474","inReplyTo":"pull.1162.git.1645789446.gitgitgadget@gmail.com","subject":"[PATCH 4/4] git-prompt: put upstream comments together","fromName":"Justin Donnelly via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-02-25T11:44:06Z","receivedAt":"2022-02-25T11:44:25Z","isPatch":true,"sender":{"key":"justinrdonnelly@gmail.com","avatar":"https://avatars.githubusercontent.com/u/24846452?v=4"},"body":"From: Justin Donnelly <justinrdonnelly@gmail.com>\n\nCommit 6d158cba28 (bash completion: Support \"divergence from upstream\"\nmessages in __git_ps1, 2010-06-17) introduced support for indicating\ndivergence from upstream in the PS1 prompt. The comments at the top of\ngit-prompt.sh that were introduced with that commit are several\nparagraphs long. Over the years, other comments have been inserted in\nbetween the paragraphs relating to divergence from upstream.\n\nThis commit puts the comments relating to divergence from upstream back\ntogether.\n\nSigned-off-by: Justin Donnelly <justinrdonnelly@gmail.com>\n---\n contrib/completion/git-prompt.sh | 10 +++++-----\n 1 file changed, 5 insertions(+), 5 deletions(-)\n\ndiff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh\nindex 2772f990888..87b2b916c03 100644\n--- a/contrib/completion/git-prompt.sh\n+++ b/contrib/completion/git-prompt.sh\n@@ -66,6 +66,11 @@\n #     git           always compare HEAD to @{upstream}\n #     svn           always compare HEAD to your SVN upstream\n #\n+# By default, __git_ps1 will compare HEAD to your SVN upstream if it can\n+# find one, or @{upstream} otherwise.  Once you have set\n+# GIT_PS1_SHOWUPSTREAM, you can override it on a per-repository basis by\n+# setting the bash.showUpstream config variable.\n+#\n # You can change the separator between the branch name and the above\n # state symbols by setting GIT_PS1_STATESEPARATOR. The default separator\n # is SP.\n@@ -79,11 +84,6 @@\n # single '?' character by setting GIT_PS1_COMPRESSSPARSESTATE, or omitted\n # by setting GIT_PS1_OMITSPARSESTATE.\n #\n-# By default, __git_ps1 will compare HEAD to your SVN upstream if it can\n-# find one, or @{upstream} otherwise.  Once you have set\n-# GIT_PS1_SHOWUPSTREAM, you can override it on a per-repository basis by\n-# setting the bash.showUpstream config variable.\n-#\n # If you would like to see more information about the identity of\n # commits checked out as a detached HEAD, set GIT_PS1_DESCRIBE_STYLE\n # to one of these values:\n-- \ngitgitgadget\n"},{"id":"449576","messageId":"220225.86czjb874f.gmgdl@evledraar.gmail.com","threadId":"57474","inReplyTo":"pull.1162.git.1645789446.gitgitgadget@gmail.com","subject":"Re: [PATCH 0/4] In PS1 prompt, make upstream state indicators consistent with other state indicators","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-02-25T12:22:59Z","receivedAt":"2022-02-25T12:26:29Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Fri, Feb 25 2022, Justin Donnelly via GitGitGadget wrote:\n\nI couldn't find any glaring issues here on a quick review, just a note.\n\n> These patches are about the characters and words that can be configured to\n> display in the PS1 prompt after the branch name. I've been unable to find a\n> consistent terminology. I refer to them as follows: [short | long] [type]\n> state indicator where short is for characters (e.g. ?), long is for words\n> (e.g. |SPARSE), and type is the type of indicator (e.g. sparse or upstream).\n> I'd be happy to change the commit messages to a different terminology if\n> that's preferred.\n\nI think that terminology is correct, in case you haven't seen it\ngit-for-each-ref(1) talks about the \"short\" here as \"short\",\n\"trackshort\" etc.\n\n> There are a few inconsistencies with the PS1 prompt upstream state indicator\n> (GIT_PS1_SHOWUPSTREAM).\n>\n>  * With GIT_PS1_SHOWUPSTREAM=\"auto\", if there are no other short state\n>    indicators (e.g. + for staged changes, $ for stashed changes, etc.), the\n>    upstream state indicator appears adjacent to the branch name (e.g.\n>    (main=)) instead of being separated by SP or GIT_PS1_STATESEPARATOR (e.g.\n>    (main =)).\n>  * If there are long state indicators (e.g. |SPARSE), a short upstream state\n>    indicator (i.e. GIT_PS1_SHOWUPSTREAM=\"auto\") is to the right of the long\n>    state indicator (e.g. (main +|SPARSE=)) instead of with the other short\n>    state indicators (e.g. (main +=|SPARSE)).\n\nI think it would really help to in each commit message have a\nbefore/after comparison of the relevant PS1 output that's being changed.\n\nI'm not sure how to readthis example. So before we said \"main +=|SPARSE\"\nbut now we'll say \"main +|SPARSE=\", but without sparse we'll say\n\"main=\"?\n\nAren't both of those harder to read than they need to be, shouldn't it\nbe closer to:\n\n    main= |SPARSE\n\nOr:\n\n    main= |+SPARSE\n\nOr:\n\n    main= +|SPARSE\n\nI can't recall what the \"+\" there is (if any).\n\nI.e. the \"=\" refers to the ahead/behind state of \"main, it seems odd in\nboth versions of your example that we're splitting it off from \"main\"\nbecause we have \"SPARSE\" too.\n\nBut maybe I'm missing something...\n"},{"id":"449683","messageId":"CAGTqyRwTEdwut4HKD2=MaBfG_tZqN_TjGPAjChzmjBubC0-wuQ@mail.gmail.com","threadId":"57474","inReplyTo":"220225.86czjb874f.gmgdl@evledraar.gmail.com","subject":"Re: [PATCH 0/4] In PS1 prompt, make upstream state indicators consistent with other state indicators","fromName":"Justin Donnelly","fromEmail":"justinrdonnelly@gmail.com","sentAt":"2022-02-27T00:32:52Z","receivedAt":"2022-02-27T00:33:32Z","isPatch":true,"sender":{"key":"justinrdonnelly@gmail.com","avatar":"https://avatars.githubusercontent.com/u/24846452?v=4"},"body":"Thanks for the feedback. Comments interleaved below.\n\nOn Fri, Feb 25, 2022 at 7:26 AM Ævar Arnfjörð Bjarmason\n<avarab@gmail.com> wrote:\n>\n>\n> On Fri, Feb 25 2022, Justin Donnelly via GitGitGadget wrote:\n>\n> I couldn't find any glaring issues here on a quick review, just a note.\n>\n> > These patches are about the characters and words that can be configured to\n> > display in the PS1 prompt after the branch name. I've been unable to find a\n> > consistent terminology. I refer to them as follows: [short | long] [type]\n> > state indicator where short is for characters (e.g. ?), long is for words\n> > (e.g. |SPARSE), and type is the type of indicator (e.g. sparse or upstream).\n> > I'd be happy to change the commit messages to a different terminology if\n> > that's preferred.\n>\n> I think that terminology is correct, in case you haven't seen it\n> git-for-each-ref(1) talks about the \"short\" here as \"short\",\n> \"trackshort\" etc.\n>\n> > There are a few inconsistencies with the PS1 prompt upstream state indicator\n> > (GIT_PS1_SHOWUPSTREAM).\n> >\n> >  * With GIT_PS1_SHOWUPSTREAM=\"auto\", if there are no other short state\n> >    indicators (e.g. + for staged changes, $ for stashed changes, etc.), the\n> >    upstream state indicator appears adjacent to the branch name (e.g.\n> >    (main=)) instead of being separated by SP or GIT_PS1_STATESEPARATOR (e.g.\n> >    (main =)).\n> >  * If there are long state indicators (e.g. |SPARSE), a short upstream state\n> >    indicator (i.e. GIT_PS1_SHOWUPSTREAM=\"auto\") is to the right of the long\n> >    state indicator (e.g. (main +|SPARSE=)) instead of with the other short\n> >    state indicators (e.g. (main +=|SPARSE)).\n>\n> I think it would really help to in each commit message have a\n> before/after comparison of the relevant PS1 output that's being changed.\n\nI agree that a before/after comparison would probably make it easier\nto understand. Maybe some examples without upstream (for a baseline to\ncompare against) and a table that shows before/after for upstream.\n\n`__git_ps1` examples without upstream:\n(main)\n(main %)\n(main *%)\n(main|SPARSE)\n(main %|SPARSE)\n(main *%|SPARSE)\n(main|SPARSE|REBASE 1/2)\n(main %|SPARSE|REBASE 1/2)\n\nOf note:\n1. If there are short state indicators, they appear together after the\nbranch name and separated from it by `SP` or `GIT_PS1_STATESEPARATOR`.\n2. If there are long state indicators, they appear after short state\nindicators if there are any, or after the branch name if there are no\nshort state indicators. Each long state indicator begins with a pipe\n(`|`) as a separator.\n\nPatch 2 before/after:\n| Before           | After            |\n| ---------------- | ---------------- |\n| (main=)          | (main =)         |\n| (main|SPARSE=)   | (main =|SPARSE)  |\n| (main %|SPARSE=) | (main %=|SPARSE) |\n\nPatch 3 before/after:\n| Before                          | After                           |\n| ------------------------------- | ------------------------------- |\n| (main u=)                       | (main|u=)                       |\n| (main u= origin/main)           | (main|u= origin/main)           |\n| (main u+1)                      | (main|u+1)                      |\n| (main u+1 origin/main)          | (main|u+1 origin/main)          |\n| (main % u=)                     | (main %|u=)                     |\n| (main % u= origin/main)         | (main %|u= origin/main)         |\n| (main % u+1)                    | (main %|u+1)                    |\n| (main % u+1 origin/main)        | (main %|u+1 origin/main)        |\n| (main|SPARSE u=)                | (main|SPARSE|u=)                |\n| (main|SPARSE u= origin/main)    | (main|SPARSE|u= origin/main)    |\n| (main|SPARSE u+1)               | (main|SPARSE|u+1)               |\n| (main|SPARSE u+1 origin/main)   | (main|SPARSE|u+1 origin/main)   |\n| (main %|SPARSE u=)              | (main %|SPARSE|u=)              |\n| (main %|SPARSE u= origin/main)  | (main %|SPARSE|u= origin/main)  |\n| (main %|SPARSE u+1)             | (main %|SPARSE|u+1)             |\n| (main %|SPARSE u+1 origin/main) | (main %|SPARSE|u+1 origin/main) |\n\nNote: These tables are inspired by [Markdown Guide extended\nsyntax](https://www.markdownguide.org/extended-syntax/#tables), but I\ndidn't wrap the PS1 prompt text in backticks or escape the pipe\nbecause I thought that would make it more confusing. In short, they're\nmeant to be viewed as (monospaced font) text, not Markdown.\n\n>\n>\n> I'm not sure how to readthis example. So before we said \"main +=|SPARSE\"\n> but now we'll say \"main +|SPARSE=\", but without sparse we'll say\n> \"main=\"?\n>\n> Aren't both of those harder to read than they need to be, shouldn't it\n> be closer to:\n>\n>     main= |SPARSE\n>\n> Or:\n>\n>     main= |+SPARSE\n>\n> Or:\n>\n>     main= +|SPARSE\n>\n> I can't recall what the \"+\" there is (if any).\n\n\n`+` is for staged changes (if `GIT_PS1_SHOWDIRTYSTATE` is a nonempty\nvalue). So it's not directly related to upstream, but the addition of\nanother short state indicator changes things.\n\n>\n>\n> I.e. the \"=\" refers to the ahead/behind state of \"main, it seems odd in\n> both versions of your example that we're splitting it off from \"main\"\n> because we have \"SPARSE\" too.\n>\n> But maybe I'm missing something...\n"},{"id":"449685","messageId":"220227.86wnhg626a.gmgdl@evledraar.gmail.com","threadId":"57474","inReplyTo":"CAGTqyRwTEdwut4HKD2=MaBfG_tZqN_TjGPAjChzmjBubC0-wuQ@mail.gmail.com","subject":"Re: [PATCH 0/4] In PS1 prompt, make upstream state indicators consistent with other state indicators","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-02-27T10:19:03Z","receivedAt":"2022-02-27T10:20:51Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Sat, Feb 26 2022, Justin Donnelly wrote:\n\n> Thanks for the feedback. Comments interleaved below.\n>\n> On Fri, Feb 25, 2022 at 7:26 AM Ævar Arnfjörð Bjarmason\n> <avarab@gmail.com> wrote:\n>>\n>>\n>> On Fri, Feb 25 2022, Justin Donnelly via GitGitGadget wrote:\n>>\n>> I couldn't find any glaring issues here on a quick review, just a note.\n>>\n>> > These patches are about the characters and words that can be configured to\n>> > display in the PS1 prompt after the branch name. I've been unable to find a\n>> > consistent terminology. I refer to them as follows: [short | long] [type]\n>> > state indicator where short is for characters (e.g. ?), long is for words\n>> > (e.g. |SPARSE), and type is the type of indicator (e.g. sparse or upstream).\n>> > I'd be happy to change the commit messages to a different terminology if\n>> > that's preferred.\n>>\n>> I think that terminology is correct, in case you haven't seen it\n>> git-for-each-ref(1) talks about the \"short\" here as \"short\",\n>> \"trackshort\" etc.\n>>\n>> > There are a few inconsistencies with the PS1 prompt upstream state indicator\n>> > (GIT_PS1_SHOWUPSTREAM).\n>> >\n>> >  * With GIT_PS1_SHOWUPSTREAM=\"auto\", if there are no other short state\n>> >    indicators (e.g. + for staged changes, $ for stashed changes, etc.), the\n>> >    upstream state indicator appears adjacent to the branch name (e.g.\n>> >    (main=)) instead of being separated by SP or GIT_PS1_STATESEPARATOR (e.g.\n>> >    (main =)).\n>> >  * If there are long state indicators (e.g. |SPARSE), a short upstream state\n>> >    indicator (i.e. GIT_PS1_SHOWUPSTREAM=\"auto\") is to the right of the long\n>> >    state indicator (e.g. (main +|SPARSE=)) instead of with the other short\n>> >    state indicators (e.g. (main +=|SPARSE)).\n>>\n>> I think it would really help to in each commit message have a\n>> before/after comparison of the relevant PS1 output that's being changed.\n>\n> I agree that a before/after comparison would probably make it easier\n> to understand. Maybe some examples without upstream (for a baseline to\n> compare against) and a table that shows before/after for upstream.\n>\n> `__git_ps1` examples without upstream:\n> (main)\n> (main %)\n> (main *%)\n> (main|SPARSE)\n> (main %|SPARSE)\n> (main *%|SPARSE)\n> (main|SPARSE|REBASE 1/2)\n> (main %|SPARSE|REBASE 1/2)\n>\n> Of note:\n> 1. If there are short state indicators, they appear together after the\n> branch name and separated from it by `SP` or `GIT_PS1_STATESEPARATOR`.\n> 2. If there are long state indicators, they appear after short state\n> indicators if there are any, or after the branch name if there are no\n> short state indicators. Each long state indicator begins with a pipe\n> (`|`) as a separator.\n>\n> Patch 2 before/after:\n> | Before           | After            |\n> | ---------------- | ---------------- |\n> | (main=)          | (main =)         |\n> | (main|SPARSE=)   | (main =|SPARSE)  |\n> | (main %|SPARSE=) | (main %=|SPARSE) |\n>\n> Patch 3 before/after:\n> | Before                          | After                           |\n> | ------------------------------- | ------------------------------- |\n> | (main u=)                       | (main|u=)                       |\n> | (main u= origin/main)           | (main|u= origin/main)           |\n> | (main u+1)                      | (main|u+1)                      |\n> | (main u+1 origin/main)          | (main|u+1 origin/main)          |\n> | (main % u=)                     | (main %|u=)                     |\n> | (main % u= origin/main)         | (main %|u= origin/main)         |\n> | (main % u+1)                    | (main %|u+1)                    |\n> | (main % u+1 origin/main)        | (main %|u+1 origin/main)        |\n> | (main|SPARSE u=)                | (main|SPARSE|u=)                |\n> | (main|SPARSE u= origin/main)    | (main|SPARSE|u= origin/main)    |\n> | (main|SPARSE u+1)               | (main|SPARSE|u+1)               |\n> | (main|SPARSE u+1 origin/main)   | (main|SPARSE|u+1 origin/main)   |\n> | (main %|SPARSE u=)              | (main %|SPARSE|u=)              |\n> | (main %|SPARSE u= origin/main)  | (main %|SPARSE|u= origin/main)  |\n> | (main %|SPARSE u+1)             | (main %|SPARSE|u+1)             |\n> | (main %|SPARSE u+1 origin/main) | (main %|SPARSE|u+1 origin/main) |\n>\n> Note: These tables are inspired by [Markdown Guide extended\n> syntax](https://www.markdownguide.org/extended-syntax/#tables), but I\n> didn't wrap the PS1 prompt text in backticks or escape the pipe\n> because I thought that would make it more confusing. In short, they're\n> meant to be viewed as (monospaced font) text, not Markdown.\n\nThanks. These comparisons are really useful & would be nice to work into\nrelevant commit messages in a re-roll.\n\nI withdraw any suggestions about making this \"main|SPARSE|u=\" instead of\n\"main=|SPARSE|u\" or whatever. I think such a thing might still make\nsense, but it's clearly unrelated to the improvements you're making\nhere.\n\n>>\n>>\n>> I'm not sure how to readthis example. So before we said \"main +=|SPARSE\"\n>> but now we'll say \"main +|SPARSE=\", but without sparse we'll say\n>> \"main=\"?\n>>\n>> Aren't both of those harder to read than they need to be, shouldn't it\n>> be closer to:\n>>\n>>     main= |SPARSE\n>>\n>> Or:\n>>\n>>     main= |+SPARSE\n>>\n>> Or:\n>>\n>>     main= +|SPARSE\n>>\n>> I can't recall what the \"+\" there is (if any).\n>\n>\n> `+` is for staged changes (if `GIT_PS1_SHOWDIRTYSTATE` is a nonempty\n> value). So it's not directly related to upstream, but the addition of\n> another short state indicator changes things.\n\nThanks!\n\n>>\n>>\n>> I.e. the \"=\" refers to the ahead/behind state of \"main, it seems odd in\n>> both versions of your example that we're splitting it off from \"main\"\n>> because we have \"SPARSE\" too.\n>>\n>> But maybe I'm missing something...\n\n"},{"id":"449707","messageId":"1db836bb309989c4ad93ed6d32a5ef4075ac7020.1645991832.git.gitgitgadget@gmail.com","threadId":"57474","inReplyTo":"pull.1162.v2.git.1645991832.gitgitgadget@gmail.com","subject":"[PATCH v2 1/4] git-prompt: rename `upstream` to `upstream_type`","fromName":"Justin Donnelly via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-02-27T19:57:09Z","receivedAt":"2022-02-27T19:57:19Z","isPatch":true,"sender":{"key":"justinrdonnelly@gmail.com","avatar":"https://avatars.githubusercontent.com/u/24846452?v=4"},"body":"From: Justin Donnelly <justinrdonnelly@gmail.com>\n\nIn `__git_ps1_show_upstream` rename the variable `upstream` to\n`upstream_type`. This allows `__git_ps1_show_upstream` to reference a\nvariable named `upstream` that is declared `local` in `__git_ps1`, which\ncalls `__git_ps1_show_upstream`.\n\nSigned-off-by: Justin Donnelly <justinrdonnelly@gmail.com>\n---\n contrib/completion/git-prompt.sh | 26 +++++++++++++-------------\n 1 file changed, 13 insertions(+), 13 deletions(-)\n\ndiff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh\nindex db7c0068fb5..3997e099aa7 100644\n--- a/contrib/completion/git-prompt.sh\n+++ b/contrib/completion/git-prompt.sh\n@@ -115,7 +115,7 @@ __git_ps1_show_upstream ()\n {\n \tlocal key value\n \tlocal svn_remote svn_url_pattern count n\n-\tlocal upstream=git legacy=\"\" verbose=\"\" name=\"\"\n+\tlocal upstream_type=git legacy=\"\" verbose=\"\" name=\"\"\n \n \tsvn_remote=()\n \t# get some config options from git-config\n@@ -132,7 +132,7 @@ __git_ps1_show_upstream ()\n \t\tsvn-remote.*.url)\n \t\t\tsvn_remote[$((${#svn_remote[@]} + 1))]=\"$value\"\n \t\t\tsvn_url_pattern=\"$svn_url_pattern\\\\|$value\"\n-\t\t\tupstream=svn+git # default upstream is SVN if available, else git\n+\t\t\tupstream_type=svn+git # default upstream type is SVN if available, else git\n \t\t\t;;\n \t\tesac\n \tdone <<< \"$output\"\n@@ -141,16 +141,16 @@ __git_ps1_show_upstream ()\n \tlocal option\n \tfor option in ${GIT_PS1_SHOWUPSTREAM}; do\n \t\tcase \"$option\" in\n-\t\tgit|svn) upstream=\"$option\" ;;\n+\t\tgit|svn) upstream_type=\"$option\" ;;\n \t\tverbose) verbose=1 ;;\n \t\tlegacy)  legacy=1  ;;\n \t\tname)    name=1 ;;\n \t\tesac\n \tdone\n \n-\t# Find our upstream\n-\tcase \"$upstream\" in\n-\tgit)    upstream=\"@{upstream}\" ;;\n+\t# Find our upstream type\n+\tcase \"$upstream_type\" in\n+\tgit)    upstream_type=\"@{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@@ -167,12 +167,12 @@ __git_ps1_show_upstream ()\n \n \t\t\tif [[ -z \"$svn_upstream\" ]]; then\n \t\t\t\t# default branch name for checkouts with no layout:\n-\t\t\t\tupstream=${GIT_SVN_ID:-git-svn}\n+\t\t\t\tupstream_type=${GIT_SVN_ID:-git-svn}\n \t\t\telse\n-\t\t\t\tupstream=${svn_upstream#/}\n+\t\t\t\tupstream_type=${svn_upstream#/}\n \t\t\tfi\n-\t\telif [[ \"svn+git\" = \"$upstream\" ]]; then\n-\t\t\tupstream=\"@{upstream}\"\n+\t\telif [[ \"svn+git\" = \"$upstream_type\" ]]; then\n+\t\t\tupstream_type=\"@{upstream}\"\n \t\tfi\n \t\t;;\n \tesac\n@@ -180,11 +180,11 @@ __git_ps1_show_upstream ()\n \t# Find how many commits we are ahead/behind our upstream\n \tif [[ -z \"$legacy\" ]]; then\n \t\tcount=\"$(git rev-list --count --left-right \\\n-\t\t\t\t\"$upstream\"...HEAD 2>/dev/null)\"\n+\t\t\t\t\"$upstream_type\"...HEAD 2>/dev/null)\"\n \telse\n \t\t# produce equivalent output to --count for older versions of git\n \t\tlocal commits\n-\t\tif commits=\"$(git rev-list --left-right \"$upstream\"...HEAD 2>/dev/null)\"\n+\t\tif commits=\"$(git rev-list --left-right \"$upstream_type\"...HEAD 2>/dev/null)\"\n \t\tthen\n \t\t\tlocal commit behind=0 ahead=0\n \t\t\tfor commit in $commits\n@@ -229,7 +229,7 @@ __git_ps1_show_upstream ()\n \t\tesac\n \t\tif [[ -n \"$count\" && -n \"$name\" ]]; then\n \t\t\t__git_ps1_upstream_name=$(git rev-parse \\\n-\t\t\t\t--abbrev-ref \"$upstream\" 2>/dev/null)\n+\t\t\t\t--abbrev-ref \"$upstream_type\" 2>/dev/null)\n \t\t\tif [ $pcmode = yes ] && [ $ps1_expanded = yes ]; then\n \t\t\t\tp=\"$p \\${__git_ps1_upstream_name}\"\n \t\t\telse\n-- \ngitgitgadget\n\n"},{"id":"449708","messageId":"pull.1162.v2.git.1645991832.gitgitgadget@gmail.com","threadId":"57474","inReplyTo":"pull.1162.git.1645789446.gitgitgadget@gmail.com","subject":"[PATCH v2 0/4] In PS1 prompt, make upstream state indicators consistent with other state indicators","fromName":"Justin Donnelly via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-02-27T19:57:08Z","receivedAt":"2022-02-27T19:57:21Z","isPatch":true,"sender":{"key":"justinrdonnelly@gmail.com","avatar":"https://avatars.githubusercontent.com/u/24846452?v=4"},"body":"These patches are about the characters and words that can be configured to\ndisplay in the PS1 prompt after the branch name. I've been unable to find a\nconsistent terminology. I refer to them as follows: [short | long] [type]\nstate indicator where short is for characters (e.g. ?), long is for words\n(e.g. |SPARSE), and type is the type of indicator (e.g. sparse or upstream).\nI'd be happy to change the commit messages to a different terminology if\nthat's preferred.\n\nThere are a few inconsistencies with the PS1 prompt upstream state indicator\n(GIT_PS1_SHOWUPSTREAM).\n\n * With GIT_PS1_SHOWUPSTREAM=\"auto\", if there are no other short state\n   indicators (e.g. + for staged changes, $ for stashed changes, etc.), the\n   upstream state indicator appears adjacent to the branch name (e.g.\n   (main=)) instead of being separated by SP or GIT_PS1_STATESEPARATOR (e.g.\n   (main =)).\n * If there are long state indicators (e.g. |SPARSE), a short upstream state\n   indicator (i.e. GIT_PS1_SHOWUPSTREAM=\"auto\") is to the right of the long\n   state indicator (e.g. (main +|SPARSE=)) instead of with the other short\n   state indicators (e.g. (main +=|SPARSE)).\n * The long upstream state indicator (e.g. GIT_PS1_SHOWUPSTREAM=\"verbose\")\n   is separated from other (short or long) state indicators by a hard-coded\n   SP. Other long state indicators are separated by a hard-coded pipe (|).\n\nThese patches are to make the upstream state indicators more consistent with\nother state indicators.\n\n----------------------------------------------------------------------------\n\nChanges since v1:\n\n * Added __git_ps1 examples and before/after tables to commit messages where\n   applicable. This should make it clearer what the behavior is for other\n   (not upstream) state indicators, and how the patches make the upstream\n   state indicator more consistent.\n * Removed some extraneous information about long state indicators from\n   patch 2 commit message. This wasn't really helpful, and was a\n   distraction.\n\n----------------------------------------------------------------------------\n\nJustin Donnelly (4):\n  git-prompt: rename `upstream` to `upstream_type`\n  git-prompt: make upstream state indicator location consistent\n  git-prompt: make long upstream state indicator consistent\n  git-prompt: put upstream comments together\n\n contrib/completion/git-prompt.sh | 59 ++++++++++++++++----------------\n 1 file changed, 30 insertions(+), 29 deletions(-)\n\n\nbase-commit: 4c53a8c20f8984adb226293a3ffd7b88c3f4ac1a\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-1162%2Fjustinrdonnelly%2Fgit-prompt-upstream-consistency-v2\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1162/justinrdonnelly/git-prompt-upstream-consistency-v2\nPull-Request: https://github.com/gitgitgadget/git/pull/1162\n\nRange-diff vs v1:\n\n 1:  1db836bb309 = 1:  1db836bb309 git-prompt: rename `upstream` to `upstream_type`\n 2:  b503cac5ae3 ! 2:  4bf120b1bf8 git-prompt: make upstream state indicator location consistent\n     @@ Commit message\n          git-prompt: make upstream state indicator location consistent\n      \n          Make upstream state indicator location more consistent with similar\n     -    state indicators (e.g. sparse). Group the short state indicator (`=`,\n     -    `<`, `>`, or `<>`) with other short state indicators immediately after\n     -    the branch name. Group the long state indicator (e.g. `u+2-1\n     -    origin/main`) with other long state indicators after the short state\n     -    indicators. Previously short and long upstream state indicators appeared\n     -    after all other state indicators.\n     +    state indicators (e.g. sparse). Group the short upstream state indicator\n     +    (`=`, `<`, `>`, or `<>`) with other short state indicators immediately\n     +    after the branch name. Previously short and long upstream state\n     +    indicators appeared after all other state indicators.\n      \n          Use a separator (`SP` or `GIT_PS1_STATESEPARATOR`) between branch name\n          and short upstream state indicator. Previously the short upstream state\n          indicator would sometimes appear directly adjacent to the branch name\n     -    (e.g. `(main=)`) instead of being separated (e.g. `(main =)`).\n     +    instead of being separated.\n     +\n     +    For comparison, `__git_ps1` examples without upstream state indicator:\n     +    (main)\n     +    (main %)\n     +    (main *%)\n     +    (main|SPARSE)\n     +    (main %|SPARSE)\n     +    (main *%|SPARSE)\n     +    (main|SPARSE|REBASE 1/2)\n     +    (main %|SPARSE|REBASE 1/2)\n     +\n     +    Note that if there are short state indicators, they appear together\n     +    after the branch name and separated from it by `SP` or\n     +    `GIT_PS1_STATESEPARATOR`.\n     +\n     +    Before/after examples with short upstream state indicator:\n     +    | Before           | After            |\n     +    | ---------------- | ---------------- |\n     +    | (main=)          | (main =)         |\n     +    | (main|SPARSE=)   | (main =|SPARSE)  |\n     +    | (main %|SPARSE=) | (main %=|SPARSE) |\n      \n          Signed-off-by: Justin Donnelly <justinrdonnelly@gmail.com>\n      \n 3:  83766e33614 ! 3:  0af083413b8 git-prompt: make long upstream state indicator consistent\n     @@ Metadata\n       ## Commit message ##\n          git-prompt: make long upstream state indicator consistent\n      \n     -    Use a pipe as a delimiter between short state indicators and long\n     -    upstream state indicator (e.g. `(main *|u+2-1 origin/main)` instead of\n     -    `(main * u+2-1 origin/main)`) . This is consistent with long state\n     -    indicators for sparse and in-progress operations (e.g. merge).\n     +    Use a pipe as a separator before long upstream state indicator. This is\n     +    consistent with long state indicators for sparse and in-progress\n     +    operations (e.g. merge).\n     +\n     +    For comparison, `__git_ps1` examples without upstream state indicator:\n     +    (main)\n     +    (main %)\n     +    (main *%)\n     +    (main|SPARSE)\n     +    (main %|SPARSE)\n     +    (main *%|SPARSE)\n     +    (main|SPARSE|REBASE 1/2)\n     +    (main %|SPARSE|REBASE 1/2)\n     +\n     +    Note that if there are long state indicators, they appear after short\n     +    state indicators if there are any, or after the branch name if there are\n     +    no short state indicators. Each long state indicator begins with a pipe\n     +    (`|`) as a separator.\n     +\n     +    Before/after examples with long upstream state indicator:\n     +    | Before                          | After                           |\n     +    | ------------------------------- | ------------------------------- |\n     +    | (main u=)                       | (main|u=)                       |\n     +    | (main u= origin/main)           | (main|u= origin/main)           |\n     +    | (main u+1)                      | (main|u+1)                      |\n     +    | (main u+1 origin/main)          | (main|u+1 origin/main)          |\n     +    | (main % u=)                     | (main %|u=)                     |\n     +    | (main % u= origin/main)         | (main %|u= origin/main)         |\n     +    | (main % u+1)                    | (main %|u+1)                    |\n     +    | (main % u+1 origin/main)        | (main %|u+1 origin/main)        |\n     +    | (main|SPARSE u=)                | (main|SPARSE|u=)                |\n     +    | (main|SPARSE u= origin/main)    | (main|SPARSE|u= origin/main)    |\n     +    | (main|SPARSE u+1)               | (main|SPARSE|u+1)               |\n     +    | (main|SPARSE u+1 origin/main)   | (main|SPARSE|u+1 origin/main)   |\n     +    | (main %|SPARSE u=)              | (main %|SPARSE|u=)              |\n     +    | (main %|SPARSE u= origin/main)  | (main %|SPARSE|u= origin/main)  |\n     +    | (main %|SPARSE u+1)             | (main %|SPARSE|u+1)             |\n     +    | (main %|SPARSE u+1 origin/main) | (main %|SPARSE|u+1 origin/main) |\n      \n          Signed-off-by: Justin Donnelly <justinrdonnelly@gmail.com>\n      \n 4:  58ff3d8affe = 4:  06e51dc5093 git-prompt: put upstream comments together\n\n-- \ngitgitgadget\n"},{"id":"449709","messageId":"4bf120b1bf89dfd10b2a1a9297169904223a6d9b.1645991832.git.gitgitgadget@gmail.com","threadId":"57474","inReplyTo":"pull.1162.v2.git.1645991832.gitgitgadget@gmail.com","subject":"[PATCH v2 2/4] git-prompt: make upstream state indicator location consistent","fromName":"Justin Donnelly via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-02-27T19:57:10Z","receivedAt":"2022-02-27T19:57:23Z","isPatch":true,"sender":{"key":"justinrdonnelly@gmail.com","avatar":"https://avatars.githubusercontent.com/u/24846452?v=4"},"body":"From: Justin Donnelly <justinrdonnelly@gmail.com>\n\nMake upstream state indicator location more consistent with similar\nstate indicators (e.g. sparse). Group the short upstream state indicator\n(`=`, `<`, `>`, or `<>`) with other short state indicators immediately\nafter the branch name. Previously short and long upstream state\nindicators appeared after all other state indicators.\n\nUse a separator (`SP` or `GIT_PS1_STATESEPARATOR`) between branch name\nand short upstream state indicator. Previously the short upstream state\nindicator would sometimes appear directly adjacent to the branch name\ninstead of being separated.\n\nFor comparison, `__git_ps1` examples without upstream state indicator:\n(main)\n(main %)\n(main *%)\n(main|SPARSE)\n(main %|SPARSE)\n(main *%|SPARSE)\n(main|SPARSE|REBASE 1/2)\n(main %|SPARSE|REBASE 1/2)\n\nNote that if there are short state indicators, they appear together\nafter the branch name and separated from it by `SP` or\n`GIT_PS1_STATESEPARATOR`.\n\nBefore/after examples with short upstream state indicator:\n| Before           | After            |\n| ---------------- | ---------------- |\n| (main=)          | (main =)         |\n| (main|SPARSE=)   | (main =|SPARSE)  |\n| (main %|SPARSE=) | (main %=|SPARSE) |\n\nSigned-off-by: Justin Donnelly <justinrdonnelly@gmail.com>\n---\n contrib/completion/git-prompt.sh | 25 +++++++++++++------------\n 1 file changed, 13 insertions(+), 12 deletions(-)\n\ndiff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh\nindex 3997e099aa7..613389a53bc 100644\n--- a/contrib/completion/git-prompt.sh\n+++ b/contrib/completion/git-prompt.sh\n@@ -109,7 +109,7 @@\n __git_printf_supports_v=\n printf -v __git_printf_supports_v -- '%s' yes >/dev/null 2>&1\n \n-# stores the divergence from upstream in $p\n+# stores the divergence from upstream in $p (for short status) or $upstream (for verbose status)\n # used by GIT_PS1_SHOWUPSTREAM\n __git_ps1_show_upstream ()\n {\n@@ -214,26 +214,26 @@ __git_ps1_show_upstream ()\n \t\t*)\t    # diverged from upstream\n \t\t\tp=\"<>\" ;;\n \t\tesac\n-\telse\n+\telse # verbose, set upstream instead of p\n \t\tcase \"$count\" in\n \t\t\"\") # no upstream\n-\t\t\tp=\"\" ;;\n+\t\t\tupstream=\"\" ;;\n \t\t\"0\t0\") # equal to upstream\n-\t\t\tp=\" u=\" ;;\n+\t\t\tupstream=\" u=\" ;;\n \t\t\"0\t\"*) # ahead of upstream\n-\t\t\tp=\" u+${count#0\t}\" ;;\n+\t\t\tupstream=\" u+${count#0\t}\" ;;\n \t\t*\"\t0\") # behind upstream\n-\t\t\tp=\" u-${count%\t0}\" ;;\n+\t\t\tupstream=\" u-${count%\t0}\" ;;\n \t\t*)\t    # diverged from upstream\n-\t\t\tp=\" u+${count#*\t}-${count%\t*}\" ;;\n+\t\t\tupstream=\" u+${count#*\t}-${count%\t*}\" ;;\n \t\tesac\n \t\tif [[ -n \"$count\" && -n \"$name\" ]]; then\n \t\t\t__git_ps1_upstream_name=$(git rev-parse \\\n \t\t\t\t--abbrev-ref \"$upstream_type\" 2>/dev/null)\n \t\t\tif [ $pcmode = yes ] && [ $ps1_expanded = yes ]; then\n-\t\t\t\tp=\"$p \\${__git_ps1_upstream_name}\"\n+\t\t\t\tupstream=\"$upstream \\${__git_ps1_upstream_name}\"\n \t\t\telse\n-\t\t\t\tp=\"$p ${__git_ps1_upstream_name}\"\n+\t\t\t\tupstream=\"$upstream ${__git_ps1_upstream_name}\"\n \t\t\t\t# not needed anymore; keep user's\n \t\t\t\t# environment clean\n \t\t\t\tunset __git_ps1_upstream_name\n@@ -512,7 +512,8 @@ __git_ps1 ()\n \tlocal u=\"\"\n \tlocal h=\"\"\n \tlocal c=\"\"\n-\tlocal p=\"\"\n+\tlocal p=\"\" # short version of upstream state indicator\n+\tlocal upstream=\"\" # verbose version of upstream state indicator\n \n \tif [ \"true\" = \"$inside_gitdir\" ]; then\n \t\tif [ \"true\" = \"$bare_repo\" ]; then\n@@ -568,8 +569,8 @@ __git_ps1 ()\n \t\tb=\"\\${__git_ps1_branch_name}\"\n \tfi\n \n-\tlocal f=\"$h$w$i$s$u\"\n-\tlocal gitstring=\"$c$b${f:+$z$f}${sparse}$r$p\"\n+\tlocal f=\"$h$w$i$s$u$p\"\n+\tlocal gitstring=\"$c$b${f:+$z$f}${sparse}$r${upstream}\"\n \n \tif [ $pcmode = yes ]; then\n \t\tif [ \"${__git_printf_supports_v-}\" != yes ]; then\n-- \ngitgitgadget\n\n"},{"id":"449710","messageId":"0af083413b81eb393373b6fe02c5dd4c04d90bdd.1645991832.git.gitgitgadget@gmail.com","threadId":"57474","inReplyTo":"pull.1162.v2.git.1645991832.gitgitgadget@gmail.com","subject":"[PATCH v2 3/4] git-prompt: make long upstream state indicator consistent","fromName":"Justin Donnelly via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-02-27T19:57:11Z","receivedAt":"2022-02-27T19:57:26Z","isPatch":true,"sender":{"key":"justinrdonnelly@gmail.com","avatar":"https://avatars.githubusercontent.com/u/24846452?v=4"},"body":"From: Justin Donnelly <justinrdonnelly@gmail.com>\n\nUse a pipe as a separator before long upstream state indicator. This is\nconsistent with long state indicators for sparse and in-progress\noperations (e.g. merge).\n\nFor comparison, `__git_ps1` examples without upstream state indicator:\n(main)\n(main %)\n(main *%)\n(main|SPARSE)\n(main %|SPARSE)\n(main *%|SPARSE)\n(main|SPARSE|REBASE 1/2)\n(main %|SPARSE|REBASE 1/2)\n\nNote that if there are long state indicators, they appear after short\nstate indicators if there are any, or after the branch name if there are\nno short state indicators. Each long state indicator begins with a pipe\n(`|`) as a separator.\n\nBefore/after examples with long upstream state indicator:\n| Before                          | After                           |\n| ------------------------------- | ------------------------------- |\n| (main u=)                       | (main|u=)                       |\n| (main u= origin/main)           | (main|u= origin/main)           |\n| (main u+1)                      | (main|u+1)                      |\n| (main u+1 origin/main)          | (main|u+1 origin/main)          |\n| (main % u=)                     | (main %|u=)                     |\n| (main % u= origin/main)         | (main %|u= origin/main)         |\n| (main % u+1)                    | (main %|u+1)                    |\n| (main % u+1 origin/main)        | (main %|u+1 origin/main)        |\n| (main|SPARSE u=)                | (main|SPARSE|u=)                |\n| (main|SPARSE u= origin/main)    | (main|SPARSE|u= origin/main)    |\n| (main|SPARSE u+1)               | (main|SPARSE|u+1)               |\n| (main|SPARSE u+1 origin/main)   | (main|SPARSE|u+1 origin/main)   |\n| (main %|SPARSE u=)              | (main %|SPARSE|u=)              |\n| (main %|SPARSE u= origin/main)  | (main %|SPARSE|u= origin/main)  |\n| (main %|SPARSE u+1)             | (main %|SPARSE|u+1)             |\n| (main %|SPARSE u+1 origin/main) | (main %|SPARSE|u+1 origin/main) |\n\nSigned-off-by: Justin Donnelly <justinrdonnelly@gmail.com>\n---\n contrib/completion/git-prompt.sh | 10 +++++-----\n 1 file changed, 5 insertions(+), 5 deletions(-)\n\ndiff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh\nindex 613389a53bc..2772f990888 100644\n--- a/contrib/completion/git-prompt.sh\n+++ b/contrib/completion/git-prompt.sh\n@@ -109,7 +109,7 @@\n __git_printf_supports_v=\n printf -v __git_printf_supports_v -- '%s' yes >/dev/null 2>&1\n \n-# stores the divergence from upstream in $p (for short status) or $upstream (for verbose status)\n+# stores the divergence from upstream in $p\n # used by GIT_PS1_SHOWUPSTREAM\n __git_ps1_show_upstream ()\n {\n@@ -219,13 +219,13 @@ __git_ps1_show_upstream ()\n \t\t\"\") # no upstream\n \t\t\tupstream=\"\" ;;\n \t\t\"0\t0\") # equal to upstream\n-\t\t\tupstream=\" u=\" ;;\n+\t\t\tupstream=\"|u=\" ;;\n \t\t\"0\t\"*) # ahead of upstream\n-\t\t\tupstream=\" u+${count#0\t}\" ;;\n+\t\t\tupstream=\"|u+${count#0\t}\" ;;\n \t\t*\"\t0\") # behind upstream\n-\t\t\tupstream=\" u-${count%\t0}\" ;;\n+\t\t\tupstream=\"|u-${count%\t0}\" ;;\n \t\t*)\t    # diverged from upstream\n-\t\t\tupstream=\" u+${count#*\t}-${count%\t*}\" ;;\n+\t\t\tupstream=\"|u+${count#*\t}-${count%\t*}\" ;;\n \t\tesac\n \t\tif [[ -n \"$count\" && -n \"$name\" ]]; then\n \t\t\t__git_ps1_upstream_name=$(git rev-parse \\\n-- \ngitgitgadget\n\n"},{"id":"449711","messageId":"06e51dc50937dc08c11e30b096c231a3d785f24c.1645991832.git.gitgitgadget@gmail.com","threadId":"57474","inReplyTo":"pull.1162.v2.git.1645991832.gitgitgadget@gmail.com","subject":"[PATCH v2 4/4] git-prompt: put upstream comments together","fromName":"Justin Donnelly via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-02-27T19:57:12Z","receivedAt":"2022-02-27T19:57:28Z","isPatch":true,"sender":{"key":"justinrdonnelly@gmail.com","avatar":"https://avatars.githubusercontent.com/u/24846452?v=4"},"body":"From: Justin Donnelly <justinrdonnelly@gmail.com>\n\nCommit 6d158cba28 (bash completion: Support \"divergence from upstream\"\nmessages in __git_ps1, 2010-06-17) introduced support for indicating\ndivergence from upstream in the PS1 prompt. The comments at the top of\ngit-prompt.sh that were introduced with that commit are several\nparagraphs long. Over the years, other comments have been inserted in\nbetween the paragraphs relating to divergence from upstream.\n\nThis commit puts the comments relating to divergence from upstream back\ntogether.\n\nSigned-off-by: Justin Donnelly <justinrdonnelly@gmail.com>\n---\n contrib/completion/git-prompt.sh | 10 +++++-----\n 1 file changed, 5 insertions(+), 5 deletions(-)\n\ndiff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh\nindex 2772f990888..87b2b916c03 100644\n--- a/contrib/completion/git-prompt.sh\n+++ b/contrib/completion/git-prompt.sh\n@@ -66,6 +66,11 @@\n #     git           always compare HEAD to @{upstream}\n #     svn           always compare HEAD to your SVN upstream\n #\n+# By default, __git_ps1 will compare HEAD to your SVN upstream if it can\n+# find one, or @{upstream} otherwise.  Once you have set\n+# GIT_PS1_SHOWUPSTREAM, you can override it on a per-repository basis by\n+# setting the bash.showUpstream config variable.\n+#\n # You can change the separator between the branch name and the above\n # state symbols by setting GIT_PS1_STATESEPARATOR. The default separator\n # is SP.\n@@ -79,11 +84,6 @@\n # single '?' character by setting GIT_PS1_COMPRESSSPARSESTATE, or omitted\n # by setting GIT_PS1_OMITSPARSESTATE.\n #\n-# By default, __git_ps1 will compare HEAD to your SVN upstream if it can\n-# find one, or @{upstream} otherwise.  Once you have set\n-# GIT_PS1_SHOWUPSTREAM, you can override it on a per-repository basis by\n-# setting the bash.showUpstream config variable.\n-#\n # If you would like to see more information about the identity of\n # commits checked out as a detached HEAD, set GIT_PS1_DESCRIBE_STYLE\n # to one of these values:\n-- \ngitgitgadget\n"},{"id":"451842","messageId":"220322.865yo6npg4.gmgdl@evledraar.gmail.com","threadId":"57474","inReplyTo":"pull.1162.v2.git.1645991832.gitgitgadget@gmail.com","subject":"Re: [PATCH v2 0/4] In PS1 prompt, make upstream state indicators consistent with other state indicators","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-03-22T12:25:35Z","receivedAt":"2022-03-22T12:26:36Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Sun, Feb 27 2022, Justin Donnelly via GitGitGadget wrote:\n\n> These patches are about the characters and words that can be configured to\n> display in the PS1 prompt after the branch name. I've been unable to find a\n> consistent terminology. I refer to them as follows: [short | long] [type]\n> state indicator where short is for characters (e.g. ?), long is for words\n> (e.g. |SPARSE), and type is the type of indicator (e.g. sparse or upstream).\n> I'd be happy to change the commit messages to a different terminology if\n> that's preferred.\n>\n> There are a few inconsistencies with the PS1 prompt upstream state indicator\n> (GIT_PS1_SHOWUPSTREAM).\n>\n>  * With GIT_PS1_SHOWUPSTREAM=\"auto\", if there are no other short state\n>    indicators (e.g. + for staged changes, $ for stashed changes, etc.), the\n>    upstream state indicator appears adjacent to the branch name (e.g.\n>    (main=)) instead of being separated by SP or GIT_PS1_STATESEPARATOR (e.g.\n>    (main =)).\n>  * If there are long state indicators (e.g. |SPARSE), a short upstream state\n>    indicator (i.e. GIT_PS1_SHOWUPSTREAM=\"auto\") is to the right of the long\n>    state indicator (e.g. (main +|SPARSE=)) instead of with the other short\n>    state indicators (e.g. (main +=|SPARSE)).\n>  * The long upstream state indicator (e.g. GIT_PS1_SHOWUPSTREAM=\"verbose\")\n>    is separated from other (short or long) state indicators by a hard-coded\n>    SP. Other long state indicators are separated by a hard-coded pipe (|).\n>\n> These patches are to make the upstream state indicators more consistent with\n> other state indicators.\n>\n> ----------------------------------------------------------------------------\n>\n> Changes since v1:\n>\n>  * Added __git_ps1 examples and before/after tables to commit messages where\n>    applicable. This should make it clearer what the behavior is for other\n>    (not upstream) state indicators, and how the patches make the upstream\n>    state indicator more consistent.\n>  * Removed some extraneous information about long state indicators from\n>    patch 2 commit message. This wasn't really helpful, and was a\n>    distraction.\n\nSince this was all in reponse to my review: I've looked this over again\nand this all LGTM now:\n\nReviewed-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n"},{"id":"452022","messageId":"xmqqa6dgsaam.fsf@gitster.g","threadId":"57474","inReplyTo":"220322.865yo6npg4.gmgdl@evledraar.gmail.com","subject":"Re: [PATCH v2 0/4] In PS1 prompt, make upstream state indicators consistent with other state indicators","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-03-23T20:06:57Z","receivedAt":"2022-03-23T20:07:04Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:\n\n> On Sun, Feb 27 2022, Justin Donnelly via GitGitGadget wrote:\n>\n>> These patches are about the characters and words that can be configured to\n>> display in the PS1 prompt after the branch name. I've been unable to find a\n>> consistent terminology. I refer to them as follows: [short | long] [type]\n>> state indicator where short is for characters (e.g. ?), long is for words\n>> (e.g. |SPARSE), and type is the type of indicator (e.g. sparse or upstream).\n>> I'd be happy to change the commit messages to a different terminology if\n>> that's preferred.\n>>\n>> There are a few inconsistencies with the PS1 prompt upstream state indicator\n>> (GIT_PS1_SHOWUPSTREAM).\n>>\n>>  * With GIT_PS1_SHOWUPSTREAM=\"auto\", if there are no other short state\n>>    indicators (e.g. + for staged changes, $ for stashed changes, etc.), the\n>>    upstream state indicator appears adjacent to the branch name (e.g.\n>>    (main=)) instead of being separated by SP or GIT_PS1_STATESEPARATOR (e.g.\n>>    (main =)).\n>>  * If there are long state indicators (e.g. |SPARSE), a short upstream state\n>>    indicator (i.e. GIT_PS1_SHOWUPSTREAM=\"auto\") is to the right of the long\n>>    state indicator (e.g. (main +|SPARSE=)) instead of with the other short\n>>    state indicators (e.g. (main +=|SPARSE)).\n>>  * The long upstream state indicator (e.g. GIT_PS1_SHOWUPSTREAM=\"verbose\")\n>>    is separated from other (short or long) state indicators by a hard-coded\n>>    SP. Other long state indicators are separated by a hard-coded pipe (|).\n>>\n>> These patches are to make the upstream state indicators more consistent with\n>> other state indicators.\n>>\n>> ----------------------------------------------------------------------------\n>>\n>> Changes since v1:\n>>\n>>  * Added __git_ps1 examples and before/after tables to commit messages where\n>>    applicable. This should make it clearer what the behavior is for other\n>>    (not upstream) state indicators, and how the patches make the upstream\n>>    state indicator more consistent.\n>>  * Removed some extraneous information about long state indicators from\n>>    patch 2 commit message. This wasn't really helpful, and was a\n>>    distraction.\n>\n> Since this was all in reponse to my review: I've looked this over again\n> and this all LGTM now:\n>\n> Reviewed-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n\nThanks, both.\n"}]}