summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaartic Sivaraam <kaartic.sivaraam@gmail.com>2017-12-16 14:33:17 +0530
committerJunio C Hamano <gitster@pobox.com>2017-12-19 10:02:14 -0800
commit3a9156adc774f28b3b0f880cdd285a7e01118d15 (patch)
treed517f2d0739b1043a14fdf276059b702f3f8c043
parent52015aaf9d19c97b52c47c7046058e6d029ff856 (diff)
downloadgit-3a9156adc774f28b3b0f880cdd285a7e01118d15.tar.gz
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>
-rwxr-xr-xgit-rebase.sh17
1 files changed, 10 insertions, 7 deletions
diff --git a/git-rebase.sh b/git-rebase.sh
index 60b70f3def..a299bcc520 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -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
;;