{"thread":{"id":"64485","subject":"[PATCH 0/3] git-prompt: add quiet upstream indicator option","startedAt":"2025-11-15T18:54:25Z","lastAt":"2025-11-20T18:18:55Z","messageCount":10,"participants":["Kiril Ivanov via GitGitGadget","Junio C Hamano","Kiril Ivanov","D. Ben Knoble","Eric Sunshine"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"530751","messageId":"pull.2101.git.git.1763232863.gitgitgadget@gmail.com","threadId":"64485","inReplyTo":null,"subject":"[PATCH 0/3] git-prompt: add quiet upstream indicator option","fromName":"Kiril Ivanov via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2025-11-15T18:54:20Z","receivedAt":"2025-11-15T18:54:25Z","isPatch":true,"sender":{"key":"ivanovkirilg@gmail.com","avatar":null},"body":"This patch series allows a cleaner git-prompt when the upstream indicator is\nnot actionable.\n\nIn particular, the '=' to the upstream can be redundant noise if the user is\nalways on a remote-tracking branch and only needs to be aware of any\ndivergence.\n\nSince SHOWUPSTREAM already supports various options, I propose a new 'quiet'\noption to limit it to actionable output (omit '=')\n\n * Default: branch =\n * Verbose: branch|u=\n * Verbose name: branch|u= remote/branch\n * Quiet: branch\n * Verbose quiet: branch|u\n * Verbose quiet name: branch|u remote/branch\n\nAhead/behind output is unaffected (default <> or verbose +N-M).\n\nKiril Ivanov (3):\n  t9903: shorten setup using test_commit\n  t9903: add upstream indicator tests\n  git-prompt: add quiet upstream indicator option\n\n contrib/completion/git-prompt.sh | 14 ++++--\n t/t9903-bash-prompt.sh           | 86 ++++++++++++++++++++++++++------\n 2 files changed, 80 insertions(+), 20 deletions(-)\n\n\nbase-commit: fd372d9b1a69a01a676398882bbe3840bf51fe72\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2101%2Fivanovkirilg%2Fquiet-option-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2101/ivanovkirilg/quiet-option-v1\nPull-Request: https://github.com/git/git/pull/2101\n-- \ngitgitgadget\n"},{"id":"530752","messageId":"2ebccd3096ba8f36f9ab166b674353890191d8bc.1763232863.git.gitgitgadget@gmail.com","threadId":"64485","inReplyTo":"pull.2101.git.git.1763232863.gitgitgadget@gmail.com","subject":"[PATCH 1/3] t9903: shorten setup using test_commit","fromName":"Kiril Ivanov via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2025-11-15T18:54:21Z","receivedAt":"2025-11-15T18:54:27Z","isPatch":true,"sender":{"key":"ivanovkirilg@gmail.com","avatar":null},"body":"From: Kiril Ivanov <ivanovkirilg@gmail.com>\n\nSigned-off-by: Kiril Ivanov <ivanovkirilg@gmail.com>\n---\n t/t9903-bash-prompt.sh | 27 +++++++++++----------------\n 1 file changed, 11 insertions(+), 16 deletions(-)\n\ndiff --git a/t/t9903-bash-prompt.sh b/t/t9903-bash-prompt.sh\nindex 637a6f13a6..7628bc10fe 100755\n--- a/t/t9903-bash-prompt.sh\n+++ b/t/t9903-bash-prompt.sh\n@@ -18,26 +18,21 @@ c_green='\\001\\e[32m\\002'\n c_lblue='\\001\\e[1;34m\\002'\n c_clear='\\001\\e[0m\\002'\n \n+# (main)                     (b1)\n+# initial (t1) - second-b1 - third-b1 (t2)\n+#             \\\n+#              second-b2 - another-b2 - yet-another-b2\n+#                                       (b2)\n test_expect_success 'setup for prompt tests' '\n \tgit init otherrepo &&\n-\techo 1 >file &&\n-\tgit add file &&\n-\ttest_tick &&\n-\tgit commit -m initial &&\n-\tgit tag -a -m msg1 t1 &&\n+\ttest_commit --annotate initial file contents1 t1 &&\n \tgit checkout -b b1 &&\n-\techo 2 >file &&\n-\tgit commit -m \"second b1\" file &&\n-\techo 3 >file &&\n-\tgit commit -m \"third b1\" file &&\n-\tgit tag -a -m msg2 t2 &&\n+\ttest_commit --no-tag second-b1 file &&\n+\ttest_commit --annotate third-b1 file contents2 t2 &&\n \tgit checkout -b b2 main &&\n-\techo 0 >file &&\n-\tgit commit -m \"second b2\" file &&\n-\techo 00 >file &&\n-\tgit commit -m \"another b2\" file &&\n-\techo 000 >file &&\n-\tgit commit -m \"yet another b2\" file &&\n+\ttest_commit --no-tag second-b2 file &&\n+\ttest_commit --no-tag another-b2 file &&\n+\ttest_commit --no-tag yet-another-b2 file &&\n \tmkdir ignored_dir &&\n \techo \"ignored_dir/\" >>.gitignore &&\n \tgit checkout main\n-- \ngitgitgadget\n\n"},{"id":"530753","messageId":"af5861933fe4f2f4aa4c81e080a035ce5cd45c34.1763232863.git.gitgitgadget@gmail.com","threadId":"64485","inReplyTo":"pull.2101.git.git.1763232863.gitgitgadget@gmail.com","subject":"[PATCH 2/3] t9903: add upstream indicator tests","fromName":"Kiril Ivanov via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2025-11-15T18:54:22Z","receivedAt":"2025-11-15T18:54:28Z","isPatch":true,"sender":{"key":"ivanovkirilg@gmail.com","avatar":null},"body":"From: Kiril Ivanov <ivanovkirilg@gmail.com>\n\nThe upstream indicator currently has no test coverage.\n\nSince GIT_PS1_SHOWUPSTREAM supports various options, make these tests\nparameterized with a matrix for expected results (ahead/behind/etc).\n\nSigned-off-by: Kiril Ivanov <ivanovkirilg@gmail.com>\n---\n t/t9903-bash-prompt.sh | 59 ++++++++++++++++++++++++++++++++++++++++++\n 1 file changed, 59 insertions(+)\n\ndiff --git a/t/t9903-bash-prompt.sh b/t/t9903-bash-prompt.sh\nindex 7628bc10fe..3997012d1c 100755\n--- a/t/t9903-bash-prompt.sh\n+++ b/t/t9903-bash-prompt.sh\n@@ -25,6 +25,8 @@ c_clear='\\001\\e[0m\\002'\n #                                       (b2)\n test_expect_success 'setup for prompt tests' '\n \tgit init otherrepo &&\n+\tgit init --bare origin.git &&\n+\tgit remote add origin origin.git &&\n \ttest_commit --annotate initial file contents1 t1 &&\n \tgit checkout -b b1 &&\n \ttest_commit --no-tag second-b1 file &&\n@@ -35,6 +37,7 @@ test_expect_success 'setup for prompt tests' '\n \ttest_commit --no-tag yet-another-b2 file &&\n \tmkdir ignored_dir &&\n \techo \"ignored_dir/\" >>.gitignore &&\n+\tgit push --set-upstream origin main b1 b2 &&\n \tgit checkout main\n '\n \n@@ -515,6 +518,62 @@ test_expect_success 'prompt - untracked files status indicator - not shown insid\n \ttest_cmp expected \"$actual\"\n '\n \n+################################################################\n+# Show Upstream\n+options=(          short  verbose   'verbose name'    )\n+expected_equal=(   ' ='   '|u='     '|u= origin/main' )\n+expected_ahead=(   ' >'   '|u+1'    '|u+1 origin/main')\n+expected_behind=(  ' <'   '|u-1'    '|u-1 origin/b1'  )\n+expected_diverged=(' <>'  '|u+1-1'  '|u+1-1 origin/b1')\n+\n+for i in ${!options[@]}\n+do\n+\toption=${options[$i]}\n+\n+\ttest_expect_success \"prompt - upstream status indicator - $option - equal\" '\n+\t\tprintf \" (main${expected_equal[$i]})\" >expected &&\n+\t\tGIT_PS1_SHOWUPSTREAM=$option &&\n+\t\ttest_when_finished \"sane_unset GIT_PS1_SHOWUPSTREAM\" &&\n+\t\t__git_ps1 >\"$actual\" &&\n+\t\ttest_cmp expected \"$actual\"\n+\t'\n+\n+\ttest_expect_success \"prompt - upstream status indicator - $option - ahead\" '\n+\t\tprintf \" (main${expected_ahead[$i]})\" >expected &&\n+\t\tGIT_PS1_SHOWUPSTREAM=$option &&\n+\t\ttest_when_finished \"sane_unset GIT_PS1_SHOWUPSTREAM\" &&\n+\t\ttest_commit --no-tag ahead &&\n+\t\ttest_when_finished \"git reset HEAD^\" &&\n+\t\t__git_ps1 >\"$actual\" &&\n+\t\ttest_cmp expected \"$actual\"\n+\t'\n+\n+\ttest_expect_success \"prompt - upstream status indicator - $option - behind\" '\n+\t\tprintf \" (b1${expected_behind[$i]})\" >expected &&\n+\t\tGIT_PS1_SHOWUPSTREAM=$option &&\n+\t\ttest_when_finished \"sane_unset GIT_PS1_SHOWUPSTREAM\" &&\n+\t\tgit checkout b1 &&\n+\t\ttest_when_finished \"git checkout main\" &&\n+\t\tgit reset HEAD^ &&\n+\t\ttest_when_finished \"git reset @{u}\" &&\n+\t\t__git_ps1 >\"$actual\" &&\n+\t\ttest_cmp expected \"$actual\"\n+\t'\n+\n+\ttest_expect_success \"prompt - upstream status indicator - $option - diverged\" '\n+\t\tprintf \" (b1${expected_diverged[$i]})\" >expected &&\n+\t\tGIT_PS1_SHOWUPSTREAM=$option &&\n+\t\ttest_when_finished \"sane_unset GIT_PS1_SHOWUPSTREAM\" &&\n+\t\tgit checkout b1 &&\n+\t\ttest_when_finished \"git checkout main\" &&\n+\t\tgit reset HEAD^ &&\n+\t\ttest_when_finished \"git reset @{u}\" &&\n+\t\ttest_commit --no-tag ahead &&\n+\t\t__git_ps1 >\"$actual\" &&\n+\t\ttest_cmp expected \"$actual\"\n+\t'\n+done\n+\n test_expect_success 'prompt - format string starting with dash' '\n \tprintf -- \"-main\" >expected &&\n \t__git_ps1 \"-%s\" >\"$actual\" &&\n-- \ngitgitgadget\n\n"},{"id":"530754","messageId":"39b17bc64ff0d2e4162437ab745845c055315037.1763232863.git.gitgitgadget@gmail.com","threadId":"64485","inReplyTo":"pull.2101.git.git.1763232863.gitgitgadget@gmail.com","subject":"[PATCH 3/3] git-prompt: add quiet upstream indicator option","fromName":"Kiril Ivanov via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2025-11-15T18:54:23Z","receivedAt":"2025-11-15T18:54:29Z","isPatch":true,"sender":{"key":"ivanovkirilg@gmail.com","avatar":null},"body":"From: Kiril Ivanov <ivanovkirilg@gmail.com>\n\nOther single-char state indicators (e.g. stash, dirty) as well as\npipe-delimited indicators (e.g. '|CONFLICT') are only shown when\nthey are actionable.\n\nOTOH, the upstream '=' (up-to-date with the upstream) is simply a\nneutral state, which git-prompt is usually quiet about. Therefore,\nallow users to hide it.\n\nThe 'verbose quiet' combination sounds weird but it may be what the\nuser wants, and does not conflict with anything else, so why not.\n\nSigned-off-by: Kiril Ivanov <ivanovkirilg@gmail.com>\n---\n contrib/completion/git-prompt.sh | 14 ++++++++++----\n t/t9903-bash-prompt.sh           | 10 +++++-----\n 2 files changed, 15 insertions(+), 9 deletions(-)\n\ndiff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh\nindex 6186c474ba..be23c522da 100644\n--- a/contrib/completion/git-prompt.sh\n+++ b/contrib/completion/git-prompt.sh\n@@ -55,13 +55,14 @@\n # enabled.\n #\n # If you would like to see the difference between HEAD and its upstream,\n-# set GIT_PS1_SHOWUPSTREAM=\"auto\".  A \"<\" indicates you are behind, \">\"\n-# indicates you are ahead, \"<>\" indicates you have diverged and \"=\"\n-# indicates that there is no difference. You can further control\n+# set GIT_PS1_SHOWUPSTREAM to a nonempty value.  A \"<\" indicates you are\n+# behind, \">\" indicates you are ahead, \"<>\" indicates you have diverged\n+# and \"=\" indicates that there is no difference.  You can further control\n # behaviour by setting GIT_PS1_SHOWUPSTREAM to a space-separated list\n # of values:\n #\n #     verbose       show number of commits ahead/behind (+/-) upstream\n+#     quiet         omit '=' when there is no difference to the upstream\n #     name          if verbose, then also show the upstream abbrev name\n #     legacy        don't use the '--count' option available in recent\n #                   versions of git-rev-list\n@@ -157,7 +158,7 @@ __git_ps1_show_upstream ()\n {\n \tlocal key value\n \tlocal svn_remotes=\"\" svn_url_pattern=\"\" count n\n-\tlocal upstream_type=git legacy=\"\" verbose=\"\" name=\"\"\n+\tlocal upstream_type=git legacy=\"\" verbose=\"\" quiet=\"\" name=\"\"\n \tlocal LF=\"$__git_LF\"\n \n \t# get some config options from git-config\n@@ -187,6 +188,7 @@ __git_ps1_show_upstream ()\n \t\tcase \"$option\" in\n \t\tgit|svn) upstream_type=\"$option\" ;;\n \t\tverbose) verbose=1 ;;\n+\t\tquiet)   quiet=1   ;;\n \t\tlegacy)  legacy=1  ;;\n \t\tname)    name=1 ;;\n \t\tesac\n@@ -262,6 +264,8 @@ __git_ps1_show_upstream ()\n \t\t\"\") # no upstream\n \t\t\tp=\"\" ;;\n \t\t\"0\t0\") # equal to upstream\n+\t\t\t[ \"$quiet\" ] &&\n+\t\t\tp=\"\" ||\n \t\t\tp=\"=\" ;;\n \t\t\"0\t\"*) # ahead of upstream\n \t\t\tp=\">\" ;;\n@@ -275,6 +279,8 @@ __git_ps1_show_upstream ()\n \t\t\"\") # no upstream\n \t\t\tupstream=\"\" ;;\n \t\t\"0\t0\") # equal to upstream\n+\t\t\t[ \"$quiet\" ] &&\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}\" ;;\ndiff --git a/t/t9903-bash-prompt.sh b/t/t9903-bash-prompt.sh\nindex 3997012d1c..855428f007 100755\n--- a/t/t9903-bash-prompt.sh\n+++ b/t/t9903-bash-prompt.sh\n@@ -520,11 +520,11 @@ test_expect_success 'prompt - untracked files status indicator - not shown insid\n \n ################################################################\n # Show Upstream\n-options=(          short  verbose   'verbose name'    )\n-expected_equal=(   ' ='   '|u='     '|u= origin/main' )\n-expected_ahead=(   ' >'   '|u+1'    '|u+1 origin/main')\n-expected_behind=(  ' <'   '|u-1'    '|u-1 origin/b1'  )\n-expected_diverged=(' <>'  '|u+1-1'  '|u+1-1 origin/b1')\n+options=(          short  verbose   'verbose name'      quiet   'verbose quiet'  'verbose name quiet')\n+expected_equal=(   ' ='   '|u='     '|u= origin/main'   ''      '|u'             '|u origin/main'    )\n+expected_ahead=(   ' >'   '|u+1'    '|u+1 origin/main'  ' >'    '|u+1'           '|u+1 origin/main'  )\n+expected_behind=(  ' <'   '|u-1'    '|u-1 origin/b1'    ' <'    '|u-1'           '|u-1 origin/b1'    )\n+expected_diverged=(' <>'  '|u+1-1'  '|u+1-1 origin/b1'  ' <>'   '|u+1-1'         '|u+1-1 origin/b1'  )\n \n for i in ${!options[@]}\n do\n-- \ngitgitgadget\n"},{"id":"530760","messageId":"xmqqjyzrdpqu.fsf@gitster.g","threadId":"64485","inReplyTo":"pull.2101.git.git.1763232863.gitgitgadget@gmail.com","subject":"Re: [PATCH 0/3] git-prompt: add quiet upstream indicator option","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-11-15T20:07:05Z","receivedAt":"2025-11-15T20:07:08Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Kiril Ivanov via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> Kiril Ivanov (3):\n>   t9903: shorten setup using test_commit\n>   t9903: add upstream indicator tests\n>   git-prompt: add quiet upstream indicator option\n>\n>  contrib/completion/git-prompt.sh | 14 ++++--\n>  t/t9903-bash-prompt.sh           | 86 ++++++++++++++++++++++++++------\n\n\nNot about the patch, but a slightly related tangent, but I wonder if\nwe want to update t/t9903-bash-prompt.sh script so that it starts\nwith \"#!/bin/bash\" not \"#!/bin/sh\" (this is a reaction to seeing\nsome bash-isms in these patches.  No complaints here, as the test\nscript is all about the command line prompt feature to be used with\nbash and nothing else).\n\n\n\n>  2 files changed, 80 insertions(+), 20 deletions(-)\n>\n>\n> base-commit: fd372d9b1a69a01a676398882bbe3840bf51fe72\n> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2101%2Fivanovkirilg%2Fquiet-option-v1\n> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2101/ivanovkirilg/quiet-option-v1\n> Pull-Request: https://github.com/git/git/pull/2101\n"},{"id":"530770","messageId":"CANHi5upZdwi33upTFL01NymMqK7dCWEbj8XAOEydCDMf4bSFzw@mail.gmail.com","threadId":"64485","inReplyTo":"xmqqjyzrdpqu.fsf@gitster.g","subject":"Re: [PATCH 0/3] git-prompt: add quiet upstream indicator option","fromName":"Kiril Ivanov","fromEmail":"ivanovkirilg@gmail.com","sentAt":"2025-11-16T12:05:17Z","receivedAt":"2025-11-16T12:05:29Z","isPatch":true,"sender":{"key":"ivanovkirilg@gmail.com","avatar":null},"body":"Junio C Hamano <gitster@pobox.com> wrote:\n\n> ... (this is a reaction to seeing\n> some bash-isms in these patches.  No complaints here, as the test\n> script is all about the command line prompt feature to be used with\n> bash and nothing else).\n\nActually, this got me reconsidering.  The prompt feature claims at least\nto support zsh in addition to bash, and it has had modifications to make\nit more compliant:\n\n<pull.1750.git.git.1721762306.gitgitgadget@gmail.com>\n\n> After this patchset, the following shells work: bash, zsh, dash (since at\n> least 0.5.8), free/net bsd sh, busybox-ash, mksh, openbsd sh, pdksh(!),\n> Schily extended Bourne sh (bosh), yash.\n\nAnd the test seems to run successfully under 'sh' in master with:\n-. ./lib-bash.sh\n+. ./test-lib.sh\n(Passes normally, and fails when the 'expected' strings are clobbered.)\n\n\n... Which is all to say that the bash-isms may be undesirable even here.\n\nUnfortunately, I have been struggling (for an embarrassing couple of hours)\nto replace them with something standard that still keeps the matrix-like\nform of the test parameters.  If anyone more experienced in scripting has\nan itch to help, it's welcome.\n\nSince I originally intended this to be a two-line change, I'd rather wait\nto see if it is even a welcome addition before I spend more time on it.\n\nThanks Junio for the feedback!\n"},{"id":"530774","messageId":"xmqqms4ldii7.fsf@gitster.g","threadId":"64485","inReplyTo":"CANHi5upZdwi33upTFL01NymMqK7dCWEbj8XAOEydCDMf4bSFzw@mail.gmail.com","subject":"Re: [PATCH 0/3] git-prompt: add quiet upstream indicator option","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-11-16T16:55:44Z","receivedAt":"2025-11-16T16:55:47Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Kiril Ivanov <ivanovkirilg@gmail.com> writes:\n\n> Junio C Hamano <gitster@pobox.com> wrote:\n>\n>> ... (this is a reaction to seeing\n>> some bash-isms in these patches.  No complaints here, as the test\n>> script is all about the command line prompt feature to be used with\n>> bash and nothing else).\n>\n> Actually, this got me reconsidering.  The prompt feature claims at least\n> to support zsh in addition to bash, and it has had modifications to make\n> it more compliant:\n>\n> <pull.1750.git.git.1721762306.gitgitgadget@gmail.com>\n>\n>> After this patchset, the following shells work: bash, zsh, dash (since at\n>> least 0.5.8), free/net bsd sh, busybox-ash, mksh, openbsd sh, pdksh(!),\n>> Schily extended Bourne sh (bosh), yash.\n>\n> And the test seems to run successfully under 'sh' in master with:\n> -. ./lib-bash.sh\n> +. ./test-lib.sh\n> (Passes normally, and fails when the 'expected' strings are clobbered.)\n\nAh, good finding.  So the inclusion of lib-bash.sh there is wrong,\nand we shouldn't expect that we'd always run under bash.\n\n> ... Which is all to say that the bash-isms may be undesirable even here.\n\nYou're right.  Thanks for correcting me.\n\n"},{"id":"531062","messageId":"CALnO6CBzE-+51LfgjpEv665oG6kZG9_4YZTv8qgqtNrhh+a-Bw@mail.gmail.com","threadId":"64485","inReplyTo":"39b17bc64ff0d2e4162437ab745845c055315037.1763232863.git.gitgitgadget@gmail.com","subject":"Re: [PATCH 3/3] git-prompt: add quiet upstream indicator option","fromName":"D. Ben Knoble","fromEmail":"ben.knoble@gmail.com","sentAt":"2025-11-20T16:01:57Z","receivedAt":"2025-11-20T16:02:10Z","isPatch":true,"sender":{"key":"ben.knoble@gmail.com","avatar":"https://avatars.githubusercontent.com/u/22802209?v=4"},"body":"On Sat, Nov 15, 2025 at 1:55 PM Kiril Ivanov via GitGitGadget\n<gitgitgadget@gmail.com> wrote:\n> diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh\n> index 6186c474ba..be23c522da 100644\n> --- a/contrib/completion/git-prompt.sh\n> +++ b/contrib/completion/git-prompt.sh\n> @@ -262,6 +264,8 @@ __git_ps1_show_upstream ()\n>                 \"\") # no upstream\n>                         p=\"\" ;;\n>                 \"0      0\") # equal to upstream\n> +                       [ \"$quiet\" ] &&\n> +                       p=\"\" ||\n>                         p=\"=\" ;;\n>                 \"0      \"*) # ahead of upstream\n>                         p=\">\" ;;\n> @@ -275,6 +279,8 @@ __git_ps1_show_upstream ()\n>                 \"\") # no upstream\n>                         upstream=\"\" ;;\n>                 \"0      0\") # equal to upstream\n> +                       [ \"$quiet\" ] &&\n> +                       upstream=\"|u\" ||\n>                         upstream=\"|u=\" ;;\n>                 \"0      \"*) # ahead of upstream\n>                         upstream=\"|u+${count#0  }\" ;;\n\nI generally advise avoiding \"X && Y || Z\" as a replacement for \"if X;\nthen Y; else Z; fi\" because if X succeeds and Y fails, Z runs in the\nformer but not the latter.\n\nHere, Y is an infallible (?) assignment, so we should not have any\nissues. OTOH, such subtleties may teach novice readers the wrong\nlesson (\"oh, handy shortcut!\" vs \"I see how this works in restricted\ncases\"). Using \"if\" is a bit more invasive wrt to the patch, but would\nbe clearer to me.\n\nOur coding style also prefers \"test\" to \"[\".\n\n-- \nD. Ben Knoble\n"},{"id":"531069","messageId":"CAPig+cTpDdTceBSYoVRBS7wKoSxURMeTA7TruiAmjgTX4B=m5w@mail.gmail.com","threadId":"64485","inReplyTo":"CALnO6CBzE-+51LfgjpEv665oG6kZG9_4YZTv8qgqtNrhh+a-Bw@mail.gmail.com","subject":"Re: [PATCH 3/3] git-prompt: add quiet upstream indicator option","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2025-11-20T18:05:55Z","receivedAt":"2025-11-20T18:06:07Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Thu, Nov 20, 2025 at 11:10 AM D. Ben Knoble <ben.knoble@gmail.com> wrote:\n> On Sat, Nov 15, 2025 at 1:55 PM Kiril Ivanov via GitGitGadget\n> <gitgitgadget@gmail.com> wrote:\n> > diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh\n> > @@ -275,6 +279,8 @@ __git_ps1_show_upstream ()\n> >                 \"0      0\") # equal to upstream\n> > +                       [ \"$quiet\" ] &&\n> > +                       upstream=\"|u\" ||\n> >                         upstream=\"|u=\" ;;\n> >                 \"0      \"*) # ahead of upstream\n> >                         upstream=\"|u+${count#0  }\" ;;\n>\n> Our coding style also prefers \"test\" to \"[\".\n\nIn this bash-specific script, the normal project coding style is\nrelaxed and `[` is used regularly, far more so than `test`, so use of\n`[` here is appropriate and consistent with surrounding code.\n"},{"id":"531070","messageId":"CALnO6CDin=zO5EBU2fC7xj6N9ZtAw0ge=GC=TRtE=2dM65+UxQ@mail.gmail.com","threadId":"64485","inReplyTo":"CAPig+cTpDdTceBSYoVRBS7wKoSxURMeTA7TruiAmjgTX4B=m5w@mail.gmail.com","subject":"Re: [PATCH 3/3] git-prompt: add quiet upstream indicator option","fromName":"D. Ben Knoble","fromEmail":"ben.knoble@gmail.com","sentAt":"2025-11-20T18:18:40Z","receivedAt":"2025-11-20T18:18:55Z","isPatch":true,"sender":{"key":"ben.knoble@gmail.com","avatar":"https://avatars.githubusercontent.com/u/22802209?v=4"},"body":"On Thu, Nov 20, 2025 at 1:06 PM Eric Sunshine <sunshine@sunshineco.com> wrote:\n>\n> On Thu, Nov 20, 2025 at 11:10 AM D. Ben Knoble <ben.knoble@gmail.com> wrote:\n> > On Sat, Nov 15, 2025 at 1:55 PM Kiril Ivanov via GitGitGadget\n> > <gitgitgadget@gmail.com> wrote:\n> > > diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh\n> > > @@ -275,6 +279,8 @@ __git_ps1_show_upstream ()\n> > >                 \"0      0\") # equal to upstream\n> > > +                       [ \"$quiet\" ] &&\n> > > +                       upstream=\"|u\" ||\n> > >                         upstream=\"|u=\" ;;\n> > >                 \"0      \"*) # ahead of upstream\n> > >                         upstream=\"|u+${count#0  }\" ;;\n> >\n> > Our coding style also prefers \"test\" to \"[\".\n>\n> In this bash-specific script, the normal project coding style is\n> relaxed and `[` is used regularly, far more so than `test`, so use of\n> `[` here is appropriate and consistent with surrounding code.\n\nGood to know, thanks! That'll teach me to respond without looking at\nsurrounding context ;)\n\n-- \nD. Ben Knoble\n"}]}