[PATCH 14/19] bash prompt: use bash builtins to find out current branch during rebase
- From
SZEDER Gábor <szeder@ira.uka.de>
- Date
- May 9, 2012, 00:44 UTC
- Message-ID
- <1336524290-30023-15-git-send-email-szeder@ira.uka.de>
- In-Reply-To
- <1336524290-30023-1-git-send-email-szeder@ira.uka.de>
During an ongoing interactive rebase __git_ps1() finds out the name of the rebased branch by executing the '$(cat .git/rebase-merge/head-name)' command substitution. That is not quite the most efficient way to read a single line single word file, because it imposes the overhead of fork()ing a subshell and fork()+exec()ing 'cat'.
Use the 'read' bash builtin instead to avoid that overhead.
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de> --- contrib/completion/git-completion.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 64b96f13..671032bf 100755 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -272,10 +272,10 @@ __git_ps1 () local b="" if [ -f "$__git_dir/rebase-merge/interactive" ]; then r="|REBASE-i" - b="$(cat "$__git_dir/rebase-merge/head-name")" + read b <"$__git_dir/rebase-merge/head-name" elif [ -d "$__git_dir/rebase-merge" ]; then r="|REBASE-m" - b="$(cat "$__git_dir/rebase-merge/head-name")" + read b <"$__git_dir/rebase-merge/head-name" else if [ -d "$__git_dir/rebase-apply" ]; then if [ -f "$__git_dir/rebase-apply/rebasing" ]; then
-- 1.7.10.1.541.gb1be298