git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] git-prompt: add quiet upstream indicator option
@ 2025-11-15 18:54 Kiril Ivanov via GitGitGadget
  2025-11-15 18:54 ` [PATCH 1/3] t9903: shorten setup using test_commit Kiril Ivanov via GitGitGadget
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Kiril Ivanov via GitGitGadget @ 2025-11-15 18:54 UTC (permalink / raw)
  To: git; +Cc: Kiril Ivanov

This patch series allows a cleaner git-prompt when the upstream indicator is
not actionable.

In particular, the '=' to the upstream can be redundant noise if the user is
always on a remote-tracking branch and only needs to be aware of any
divergence.

Since SHOWUPSTREAM already supports various options, I propose a new 'quiet'
option to limit it to actionable output (omit '=')

 * Default: branch =
 * Verbose: branch|u=
 * Verbose name: branch|u= remote/branch
 * Quiet: branch
 * Verbose quiet: branch|u
 * Verbose quiet name: branch|u remote/branch

Ahead/behind output is unaffected (default <> or verbose +N-M).

Kiril Ivanov (3):
  t9903: shorten setup using test_commit
  t9903: add upstream indicator tests
  git-prompt: add quiet upstream indicator option

 contrib/completion/git-prompt.sh | 14 ++++--
 t/t9903-bash-prompt.sh           | 86 ++++++++++++++++++++++++++------
 2 files changed, 80 insertions(+), 20 deletions(-)


base-commit: fd372d9b1a69a01a676398882bbe3840bf51fe72
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2101%2Fivanovkirilg%2Fquiet-option-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2101/ivanovkirilg/quiet-option-v1
Pull-Request: https://github.com/git/git/pull/2101
-- 
gitgitgadget

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 1/3] t9903: shorten setup using test_commit
  2025-11-15 18:54 [PATCH 0/3] git-prompt: add quiet upstream indicator option Kiril Ivanov via GitGitGadget
@ 2025-11-15 18:54 ` Kiril Ivanov via GitGitGadget
  2025-11-15 18:54 ` [PATCH 2/3] t9903: add upstream indicator tests Kiril Ivanov via GitGitGadget
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 10+ messages in thread
From: Kiril Ivanov via GitGitGadget @ 2025-11-15 18:54 UTC (permalink / raw)
  To: git; +Cc: Kiril Ivanov, Kiril Ivanov

From: Kiril Ivanov <ivanovkirilg@gmail.com>

Signed-off-by: Kiril Ivanov <ivanovkirilg@gmail.com>
---
 t/t9903-bash-prompt.sh | 27 +++++++++++----------------
 1 file changed, 11 insertions(+), 16 deletions(-)

diff --git a/t/t9903-bash-prompt.sh b/t/t9903-bash-prompt.sh
index 637a6f13a6..7628bc10fe 100755
--- a/t/t9903-bash-prompt.sh
+++ b/t/t9903-bash-prompt.sh
@@ -18,26 +18,21 @@ c_green='\001\e[32m\002'
 c_lblue='\001\e[1;34m\002'
 c_clear='\001\e[0m\002'
 
+# (main)                     (b1)
+# initial (t1) - second-b1 - third-b1 (t2)
+#             \
+#              second-b2 - another-b2 - yet-another-b2
+#                                       (b2)
 test_expect_success 'setup for prompt tests' '
 	git init otherrepo &&
-	echo 1 >file &&
-	git add file &&
-	test_tick &&
-	git commit -m initial &&
-	git tag -a -m msg1 t1 &&
+	test_commit --annotate initial file contents1 t1 &&
 	git checkout -b b1 &&
-	echo 2 >file &&
-	git commit -m "second b1" file &&
-	echo 3 >file &&
-	git commit -m "third b1" file &&
-	git tag -a -m msg2 t2 &&
+	test_commit --no-tag second-b1 file &&
+	test_commit --annotate third-b1 file contents2 t2 &&
 	git checkout -b b2 main &&
-	echo 0 >file &&
-	git commit -m "second b2" file &&
-	echo 00 >file &&
-	git commit -m "another b2" file &&
-	echo 000 >file &&
-	git commit -m "yet another b2" file &&
+	test_commit --no-tag second-b2 file &&
+	test_commit --no-tag another-b2 file &&
+	test_commit --no-tag yet-another-b2 file &&
 	mkdir ignored_dir &&
 	echo "ignored_dir/" >>.gitignore &&
 	git checkout main
-- 
gitgitgadget


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 2/3] t9903: add upstream indicator tests
  2025-11-15 18:54 [PATCH 0/3] git-prompt: add quiet upstream indicator option Kiril Ivanov via GitGitGadget
  2025-11-15 18:54 ` [PATCH 1/3] t9903: shorten setup using test_commit Kiril Ivanov via GitGitGadget
