git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: martin.von.zweigbergk@gmail.com
To: git@vger.kernel.org, gitster@pobox.com
Cc: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>
Subject: [PATCH 3/5] rebase: read state outside loop
Date: Wed,  3 Nov 2010 22:09:38 +0100	[thread overview]
Message-ID: <1288818580-7576-4-git-send-email-martin.von.zweigbergk@gmail.com> (raw)
In-Reply-To: <1288818580-7576-1-git-send-email-martin.von.zweigbergk@gmail.com>

From: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>

The 'onto_name' state is used in 'git rebase --merge' is currently read
once for each commit that need to be applied. It doesn't change between
each iteration, however, so it should be moved out of the loop. This also
makes the code more readable. Also remove the unused variable 'end'.

Signed-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>
---
 git-rebase.sh |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/git-rebase.sh b/git-rebase.sh
index e0842e3..2c812b2 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -61,6 +61,7 @@ read_state () {
 	then
 		state_dir="$merge_dir"
 		prev_head=$(cat "$merge_dir"/prev_head) &&
+		onto_name=$(cat "$merge_dir"/onto_name) &&
 		end=$(cat "$merge_dir"/end) &&
 		msgnum=$(cat "$merge_dir"/msgnum)
 	else
@@ -122,9 +123,8 @@ call_merge () {
 	hd=$(git rev-parse --verify HEAD)
 	cmt_name=$(git symbolic-ref HEAD 2> /dev/null || echo HEAD)
 	msgnum=$(cat "$merge_dir/msgnum")
-	end=$(cat "$merge_dir/end")
 	eval GITHEAD_$cmt='"${cmt_name##refs/heads/}~$(($end - $msgnum))"'
-	eval GITHEAD_$hd='$(cat "$merge_dir/onto_name")'
+	eval GITHEAD_$hd='$onto_name'
 	export GITHEAD_$cmt GITHEAD_$hd
 	if test -n "$GIT_QUIET"
 	then
-- 
1.7.3.rc1.4.g5879b6

  parent reply	other threads:[~2010-11-04  3:10 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-03 21:09 [PATCH 0/5] Make git-rebase.sh more readable and easier to extend martin.von.zweigbergk
2010-11-03 21:09 ` [PATCH 1/5] rebase: clearer names for directory variables martin.von.zweigbergk
2010-11-03 21:09 ` [PATCH 2/5] rebase: refactor reading of state martin.von.zweigbergk
2010-11-03 21:09 ` martin.von.zweigbergk [this message]
2010-11-03 21:09 ` [PATCH 4/5] rebase: remove unused rebase state 'prev_head' martin.von.zweigbergk
2010-11-03 21:09 ` [PATCH 5/5] rebase: read state explicitly in '--abort' martin.von.zweigbergk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1288818580-7576-4-git-send-email-martin.von.zweigbergk@gmail.com \
    --to=martin.von.zweigbergk@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).