[PATCH] bash prompt: add option to disable for a repository

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

 



If bash.prompt is set to false, disable the prompt. This is useful
for huge repositories like the home directory.

Signed-off-by: Heikki Hokkanen <hoxu@xxxxxxxxxxxx>
---
git-prompt.sh performance seems to be quite bad for big repositories, so
without a way to disable it selectively for repositories, it becomes unusable
for people who have their homedir under git. This patch generalizes the problem
a bit by allowing the prompt to be disabled by setting bash.prompt to false in
any repository.

 contrib/completion/git-prompt.sh | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh
index 7b732d2..c982fde 100644
--- a/contrib/completion/git-prompt.sh
+++ b/contrib/completion/git-prompt.sh
@@ -84,6 +84,8 @@
 # GIT_PS1_SHOWCOLORHINTS to a nonempty value. The colors are based on
 # the colored output of "git status -sb" and are available only when
 # using __git_ps1 for PROMPT_COMMAND or precmd.
+#
+# To disable prompt for a repository, run "git config bash.prompt false"
 
 # check whether printf supports -v
 __git_printf_supports_v=
@@ -304,6 +306,12 @@ __git_ps1 ()
 		return
 	fi
 
+	local prompt_setting
+	prompt_setting=$(git config --bool bash.prompt)
+	if [ -n "$prompt_setting" ] && [ "$prompt_setting" == "false" ]; then
+		return
+	fi
+
 	local short_sha
 	if [ "$rev_parse_exit_code" = "0" ]; then
 		short_sha="${repo_info##*$'\n'}"
-- 
1.8.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]