Skip to content

Commit

Permalink
rebase: read state outside loop
Browse files Browse the repository at this point in the history
The 'onto_name' state 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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Martin von Zweigbergk authored and Junio C Hamano committed Feb 10, 2011
1 parent 02ac45f commit 10ffca7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions git-rebase.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,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
Expand Down Expand Up @@ -123,9 +124,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
Expand Down

0 comments on commit 10ffca7

Please sign in to comment.