Re: [PATCH 11/19] bash prompt: use bash builtins to find out current branch
- From
SZEDER Gábor <szeder@ira.uka.de>
- Date
- May 9, 2012, 21:45 UTC
- Message-ID
- <20120509214534.GF6958@goldbirke>
- In-Reply-To
- <7vehqtqc6d.fsf@alter.siamese.dyndns.org>
On Wed, May 09, 2012 at 02:25:46PM -0700, Junio C Hamano wrote:
Show 9 quoted lines
> SZEDER Gábor <szeder@ira.uka.de> writes: > > > If the above is right, then we could check with bash builtins whether > > HEAD is a symbolic link, which is cheap, and stick to '$(git > > symbolic-ref HEAD)' if it is, or use bash builtins if it isn't, right? > > Sure. Alternatively, you could run "readlink" on it if that is available > built-in, and manipulate the result in string builtins, but that is a b/c > slow path anyway, so I wouldn't bother.
OK, will do that then.
'readlink' is not a bash builtin, so it would need the same number of fork()s and exec() as 'symbolic-ref'. Of course, the 'readlink' binary is much smaller than git and has less to do, so it might be a tiny bit faster, but for this rare corner case it really doesn't matter.