rebase: remove $branch as synonym for $orig_head
The variables $branch and $orig_head were used as synonyms. To avoid confusion, remove $branch. The name 'orig_head' seems more suitable, since that is the name used when the variable is persisted. Signed-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Martin von Zweigbergk committed
Feb 6, 2011 at 13:43 UTC
cb82a05d5e2277d2019c43cadf8abee8bc6f97b6
1 file changed
+9
-10
git-rebase.sh
+9
-10
@@ -485,10 +485,10 @@ case "$#" in
485
switch_to="$1"
486
487
if git show-ref --verify --quiet -- "refs/heads/$1" &&
488
- branch=$(git rev-parse -q --verify "refs/heads/$1")
488
+ orig_head=$(git rev-parse -q --verify "refs/heads/$1")
489
then
490
head_name="refs/heads/$1"
491
- elif branch=$(git rev-parse -q --verify "$1")
491
+ elif orig_head=$(git rev-parse -q --verify "$1")
492
then
493
head_name="detached HEAD"
494
else
@@ -506,24 +506,23 @@ case "$#" in
506
head_name="detached HEAD"
507
branch_name=HEAD ;# detached
508
fi
509
- branch=$(git rev-parse --verify "${branch_name}^0") || exit
509
+ orig_head=$(git rev-parse --verify "${branch_name}^0") || exit
510
;;
511
esac
512
-orig_head=$branch
512
513
require_clean_work_tree "rebase" "Please commit or stash them."
514
516
-# Now we are rebasing commits $upstream..$branch (or with --root,
517
-# everything leading up to $branch) on top of $onto
515
+# Now we are rebasing commits $upstream..$orig_head (or with --root,
516
+# everything leading up to $orig_head) on top of $onto
517
518
# Check if we are already based on $onto with linear history,
519
# but this should be done only when upstream and onto are the same
520
# and if this is not an interactive rebase.
522
-mb=$(git merge-base "$onto" "$branch")
521
+mb=$(git merge-base "$onto" "$orig_head")
522
if test "$type" != interactive && test "$upstream" = "$onto" &&
523
test "$mb" = "$onto" &&
524
# linear history?
526
- ! (git rev-list --parents "$onto".."$branch" | sane_grep " .* ") > /dev/null
525
+ ! (git rev-list --parents "$onto".."$orig_head" | sane_grep " .* ") > /dev/null
526
then
527
if test -z "$force_rebase"
528
then
@@ -554,11 +553,11 @@ test "$type" = interactive && run_interactive_rebase
553
# Detach HEAD and reset the tree
554
say "First, rewinding head to replay your work on top of it..."
555
git checkout -q "$onto^0" || die "could not detach HEAD"
557
-git update-ref ORIG_HEAD $branch
556
+git update-ref ORIG_HEAD $orig_head
557
558
# If the $onto is a proper descendant of the tip of the branch, then
559
# we just fast-forwarded.
561
-if test "$mb" = "$branch"
560
+if test "$mb" = "$orig_head"
561
then
562
say "Fast-forwarded $branch_name to $onto_name."
563
move_to_original_branch