Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
git-prompt: preserve value of $? inside shell prompt
author
Tony Finch
<dot@dotat.at>
Mon, 22 Dec 2014 18:09:25 +0000
(18:09 +0000)
committer
Junio C Hamano
<gitster@pobox.com>
Mon, 22 Dec 2014 19:58:56 +0000
(11:58 -0800)
If you have a prompt which displays the command exit status,
__git_ps1 without this change corrupts it, although it has
the correct value in the parent shell:
~/src/git (master) 0 $ set | grep ^PS1
PS1='\w$(__git_ps1) $? \$ '
~/src/git (master) 0 $ false
~/src/git (master) 0 $ echo $?
1
~/src/git (master) 0 $
There is a slightly ugly workaround:
~/src/git (master) 0 $ set | grep ^PS1
PS1='\w$(x=$?; __git_ps1; exit $x) $? \$ '
~/src/git (master) 0 $ false
~/src/git (master) 1 $
This change makes the workaround unnecessary.
Signed-off-by: Tony Finch <dot@dotat.at>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
contrib/completion/git-prompt.sh
patch
|
blob
|
history
raw
|
patch
| inline |
side by side
(parent:
bef111d
)
diff --git
a/contrib/completion/git-prompt.sh
b/contrib/completion/git-prompt.sh
index c5473dc8dba78b372fd95ef2bf5257ff5cdc3baf..5fe69d046f96161a1c360a49480cd118642e98f3 100644
(file)
--- a/
contrib/completion/git-prompt.sh
+++ b/
contrib/completion/git-prompt.sh
@@
-288,6
+288,7
@@
__git_eread ()
# In this mode you can request colored hints using GIT_PS1_SHOWCOLORHINTS=true
__git_ps1 ()
{
+ local exit=$?
local pcmode=no
local detached=no
local ps1pc_start='\u@\h:\w '
@@
-511,4
+512,7
@@
__git_ps1 ()
else
printf -- "$printf_format" "$gitstring"
fi
+
+ # preserve exit status
+ return $exit
}