git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Show presense of stashed changes in bash prompt.
@ 2009-06-02 11:43 Daniel Trstenjak
       [not found] ` <7vzlcqfyli.fsf@alter.siamese.dyndns.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Daniel Trstenjak @ 2009-06-02 11:43 UTC (permalink / raw)
  To: git; +Cc: Daniel Trstenjak

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

If the presense is shown is configurable by setting
GIT_PS1_SHOW_STASH_STATE 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>
---
 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..ed0c463 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_SHOW_STASH_STATE 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_SHOW_STASH_STATE-}" ]; 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

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

* Re: [PATCH] Show presense of stashed changes in bash prompt.
       [not found] ` <7vzlcqfyli.fsf@alter.siamese.dyndns.org>
@ 2009-06-02 15:29   ` Shawn O. Pearce
  2009-06-02 18:03     ` Daniel Trstenjak
  2009-06-02 18:04   ` Daniel Trstenjak
  1 sibling, 1 reply; 5+ messages in thread
From: Shawn O. Pearce @ 2009-06-02 15:29 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Daniel Trstenjak, Daniel Trstenjak

Junio C Hamano <gitster@pobox.com> wrote:
> Daniel Trstenjak <Daniel.Trstenjak@online.de> writes:
> > Avoid the forgetting of stashed changes by showing
> > them in the bash prompt.
> >
> > If the presense is shown is configurable by setting
> > GIT_PS1_SHOW_STASH_STATE to a nonempty value.
> 
> Why am I getting this deja-vu feeling about this patch, I wonder...  Is
> this a re-roll of a previously posted patch?

I don't know... I had a similar deja-vu feeling when I read it.
 
> Shawn?

Initial NAK, see below for the nit.
 
> > diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
> > index 98b9cbe..ed0c463 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_SHOW_STASH_STATE to a nonempty value. If something is stashed,
> > +#       then a '$' will be shown next to the branch name. 
> > +#

Can we call this GIT_PS1_SHOWSTASHSTATE to match the already present
GIT_PS1_SHOWDIRTYSTATE in at least style formatting?

The bike shed already sailed... GIT_PS1_SHOWDIRTYSTATE shipped in
1.6.3.  Lets keep the same style.

Otherwise it looks fine to me, when you resend you can add my
Acked-by: Shawn O. Pearce <spearce@spearce.org>

-- 
Shawn.

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

* Re: [PATCH] Show presense of stashed changes in bash prompt.
  2009-06-02 15:29   ` Shawn O. Pearce
@ 2009-06-02 18:03     ` Daniel Trstenjak
  2009-06-02 18:36       ` Jakub Narebski
  0 siblings, 1 reply; 5+ messages in thread
From: Daniel Trstenjak @ 2009-06-02 18:03 UTC (permalink / raw)
  To: Shawn O. Pearce; +Cc: Junio C Hamano, git, Daniel Trstenjak

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

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

* Re: [PATCH] Show presense of stashed changes in bash prompt.
       [not found] ` <7vzlcqfyli.fsf@alter.siamese.dyndns.org>
  2009-06-02 15:29   ` Shawn O. Pearce
@ 2009-06-02 18:04   ` Daniel Trstenjak
  1 sibling, 0 replies; 5+ messages in thread
From: Daniel Trstenjak @ 2009-06-02 18:04 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Shawn O. Pearce, git, Daniel Trstenjak


> Why am I getting this deja-vu feeling about this patch, I wonder...  Is
> this a re-roll of a previously posted patch?

Yup.

Greetings,
Daniel

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

* Re: [PATCH] Show presense of stashed changes in bash prompt.
  2009-06-02 18:03     ` Daniel Trstenjak
@ 2009-06-02 18:36       ` Jakub Narebski
  0 siblings, 0 replies; 5+ messages in thread
From: Jakub Narebski @ 2009-06-02 18:36 UTC (permalink / raw)
  To: git

Daniel Trstenjak wrote:

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

_presence_

-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git

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

end of thread, other threads:[~2009-06-02 18:36 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2009-06-02 18:36       ` Jakub Narebski
2009-06-02 18:04   ` Daniel Trstenjak

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