Thread (1 message) 1 message, 1 author, 2016-06-15

Re: [PATCH 1/2] Allow __git_ps1 to be used in PROMPT_COMMAND

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:54:59

Simon Oosthoek [off-list ref] writes:
 __git_ps1 ()
 {
+	local pcmode=no
+	#defaults/examples:
+	local ps1pc_start='\u@\h:\w '
+	local ps1pc_end='\$ '
+	local printf_format='(%s)'
+ ...
This conversion is wrong, given that ...
quoted hunk
@@ -284,6 +317,12 @@ __git_ps1 ()
 		fi
 
 		local f="$w$i$s$u"
-		printf -- "${1:- (%s)}" "$c${b##refs/heads/}${f:+ $f}$r$p"
... the original has a SP in front.  I've tentatively queued a
fix-up patch on the topic branch before merging it to 'pu'.
+		if [ $pcmode = yes ]; then
+			PS1="$ps1pc_start("
+			PS1="$PS1$c${b##refs/heads/}${f:+ $f}$r$p"
+			PS1="$PS1)$ps1pc_end"
+		else
+			printf -- "$printf_format" "$c${b##refs/heads/}${f:+ $f}$r$p"
+		fi
 	fi
 }
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help