git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Catalin Marinas <catalin.marinas@arm.com>
To: Eran Tromer <git2eran@tromer.org>
Cc: Robin Rosenberg <robin.rosenberg@dewire.com>, git@vger.kernel.org
Subject: Re: [StGIT PATCH] Bash snippet to show branch and patch in bash prompt
Date: Mon, 30 Oct 2006 10:24:50 +0000	[thread overview]
Message-ID: <tnxlkmy2j9p.fsf@arm.com> (raw)
In-Reply-To: <4545CC6F.90001@tromer.org> (Eran Tromer's message of "Mon, 30 Oct 2006 11:57:03 +0200")

Eran Tromer <git2eran@tromer.org> wrote:
> On 2006-10-30 01:37, Robin Rosenberg wrote:
>> +# include this in your bashrc or copy to /etc/bash_completions.d
>> +
>> +if [ "$PS1" ]; then
>> +    # trap 'PS1="\u@\h [$(stg top)] \w]\$ "' DEBUG
>> +    function stgtag
>> +    {
>> +	br=$(stg branch 2>/dev/null)
>> +	top=$(stg top 2>/dev/null)
>> +	if [[ -n "$br$top" ]];then
>> +	    echo "[$top@$br]"
>> +	    return
>> +	fi
>> +    }
>> +    PS1='\u@\h$(stgtag)\w\$ '
>> +
>> +fi
>
> That's an annoying 430ms delay at every prompt, on my box. Does StGIT do
> something expensive on every invocation?

Well, there are some forks. For every "stg" command, "git-symbolic-ref
HEAD" and "git-rev-parse --git-dir" are invoked to get the name of the
main branch and the .git directory. There is also the delay of
invoking python and loading the command modules in main.py (maybe I
should modify this to import the modules on demand, based on what
command was given).

Since the repository format is stable, you could use something like
this (it should be faster):

git_dir=$(git-rev-parse --git-dir 2> /dev/null)
ref=$(git-symbolic-ref HEAD 2> /dev/null)
br=${ref##*/}
top=$(cat $git_dir/patches/$br/current)

-- 

  reply	other threads:[~2006-10-30 10:25 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-29 23:37 [StGIT PATCH] Bash snippet to show branch and patch in bash prompt Robin Rosenberg
2006-10-30  9:57 ` Eran Tromer
2006-10-30 10:24   ` Catalin Marinas [this message]
2006-10-30 10:32   ` Robin Rosenberg
2006-10-30 10:59   ` [PATCH] " Robin Rosenberg
2006-10-30 15:03     ` Eran Tromer
2006-11-02 11:24       ` Catalin Marinas

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=tnxlkmy2j9p.fsf@arm.com \
    --to=catalin.marinas@arm.com \
    --cc=catalin.marinas@gmail.com \
    --cc=git2eran@tromer.org \
    --cc=git@vger.kernel.org \
    --cc=robin.rosenberg@dewire.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).