Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2009-05-10 12:53:19 +0400
committerJunio C Hamano <gitster@pobox.com>2009-05-17 06:46:31 +0400
commitff790b6a4bb7fa3bbccd5ea23cefd89da900aa2e (patch)
tree2c8d980e4b12acacca638b5fcc6e2b08d34f251f
parent8763dbb1b24c260243f69130c734c13563a16db6 (diff)
completion: simplify "current branch" in __git_ps1()
As I very often work on a detached HEAD, I found it pretty confusing when __git_ps1() said 'some-name'. Did I create a branch with that name by mistake, or do I happen to be on a commit with that exact tag? This patch fixes the issue by enclosing non branch names in a pair of parentheses when used to substitute %s token in __git_ps1() argument. It also fixes a small bug where the branch part is left empty when .git/HEAD is unreadable for whatever reason. The output now says "(unknown)". Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rwxr-xr-xcontrib/completion/git-completion.bash15
1 files changed, 8 insertions, 7 deletions
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index c2f8ea3444..be591468db 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -106,13 +106,14 @@ __git_ps1 ()
if [ -f "$g/BISECT_LOG" ]; then
r="|BISECTING"
fi
- if ! b="$(git symbolic-ref HEAD 2>/dev/null)"; then
- if ! b="$(git describe --exact-match HEAD 2>/dev/null)"; then
- if [ -r "$g/HEAD" ]; then
- b="$(cut -c1-7 "$g/HEAD")..."
- fi
- fi
- fi
+
+ b="$(git symbolic-ref HEAD 2>/dev/null)" || {
+ b="$(git describe --exact-match HEAD 2>/dev/null)" ||
+ b="$(cut -c1-7 "$g/HEAD" 2>/dev/null)..." ||
+ b="unknown"
+
+ b="($b)"
+ }
fi
local w