git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Trstenjak <daniel.trstenjak@online.de>
To: "Shawn O. Pearce" <spearce@spearce.org>
Cc: Junio C Hamano <gitster@pobox.com>,
	git@vger.kernel.org,
	Daniel Trstenjak <Daniel.Trstenjak@science-computing.de>
Subject: Re: [PATCH] Show presense of stashed changes in bash prompt.
Date: Tue, 2 Jun 2009 20:03:22 +0200	[thread overview]
Message-ID: <20090602180322.GA5719@laptop> (raw)
In-Reply-To: <20090602152915.GK30527@spearce.org>

Avoid the forgetting of stashed changes by showing
them in the bash prompt.

If the presense is shown is configurable by setting
GIT_PS1_SHOWSTASHSTATE to a nonempty value.

The code for checking if the stash has entries is
taken from 'git-stash.sh'.

Signed-off-by: Daniel Trstenjak <daniel.trstenjak@online.de>
Acked-by: Shawn O. Pearce <spearce@spearce.org>
---
 contrib/completion/git-completion.bash |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 98b9cbe..c4ae423 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -40,6 +40,10 @@
 #       with the bash.showDirtyState variable, which defaults to true
 #       once GIT_PS1_SHOWDIRTYSTATE is enabled.
 #
+#       You can also see if currently something is stashed, by setting
+#       GIT_PS1_SHOWSTASHSTATE to a nonempty value. If something is stashed,
+#       then a '$' will be shown next to the branch name. 
+#
 # To submit patches:
 #
 #    *) Read Documentation/SubmittingPatches
@@ -127,6 +131,7 @@ __git_ps1 ()
 
 		local w
 		local i
+		local s
 		local c
 
 		if [ "true" = "$(git rev-parse --is-inside-git-dir 2>/dev/null)" ]; then
@@ -148,12 +153,15 @@ __git_ps1 ()
 					fi
 				fi
 			fi
+			if [ -n "${GIT_PS1_SHOWSTASHSTATE-}" ]; then
+			        git rev-parse --verify refs/stash >/dev/null 2>&1 && s="$"
+			fi
 		fi
 
 		if [ -n "${1-}" ]; then
-			printf "$1" "$c${b##refs/heads/}$w$i$r"
+			printf "$1" "$c${b##refs/heads/}$w$i$s$r"
 		else
-			printf " (%s)" "$c${b##refs/heads/}$w$i$r"
+			printf " (%s)" "$c${b##refs/heads/}$w$i$s$r"
 		fi
 	fi
 }
-- 
1.6.1.2

  reply	other threads:[~2009-06-02 18:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-02 11:43 [PATCH] Show presense of stashed changes in bash prompt Daniel Trstenjak
     [not found] ` <7vzlcqfyli.fsf@alter.siamese.dyndns.org>
2009-06-02 15:29   ` Shawn O. Pearce
2009-06-02 18:03     ` Daniel Trstenjak [this message]
2009-06-02 18:36       ` Jakub Narebski
2009-06-02 18:04   ` Daniel Trstenjak

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=20090602180322.GA5719@laptop \
    --to=daniel.trstenjak@online.de \
    --cc=Daniel.Trstenjak@science-computing.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=spearce@spearce.org \
    /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 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).