From: Maurice Bos <m-ou.se@m-ou.se>
To: unlisted-recipients:; (no To-header on input)
Subject: [PATCH] git-prompt.sh: make '+' work for unborn branches
Date: Thu, 6 Mar 2014 00:05:24 +0100 [thread overview]
Message-ID: <20140305233219.A6FF54284F@server> (raw)
For unborn branches, it now compares the index against the empty tree.
(Just like git status does.)
Signed-off-by: Maurice Bos <m-ou.se@m-ou.se>
---
contrib/completion/git-prompt.sh | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh
index 7b732d2..f656838 100644
--- a/contrib/completion/git-prompt.sh
+++ b/contrib/completion/git-prompt.sh
@@ -407,12 +407,14 @@ __git_ps1 ()
if [ -n "${GIT_PS1_SHOWDIRTYSTATE-}" ] &&
[ "$(git config --bool bash.showDirtyState)" != "false" ]
then
- git diff --no-ext-diff --quiet --exit-code || w="*"
- if [ -n "$short_sha" ]; then
- git diff-index --cached --quiet HEAD -- || i="+"
- else
+ local treeish=HEAD
+ if [ -z "$short_sha" ]; then
i="#"
+ # the empty tree
+ treeish=4b825dc642cb6eb9a060e54bf8d69288fbee4904
fi
+ git diff --no-ext-diff --quiet --exit-code || w="*"
+ git diff-index --cached --quiet $treeish -- || i="$i+"
fi
if [ -n "${GIT_PS1_SHOWSTASHSTATE-}" ] &&
[ -r "$g/refs/stash" ]; then
--
1.8.5.rc0.23.gaa27064
next reply other threads:[~2014-03-05 23:35 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-05 23:05 Maurice Bos [this message]
[not found] ` <20140306204026.GC29659@sigill.intra.peff.net>
[not found] ` <CABbCQwskqZzzRXm5K3dnOfRoAcx8jpsdskngmN7f1EvY6BONgw@mail.gmail.com>
2014-03-06 21:19 ` [PATCH] git-prompt.sh: make '+' work for unborn branches Maurice Bos
2014-03-27 23:08 ` Jeff King
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140305233219.A6FF54284F@server \
--to=m-ou.se@m-ou.se \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.