git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/2] completion: enhance "current branch" display
@ 2009-05-10  8:56 Junio C Hamano
  2009-05-10 10:59 ` Johannes Sixt
  2009-05-10 21:18 ` Shawn O. Pearce
  0 siblings, 2 replies; 5+ messages in thread
From: Junio C Hamano @ 2009-05-10  8:56 UTC (permalink / raw)
  To: Shawn O. Pearce; +Cc: git

Introduce GIT_PS1_DESCRIBE option you can set to "contains", "branch", or
"describe" to tweak the way how a detached HEAD is described.

The default behaviour is to describe only exact match with some tag
(otherwise use the first 7 hexdigits) as before.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---

 * I do not think the new modes based on name-rev (aka "--contains") are
   much useful if you do your own development while on a detached HEAD,
   but they probably are useful for tourists who sightsee.

 contrib/completion/git-completion.bash |   15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index ccc7e0d..2490d5f 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -108,10 +108,21 @@ __git_ps1 ()
 			fi
 
 			b="$(git symbolic-ref HEAD 2>/dev/null)" || {
-				b="$(git describe --exact-match HEAD 2>/dev/null)" ||
+
+				b="$(
+				case "${GIT_PS1_DESCRIBE_STYLE-}" in
+				(contains)
+					git describe --contains HEAD ;;
+				(branch)
+					git describe --contains --all HEAD ;;
+				(describe)
+					git describe HEAD ;;
+				(* | default)
+					git describe --exact-match HEAD ;;
+				esac 2>/dev/null)" ||
+
 				b="$(cut -c1-7 "$g/HEAD" 2>/dev/null)..." ||
 				b="unknown"
-
 				b="($b)"
 			}
 		fi
-- 
1.6.3.9.g6345d

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

end of thread, other threads:[~2009-05-10 21:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-10  8:56 [PATCH 2/2] completion: enhance "current branch" display Junio C Hamano
2009-05-10 10:59 ` Johannes Sixt
2009-05-10 11:33   ` Michal Nazarewicz
2009-05-10 11:57     ` Johannes Sixt
2009-05-10 21:18 ` Shawn O. Pearce

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).