@ 2025-11-15 18:54 ` Kiril Ivanov via GitGitGadget
  2025-11-15 18:54 ` [PATCH 3/3] git-prompt: add quiet upstream indicator option Kiril Ivanov via GitGitGadget
  2025-11-15 20:07 ` [PATCH 0/3] " Junio C Hamano
  3 siblings, 0 replies; 10+ messages in thread
From: Kiril Ivanov via GitGitGadget @ 2025-11-15 18:54 UTC (permalink / raw)
  To: git; +Cc: Kiril Ivanov, Kiril Ivanov

From: Kiril Ivanov <ivanovkirilg@gmail.com>

The upstream indicator currently has no test coverage.

Since GIT_PS1_SHOWUPSTREAM supports various options, make these tests
parameterized with a matrix for expected results (ahead/behind/etc).

Signed-off-by: Kiril Ivanov <ivanovkirilg@gmail.com>
---
 t/t9903-bash-prompt.sh | 59 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 59 insertions(+)

diff --git a/t/t9903-bash-prompt.sh b/t/t9903-bash-prompt.sh
index 7628bc10fe..3997012d1c 100755
--- a/t/t9903-bash-prompt.sh
+++ b/t/t9903-bash-prompt.sh
@@ -25,6 +25,8 @@ c_clear='\001\e[0m\002'
 #                                       (b2)
 test_expect_success 'setup for prompt tests' '
 	git init otherrepo &&
+	git init --bare origin.git &&
+	git remote add origin origin.git &&
 	test_commit --annotate initial file contents1 t1 &&
 	git checkout -b b1 &&
 	test_commit --no-tag second-b1 file &&
@@ -35,6 +37,7 @@ test_expect_success 'setup for prompt tests' '
 	test_commit --no-tag yet-another-b2 file &&
 	mkdir ignored_dir &&
 	echo "ignored_dir/" >>.gitignore &&
+	git push --set-upstream origin main b1 b2 &&
 	git checkout main
 '
 
@@ -515,6 +518,62 @@ test_expect_success 'prompt - untracked files status indicator - not shown insid
 	test_cmp expected "$actual"
 '
 
+################################################################
+# Show Upstream
+options=(          short  verbose   'verbose name'    )
+expected_equal=(   ' ='   '|u='     '|u= origin/main' )
+expected_ahead=(   ' >'   '|u+1'    '|u+1 origin/main')
+expected_behind=(  ' <'   '|u-1'    '|u-1 origin/b1'  )
+expected_diverged=(' <>'  '|u+1-1'  '|u+1-1 origin/b1')
+
+for i in ${!options[@]}
+do
+	option=${options[$i]}
+
+	test_expect_success "prompt - upstream status indicator - $option - equal" '
+		printf " (main${expected_equal[$i]})" >expected &&
+		GIT_PS1_SHOWUPSTREAM=$option &&
+		test_when_finished "sane_unset GIT_PS1_SHOWUPSTREAM" &&
+		__git_ps1 >"$actual" &&
+		test_cmp expected "$actual"
+	'
+
+	test_expect_success "prompt - upstream status indicator - $option - ahead" '
+		printf " (main${expected_ahead[$i]})" >expected &&
+		GIT_PS1_SHOWUPSTREAM=$option &&
+		test_when_finished "sane_unset GIT_PS1_SHOWUPSTREAM" &&
+		test_commit --no-tag ahead &&
+		test_when_finished "git reset HEAD^" &&
+		__git_ps1 >"$actual" &&
+		test_cmp expected "$actual"
+	'
+
+	test_expect_success "prompt - upstream status indicator - $option - behind" '
+		printf " (b1${expected_behind[$i]})" >expected &&
+		GIT_PS1_SHOWUPSTREAM=$option &&
+		test_when_finished "sane_unset GIT_PS1_SHOWUPSTREAM" &&
+		git checkout b1 &&
+		test_when_finished "git checkout main" &&
+		git reset HEAD^ &&
+		test_when_finished "git reset @{u}" &&
+		__git_ps1 >"$actual" &&
+		test_cmp expected "$actual"
+	'
+
+	test_expect_success "prompt - upstream status indicator - $option - diverged" '
+		printf " (b1${expected_diverged[$i]})" >expected &&
+		GIT_PS1_SHOWUPSTREAM=$option &&
+		test_when_finished "sane_unset GIT_PS1_SHOWUPSTREAM" &&
+		git checkout b1 &&
+		test_when_finished "git checkout main" &&
+		git reset HEAD^ &&
+		test_when_finished "git reset @{u}" &&
+		test_commit --no-tag ahead &&
+		__git_ps1 >"$actual" &&
+		test_cmp expected "$actual"
+	'
+done
+
 test_expect_success 'prompt - format string starting with dash' '
 	printf -- "-main" >expected &&
 	__git_ps1 "-%s" >"$actual" &&
-- 
gitgitgadget


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 3/3] git-prompt: add quiet upstream indicator option
  2025-11-15 18:54 [PATCH 0/3] git-prompt: add quiet upstream indicator option Kiril Ivanov via GitGitGadget
  2025-11-15 18:54 ` [PATCH 1/3] t9903: shorten setup using test_commit Kiril Ivanov via GitGitGadget
  2025-11-15 18:54 ` [PATCH 2/3] t9903: add upstream indicator tests Kiril Ivanov via GitGitGadget
@ 2025-11-15 18:54 ` Kiril Ivanov via GitGitGadget
  2025-11-20 16:01   ` D. Ben Knoble
  2025-11-15 20:07 ` [PATCH 0/3] " Junio C Hamano
  3 siblings, 1 reply; 10+ messages in thread
