All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johannes Sixt <j6t@kdbg.org>
To: Heikki Hokkanen <hoxu@users.sf.net>, git@vger.kernel.org
Cc: szeder@ira.uka.de
Subject: Re: [PATCH] bash prompt: add option to disable for a repository
Date: Sat, 23 Nov 2013 15:42:47 +0100	[thread overview]
Message-ID: <5290BEE7.2070901@kdbg.org> (raw)
In-Reply-To: <1385212703-9611-1-git-send-email-hoxu@users.sf.net>

Am 23.11.2013 14:18, schrieb Heikki Hokkanen:
> 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@users.sf.net>
> ---
> 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
> +

Gah! This adds a fork+exec each time the prompt is shown. Not good,
particularly on Windows.

Since your intent is to disable the prompt in the home directory,
wouldn't that mean that most of the time you *don't* want the prompt?
Wouldn't you be better served with a method that *turns on* the prompt?
For example, a shell function that sets PS1 and another one that unsets
it? Or a wrapper that inspects a shell variable and calls __git_ps1 only
when you want a prompt.

>  	local short_sha
>  	if [ "$rev_parse_exit_code" = "0" ]; then
>  		short_sha="${repo_info##*$'\n'}"
> 

-- Hannes

  reply	other threads:[~2013-11-23 14:43 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-23 13:18 [PATCH] bash prompt: add option to disable for a repository Heikki Hokkanen
2013-11-23 14:42 ` Johannes Sixt [this message]
2013-11-23 16:31   ` Heikki Hokkanen
2013-11-25 23:43     ` Jonathan Nieder
2013-11-26  0:26       ` SZEDER Gábor
2013-11-26  7:01       ` Johannes Sixt
2013-11-26  8:40     ` Thomas Rast
2013-11-23 16:35 ` SZEDER Gábor
2013-11-25 16:38   ` Heikki Hokkanen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5290BEE7.2070901@kdbg.org \
    --to=j6t@kdbg.org \
    --cc=git@vger.kernel.org \
    --cc=hoxu@users.sf.net \
    --cc=szeder@ira.uka.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.