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

[PATCH 2/5] prompt: do not double-discriminate detached HEAD

From
Ramkumar Ramachandra <artagnon@gmail.com>
Date
Jun 18, 2013, 17:13 UTC
Message-ID
<1371575608-9980-3-git-send-email-artagnon@gmail.com>
In-Reply-To
<1371575608-9980-1-git-send-email-artagnon@gmail.com>

When GIT_PS1_SHOWCOLORHINTS is turned on, there is no need to put a detached HEAD within parenthesis: the color can be used to discriminate the detached HEAD.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
 contrib/completion/git-prompt.sh | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh
index 9ed6ff1..a127d3b 100644
--- a/contrib/completion/git-prompt.sh
+++ b/contrib/completion/git-prompt.sh
@@ -392,7 +392,11 @@ __git_ps1 ()
 					test -z $b && b="$(git rev-parse --short HEAD)"
 					;;
 				esac
-				b="($b)"
+
+				# if there is no color, use
+				# parenthesis to indicate that the
+				# HEAD is detached
+				test -n "${GIT_PS1_SHOWCOLORHINTS-}" || b="($b)"
 			}
 		fi
 
-- 
1.8.3.1.456.gb7f4cb6.dirty
Previous: Ramkumar RamachandraNext: Ramkumar Ramachandra
Message 3 of 6 in “Fix describe --contains --all”
  1. 0/5 Fix describe --contains --allRamkumar Ramachandra, Jun 18, 2013
  2. 1/5 prompt: clean up describe logicRamkumar Ramachandra, Jun 18, 2013
  3. 2/5 prompt: do not double-discriminate detached HEADRamkumar Ramachandra, Jun 18, 2013
  4. 3/5 name-rev: fix assumption about --name-only usageRamkumar Ramachandra, Jun 18, 2013
  5. 4/5 name-rev: strip trailing ^0 in when --name-onlyRamkumar Ramachandra, Jun 18, 2013
  6. 5/5 name-rev doc: rewrite --stdin paragraphRamkumar Ramachandra, Jun 18, 2013

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.