From: SZEDER Gábor Date: Thu, 31 Mar 2011 21:41:18 +0000 (+0200) Subject: bash prompt: use bash builtins to find out current branch X-Git-Tag: v1.8.4-rc0~97^2~7 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/3a43c4b5bd19528229ef36b28d648d5ac98f15f1?ds=inline;hp=3a43c4b5bd19528229ef36b28d648d5ac98f15f1 bash prompt: use bash builtins to find out current branch __git_ps1() runs the '$(git symbolic-ref HEAD)' command substitution to find out whether we are on a branch and to find out the name of that branch. This imposes the overhead of fork()ing a subshell and fork()+exec()ing a git process. Since HEAD is in most cases a single-line file and the symbolic ref format is quite simple to recognize and parse, read and parse it using only bash builtins, thereby sparing all that fork()+exec() overhead. Don't display the git prompt if reading HEAD fails, because a readable HEAD is required for a git repository. HEAD can also be a symlink symbolic ref (due to 'core.preferSymlinkRefs'), so use bash builtins for reading HEAD only when HEAD is not a symlink. Signed-off-by: SZEDER Gábor ---