Re: [PATCH 05/19] bash prompt: don't show the prompt when .git/HEAD is unreadable
- From
SZEDER Gábor <szeder@ira.uka.de>
- Date
- May 9, 2012, 19:45 UTC
- Message-ID
- <20120509194549.GA7824@goldbirke>
- In-Reply-To
- <7vipg5rvzf.fsf@alter.siamese.dyndns.org>
On Wed, May 09, 2012 at 12:32:36PM -0700, Junio C Hamano wrote:
Show 15 quoted lines
> SZEDER Gábor <szeder@ira.uka.de> writes: > > > diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash > > index ab26bdc8..cd6a5f12 100755 > > --- a/contrib/completion/git-completion.bash > > +++ b/contrib/completion/git-completion.bash > > @@ -258,7 +258,7 @@ __git_ps1 () > > esac 2>/dev/null)" || > > > > b="$(cut -c1-7 "$g/HEAD" 2>/dev/null)..." || > > - b="unknown" > > + return > > While you are touching the vicinity of the code, could we lose that "cut" > and replace it with "rev-parse --short HEAD", without the hardcoded 1-7?
Patch 15 (bash prompt: use bash builtins to get detached HEAD abbrev. object name) eliminates that 'cut' with some parameter expansions. While it doesn't respect the 'core.abbrev' config variable, it's much much faster, so IMHO it's worth it.
Gábor