From: Kiril Ivanov via GitGitGadget @ 2025-11-15 18:54 UTC (permalink / raw)
  To: git; +Cc: Kiril Ivanov, Kiril Ivanov

From: Kiril Ivanov <ivanovkirilg@gmail.com>

Other single-char state indicators (e.g. stash, dirty) as well as
pipe-delimited indicators (e.g. '|CONFLICT') are only shown when
they are actionable.

OTOH, the upstream '=' (up-to-date with the upstream) is simply a
neutral state, which git-prompt is usually quiet about. Therefore,
allow users to hide it.

The 'verbose quiet' combination sounds weird but it may be what the
user wants, and does not conflict with anything else, so why not.

Signed-off-by: Kiril Ivanov <ivanovkirilg@gmail.com>
---
 contrib/completion/git-prompt.sh | 14 ++++++++++----
 t/t9903-bash-prompt.sh           | 10 +++++-----
 2 files changed, 15 insertions(+), 9 deletions(-)

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
@@ -55,13 +55,14 @@
 # enabled.
 #
 # If you would like to see the difference between HEAD and its upstream,
-# set GIT_PS1_SHOWUPSTREAM="auto".  A "<" indicates you are behind, ">"
-# indicates you are ahead, "<>" indicates you have diverged and "="
-# indicates that there is no difference. You can further control
+# set GIT_PS1_SHOWUPSTREAM to a nonempty value.  A "<" indicates you are
+# behind, ">" indicates you are ahead, "<>" indicates you have diverged
+# and "=" indicates that there is no difference.  You can further control
 # behaviour by setting GIT_PS1_SHOWUPSTREAM to a space-separated list
 # of values:
 #
 #     verbose       show number of commits ahead/behind (+/-) upstream
