git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Richard Hansen <rhansen@bbn.com>
To: gitster@pobox.com
Cc: j6t@kdbg.org, jess.austin@gmail.com, git@vger.kernel.org
Subject: [PATCH v5 1/2] git-prompt.sh: if pc mode, immediately set PS1 to a plain prompt
Date: Tue,  6 Jan 2015 20:22:26 -0500	[thread overview]
Message-ID: <1420593747-24110-2-git-send-email-rhansen@bbn.com> (raw)
In-Reply-To: <1420593747-24110-1-git-send-email-rhansen@bbn.com>

At the beginning of __git_ps1, right after determining that the
function is running in pc mode, set PS1 to a plain (undecorated)
prompt.  This makes it possible to simply return early without having
to set PS1 if the prompt should not be decorated.

Signed-off-by: Richard Hansen <rhansen@bbn.com>
---
 contrib/completion/git-prompt.sh | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh
index 729f769..b0de082 100644
--- a/contrib/completion/git-prompt.sh
+++ b/contrib/completion/git-prompt.sh
@@ -299,6 +299,10 @@ __git_ps1 ()
 			ps1pc_start="$1"
 			ps1pc_end="$2"
 			printf_format="${3:-$printf_format}"
+			# set PS1 to a plain prompt so that we can
+			# simply return early if the prompt should not
+			# be decorated
+			PS1="$ps1pc_start$ps1pc_end"
 		;;
 		0|1)	printf_format="${1:-$printf_format}"
 		;;
@@ -350,10 +354,6 @@ __git_ps1 ()
 	rev_parse_exit_code="$?"
 
 	if [ -z "$repo_info" ]; then
-		if [ $pcmode = yes ]; then
-			#In PC mode PS1 always needs to be set
-			PS1="$ps1pc_start$ps1pc_end"
-		fi
 		return
 	fi
 
@@ -412,9 +412,6 @@ __git_ps1 ()
 		else
 			local head=""
 			if ! __git_eread "$g/HEAD" head; then
-				if [ $pcmode = yes ]; then
-					PS1="$ps1pc_start$ps1pc_end"
-				fi
 				return
 			fi
 			# is it a symbolic ref?
-- 
2.2.1

  reply	other threads:[~2015-01-07  1:22 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-08 19:04 [PATCH] git-prompt.sh: Omit prompt for ignored directories Jess Austin
2014-10-08 21:12 ` Richard Hansen
     [not found]   ` <CANp8Xb8ETG-ZFCqrOk=f-RbxtRxehBmAR1O5ozLH80zimWq_Gw@mail.gmail.com>
2014-10-08 21:37     ` Fwd: " Jess Austin
2014-10-09  5:37       ` Richard Hansen
2014-10-09 10:27         ` Jess Austin
2014-10-09 22:09           ` Richard Hansen
2014-10-14  2:32             ` [PATCH] git-prompt.sh: Hide prompt for ignored pwd Jess Austin
2014-10-14 18:47               ` Johannes Sixt
2014-10-14 19:08                 ` Richard Hansen
2014-10-15  4:06                 ` [PATCH] git-prompt.sh: Option to hide " Jess Austin
2014-10-15 20:28                   ` Richard Hansen
2015-01-05  7:03                     ` [PATCH v4] " Richard Hansen
2015-01-06 23:31                       ` Junio C Hamano
2015-01-07  1:22                         ` [PATCH v5 0/2] " Richard Hansen
2015-01-07  1:22                           ` Richard Hansen [this message]
2015-01-14 11:45                             ` [PATCH v5 1/2] git-prompt.sh: if pc mode, immediately set PS1 SZEDER Gábor
2015-01-07  1:22                           ` [PATCH v5 2/2] git-prompt.sh: Option to hide prompt for ignored pwd Richard Hansen
2014-10-14 19:21               ` [PATCH] git-prompt.sh: Hide " Richard Hansen

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=1420593747-24110-2-git-send-email-rhansen@bbn.com \
    --to=rhansen@bbn.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=j6t@kdbg.org \
    --cc=jess.austin@gmail.com \
    /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).