git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 3/3] git-prompt: add quiet upstream indicator option

From
KGKiril Ivanov via GitGitGadget <gitgitgadget@gmail.com>
Date
Nov 15, 2025, 18:54 UTC
Message-ID
<39b17bc64ff0d2e4162437ab745845c055315037.1763232863.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.2101.git.git.1763232863.gitgitgadget@gmail.com>
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
Previous: Kiril Ivanov via GitGitGadgetNext: D. Ben Knoble
Message 4 of 10 in “git-prompt: add quiet upstream indicator option”
  1. 0/3 git-prompt: add quiet upstream indicator optionKiril Ivanov via GitGitGadget, Nov 15, 2025
  2. 1/3 t9903: shorten setup using test_commitKiril Ivanov via GitGitGadget, Nov 15, 2025
  3. 2/3 t9903: add upstream indicator testsKiril Ivanov via GitGitGadget, Nov 15, 2025
  4. 3/3 git-prompt: add quiet upstream indicator optionKiril Ivanov via GitGitGadget, Nov 15, 2025
  5. D. Ben KnobleNov 20, 2025
  6. Eric SunshineNov 20, 2025
  7. D. Ben KnobleNov 20, 2025
  8. Junio C HamanoNov 15, 2025
  9. Kiril IvanovNov 16, 2025
  10. Junio C HamanoNov 16, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.