From: D. Ben Knoble Date: Thu, 20 Nov 2025 16:01:57 GMT Subject: Re: [PATCH 3/3] git-prompt: add quiet upstream indicator option Message-ID: In-Reply-To: <39b17bc64ff0d2e4162437ab745845c055315037.1763232863.git.gitgitgadget@gmail.com> On Sat, Nov 15, 2025 at 1:55 PM Kiril Ivanov via GitGitGadget wrote: > diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh > index 6186c474ba..be23c522da 100644 > --- a/contrib/completion/git-prompt.sh > +++ b/contrib/completion/git-prompt.sh > @@ -262,6 +264,8 @@ __git_ps1_show_upstream () > "") # no upstream > p="" ;; > "0 0") # equal to upstream > + [ "$quiet" ] && > + p="" || > p="=" ;; > "0 "*) # ahead of upstream > p=">" ;; > @@ -275,6 +279,8 @@ __git_ps1_show_upstream () > "") # no upstream > upstream="" ;; > "0 0") # equal to upstream > + [ "$quiet" ] && > + upstream="|u" || > upstream="|u=" ;; > "0 "*) # ahead of upstream > upstream="|u+${count#0 }" ;; I generally advise avoiding "X && Y || Z" as a replacement for "if X; then Y; else Z; fi" because if X succeeds and Y fails, Z runs in the former but not the latter. Here, Y is an infallible (?) assignment, so we should not have any issues. OTOH, such subtleties may teach novice readers the wrong lesson ("oh, handy shortcut!" vs "I see how this works in restricted cases"). Using "if" is a bit more invasive wrt to the patch, but would be clearer to me. Our coding style also prefers "test" to "[". -- D. Ben Knoble