[RFC/PATCH] completion: __git_ps1() returns exit status now
- From
- Sergei Gavrikov <sergei.gavrikov@gmail.com>
- Date
- May 16, 2011, 13:23 UTC
- Message-ID
- <alpine.DEB.2.00.1105161615430.3397@sg-pc.belvok.com>
SYNOPSIS
$(__git_ps1 || __other_vcs_ps1)
It would be great if __git_ps1() could return exit status on it's finish, otherwise they have to check git_ps1 text output or recall __gitdir() to suppress alternative VCS prompt(s).
Patch attached, although I would prefer to check it at once, e.g.,
if [ -z "$g" ]; then return 1; fi
...
return 0however, I was in doubt about more verbose delta in such a case.
If I request the bad things or miss something, please, forget it.
Signed-off-by: Sergei Gavrikov <sergei.gavrikov@gmail.com> --- contrib/completion/git-completion.bash | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index b81f444..8b660ca 100755 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -222,7 +222,8 @@ __git_ps1_show_upstream () # __git_ps1 accepts 0 or 1 arguments (i.e., format string) -# returns text to add to bash PS1 prompt (includes branch name) +# prints text to add to bash PS1 prompt (includes branch name), +# returns 0 (exit status) if gitdir was processed, otherwise 1. __git_ps1 () { local g="$(__gitdir)" @@ -313,7 +314,11 @@ __git_ps1 () local f="$w$i$s$u" printf "${1:- (%s)}" "$c${b##refs/heads/}${f:+ $f}$r$p" + + return 0 fi + + return 1 } # __gitcomp_1 requires 2 arguments
-- 1.7.0.4