[PATCH 14/19] bash prompt: use bash builtins to find out current branch during rebase

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]