+#     quiet         omit '=' when there is no difference to the upstream
 #     name          if verbose, then also show the upstream abbrev name
 #     legacy        don't use the '--count' option available in recent
 #                   versions of git-rev-list
@@ -157,7 +158,7 @@ __git_ps1_show_upstream ()
 {
 	local key value
 	local svn_remotes="" svn_url_pattern="" count n
-	local upstream_type=git legacy="" verbose="" name=""
+	local upstream_type=git legacy="" verbose="" quiet="" name=""
 	local LF="$__git_LF"
 
 	# get some config options from git-config
@@ -187,6 +188,7 @@ __git_ps1_show_upstream ()
 		case "$option" in
 		git|svn) upstream_type="$option" ;;
 		verbose) verbose=1 ;;
+		quiet)   quiet=1   ;;
 		legacy)  legacy=1  ;;
 		name)    name=1 ;;
 		esac
@@ -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	}" ;;
diff --git a/t/t9903-bash-prompt.sh b/t/t9903-bash-prompt.sh
index 3997012d1c..855428f007 100755
--- a/t/t9903-bash-prompt.sh
+++ b/t/t9903-bash-prompt.sh
@@ -520,11 +520,11 @@ test_expect_success 'prompt - untracked files status indicator - not shown insid
 
 ################################################################
 # Show Upstream
-options=(          short  verbose   'verbose name'    )
-expected_equal=(   ' ='   '|u='     '|u= origin/main' )
-expected_ahead=(   ' >'   '|u+1'    '|u+1 origin/main')
-expected_behind=(  ' <'   '|u-1'    '|u-1 origin/b1'  )
-expected_diverged=(' <>'  '|u+1-1'  '|u+1-1 origin/b1')
+options=(          short  verbose   'verbose name'      quiet   'verbose quiet'  'verbose name quiet')
+expected_equal=(   ' ='   '|u='     '|u= origin/main'   ''      '|u'             '|u origin/main'    )
+expected_ahead=(   ' >'   '|u+1'    '|u+1 origin/main'  ' >'    '|u+1'           '|u+1 origin/main'  )
+expected_behind=(  ' <'   '|u-1'    '|u-1 origin/b1'    ' <'    '|u-1'           '|u-1 origin/b1'    )
+expected_diverged=(' <>'  '|u+1-1'  '|u+1-1 origin/b1'  ' <>'   '|u+1-1'         '|u+1-1 origin/b1'  )
 
 for i in ${!options[@]}
 do
-- 
gitgitgadget

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH 0/3] git-prompt: add quiet upstream indicator option
  2025-11-15 18:54 [PATCH 0/3] git-prompt: add quiet upstream indicator option Kiril Ivanov via GitGitGadget
                   ` (2 preceding siblings ...)
  2025-11-15 18:54 ` [PATCH 3/3] git-prompt: add quiet upstream indicator option Kiril Ivanov via GitGitGadget
@ 2025-11-15 20:07 ` Junio C Hamano
  2025-11-16 12:05   ` Kiril Ivanov
  3 siblings, 1 reply; 10+ messages in thread
From: Junio C Hamano @ 2025-11-15 20:07 UTC (permalink / raw)
  To: git; +Cc: Kiril Ivanov via GitGitGadget, Kiril Ivanov

"Kiril Ivanov via GitGitGadget" <gitgitgadget@gmail.com> writes:

> Kiril Ivanov (3):
>   t9903: shorten setup using test_commit
>   t9903: add upstream indicator tests
>   git-prompt: add quiet upstream indicator option
>
>  contrib/completion/git-prompt.sh | 14 ++++--
>  t/t9903-bash-prompt.sh           | 86 ++++++++++++++++++++++++++------


Not about the patch, but a slightly related tangent, but I wonder if
we want to update t/t9903-bash-prompt.sh script so that it starts
with "#!/bin/bash" not "#!/bin/sh" (this is a reaction to seeing
some bash-isms in these patches.  No complaints here, as the test
script is all about the command line prompt feature to be used with
bash and nothing else).



