rebase: consistently use branch_name variable
The variable "branch_name" holds the <branch> parameter in "git rebase <upstream> <branch>", but one codepath did not use it after assigning $1 to it (instead it kept using $1). Make it use the variable consistently. Also, update an error message to say there is no such branch or commit, as we are expecting either of them, and not limiting ourselves to a branch name. Signed-off-by: Kaartic Sivaraam <kaartic.sivaraam@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Kaartic Sivaraam <kaartic.sivaraam@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
52015aaf9d
commit
3a9156adc7
@ -518,7 +518,7 @@ case "$onto_name" in
|
||||
esac
|
||||
|
||||
# If the branch to rebase is given, that is the branch we will rebase
|
||||
# $branch_name -- branch being rebased, or HEAD (already detached)
|
||||
# $branch_name -- branch/commit being rebased, or HEAD (already detached)
|
||||
# $orig_head -- commit object name of tip of the branch before rebasing
|
||||
# $head_name -- refs/heads/<that-branch> or "detached HEAD"
|
||||
switch_to=
|
||||
@ -528,15 +528,18 @@ case "$#" in
|
||||
branch_name="$1"
|
||||
switch_to="$1"
|
||||
|
||||
if git show-ref --verify --quiet -- "refs/heads/$1" &&
|
||||
orig_head=$(git rev-parse -q --verify "refs/heads/$1")
|
||||
# Is it a local branch?
|
||||
if git show-ref --verify --quiet -- "refs/heads/$branch_name" &&
|
||||
orig_head=$(git rev-parse -q --verify "refs/heads/$branch_name")
|
||||
then
|
||||
head_name="refs/heads/$1"
|
||||
elif orig_head=$(git rev-parse -q --verify "$1")
|
||||
head_name="refs/heads/$branch_name"
|
||||
# If not is it a valid ref (branch or commit)?
|
||||
elif orig_head=$(git rev-parse -q --verify "$branch_name")
|
||||
then
|
||||
head_name="detached HEAD"
|
||||
|
||||
else
|
||||
die "$(eval_gettext "fatal: no such branch: \$branch_name")"
|
||||
die "$(eval_gettext "fatal: no such branch/commit: \$branch_name")"
|
||||
fi
|
||||
;;
|
||||
0)
|
||||
@ -547,7 +550,7 @@ case "$#" in
|
||||
branch_name=$(expr "z$branch_name" : 'zrefs/heads/\(.*\)')
|
||||
else
|
||||
head_name="detached HEAD"
|
||||
branch_name=HEAD ;# detached
|
||||
branch_name=HEAD
|
||||
fi
|
||||
orig_head=$(git rev-parse --verify HEAD) || exit
|
||||
;;
|
||||
|
Loading…
Reference in New Issue
Block a user