[RFC/PATCH] completion: __git_ps1() returns exit status now

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 0

however, 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@xxxxxxxxx>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]