>  2 files changed, 80 insertions(+), 20 deletions(-)
>
>
> base-commit: fd372d9b1a69a01a676398882bbe3840bf51fe72
> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2101%2Fivanovkirilg%2Fquiet-option-v1
> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2101/ivanovkirilg/quiet-option-v1
> Pull-Request: https://github.com/git/git/pull/2101

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 0/3] git-prompt: add quiet upstream indicator option
  2025-11-15 20:07 ` [PATCH 0/3] " Junio C Hamano
@ 2025-11-16 12:05   ` Kiril Ivanov
  2025-11-16 16:55     ` Junio C Hamano
  0 siblings, 1 reply; 10+ messages in thread
From: Kiril Ivanov @ 2025-11-16 12:05 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Kiril Ivanov via GitGitGadget

Junio C Hamano <gitster@pobox.com> wrote:

> ... (this is a reaction to seeing
> some bash-isms in these patches.  No complaints here, as the test
> script is all about the command line prompt feature to be used with
> bash and nothing else).

Actually, this got me reconsidering.  The prompt feature claims at least
to support zsh in addition to bash, and it has had modifications to make
it more compliant:

<pull.1750.git.git.1721762306.gitgitgadget@gmail.com>

> After this patchset, the following shells work: bash, zsh, dash (since at
> least 0.5.8), free/net bsd sh, busybox-ash, mksh, openbsd sh, pdksh(!),
> Schily extended Bourne sh (bosh), yash.

And the test seems to run successfully under 'sh' in master with:
-. ./lib-bash.sh
+. ./test-lib.sh
(Passes normally, and fails when the 'expected' strings are clobbered.)


... Which is all to say that the bash-isms may be undesirable even here.

Unfortunately, I have been struggling (for an embarrassing couple of hours)
to replace them with something standard that still keeps the matrix-like
form of the test parameters.  If anyone more experienced in scripting has
an itch to help, it's welcome.

Since I originally intended this to be a two-line change, I'd rather wait
to see if it is even a welcome addition before I spend more time on it.

Thanks Junio for the feedback!

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 0/3] git-prompt: add quiet upstream indicator option
  2025-11-16 12:05   ` Kiril Ivanov
@ 2025-11-16 16:55     ` Junio C Hamano
  0 siblings, 0 replies; 10+ messages in thread
From: Junio C Hamano @ 2025-11-16 16:55 UTC (permalink / raw)
  To: Kiril Ivanov; +Cc: git, Kiril Ivanov via GitGitGadget

Kiril Ivanov <ivanovkirilg@gmail.com> writes:

> Junio C Hamano <gitster@pobox.com> wrote:
>
>> ... (this is a reaction to seeing
>> some bash-isms in these patches.  No complaints here, as the test
>> script is all about the command line prompt feature to be used with
>> bash and nothing else).
>
> Actually, this got me reconsidering.  The prompt feature claims at least
> to support zsh in addition to bash, and it has had modifications to make
> it more compliant:
>
> <pull.1750.git.git.1721762306.gitgitgadget@gmail.com>
>
>> After this patchset, the following shells work: bash, zsh, dash (since at
>> least 0.5.8), free/net bsd sh, busybox-ash, mksh, openbsd sh, pdksh(!),
>> Schily extended Bourne sh (bosh), yash.
>
> And the test seems to run successfully under 'sh' in master with:
> -. ./lib-bash.sh
> +. ./test-lib.sh
> (Passes normally, and fails when the 'expected' strings are clobbered.)

Ah, good finding.  So the inclusion of lib-bash.sh there is wrong,
and we shouldn't expect that we'd always run under bash.

> ... Which is all to say that the bash-isms may be undesirable even here.

You're right.  Thanks for correcting me.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 3/3] git-prompt: add quiet upstream indicator option
  2025-11-15 18:54 ` [PATCH 3/3] git-prompt: add quiet upstream indicator option Kiril Ivanov via GitGitGadget
@ 2025-11-20 16:01   ` D. Ben Knoble
  2025-11-20 18:05     ` Eric Sunshine
  0 siblings, 1 reply; 10+ messages in thread
From: D. Ben Knoble @ 2025-11-20 16:01 UTC (permalink / raw)
  To: Kiril Ivanov via GitGitGadget; +Cc: git, Kiril Ivanov

On Sat, Nov 15, 2025 at 1:55 PM Kiril Ivanov via GitGitGadget
<gitgitgadget@gmail.com> 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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 3/3] git-prompt: add quiet upstream indicator option
  2025-11-20 16:01   ` D. Ben Knoble
@ 2025-11-20 18:05     ` Eric Sunshine
  2025-11-20 18:18       ` D. Ben Knoble
  0 siblings, 1 reply; 10+ messages in thread
From: Eric Sunshine @ 2025-11-20 18:05 UTC (permalink / raw)
  To: D. Ben Knoble; +Cc: Kiril Ivanov via GitGitGadget, git, Kiril Ivanov

On Thu, Nov 20, 2025 at 11:10 AM D. Ben Knoble <ben.knoble@gmail.com> wrote:
> On Sat, Nov 15, 2025 at 1:55 PM Kiril Ivanov via GitGitGadget
> <gitgitgadget@gmail.com> wrote:
> > diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh
> > @@ -275,6 +279,8 @@ __git_ps1_show_upstream ()
> >                 "0      0") # equal to upstream
> > +                       [ "$quiet" ] &&
> > +                       upstream="|u" ||
> >                         upstream="|u=" ;;
> >                 "0      "*) # ahead of upstream
> >                         upstream="|u+${count#0  }" ;;
>
> Our coding style also prefers "test" to "[".

In this bash-specific script, the normal project coding style is
relaxed and `[` is used regularly, far more so than `test`, so use of
`[` here is appropriate and consistent with surrounding code.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 3/3] git-prompt: add quiet upstream indicator option
  2025-11-20 18:05     ` Eric Sunshine
@ 2025-11-20 18:18       ` D. Ben Knoble
  0 siblings, 0 replies; 10+ messages in thread
From: D. Ben Knoble @ 2025-11-20 18:18 UTC (permalink / raw)
  To: Eric Sunshine; +Cc: Kiril Ivanov via GitGitGadget, git, Kiril Ivanov

On Thu, Nov 20, 2025 at 1:06 PM Eric Sunshine <sunshine@sunshineco.com> wrote:
>
> On Thu, Nov 20, 2025 at 11:10 AM D. Ben Knoble <ben.knoble@gmail.com> wrote:
> > On Sat, Nov 15, 2025 at 1:55 PM Kiril Ivanov via GitGitGadget
> > <gitgitgadget@gmail.com> wrote:
> > > diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh
> > > @@ -275,6 +279,8 @@ __git_ps1_show_upstream ()
> > >                 "0      0") # equal to upstream
> > > +                       [ "$quiet" ] &&
> > > +                       upstream="|u" ||
> > >                         upstream="|u=" ;;
> > >                 "0      "*) # ahead of upstream
> > >                         upstream="|u+${count#0  }" ;;
> >
> > Our coding style also prefers "test" to "[".
>
> In this bash-specific script, the normal project coding style is
> relaxed and `[` is used regularly, far more so than `test`, so use of
> `[` here is appropriate and consistent with surrounding code.

Good to know, thanks! That'll teach me to respond without looking at
surrounding context ;)

-- 
D. Ben Knoble

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2025-11-20 18:18 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-15 18:54 [PATCH 0/3] git-prompt: add quiet upstream indicator option Kiril Ivanov via GitGitGadget
2025-11-15 18:54 ` [PATCH 1/3] t9903: shorten setup using test_commit Kiril Ivanov via GitGitGadget
2025-11-15 18:54 ` [PATCH 2/3] t9903: add upstream indicator tests Kiril Ivanov via GitGitGadget
2025-11-15 18:54 ` [PATCH 3/3] git-prompt: add quiet upstream indicator option Kiril Ivanov via GitGitGadget
2025-11-20 16:01   ` D. Ben Knoble
2025-11-20 18:05     ` Eric Sunshine
2025-11-20 18:18       ` D. Ben Knoble
2025-11-15 20:07 ` [PATCH 0/3] " Junio C Hamano
2025-11-16 12:05   ` Kiril Ivanov
2025-11-16 16:55     ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).