Skip to content

Commit 594672d

Browse files
committed
Merge branch 'ks/rebase-error-messages'
Error messages from "git rebase" have been somewhat cleaned up. * ks/rebase-error-messages: rebase: rebasing can also be done when HEAD is detached rebase: distinguish user input by quoting it rebase: consistently use branch_name variable
2 parents 593fdcc + 08e6670 commit 594672d

File tree

1 file changed

+25
-10
lines changed

1 file changed

+25
-10
lines changed

git-rebase.sh

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ then
477477
;;
478478
esac
479479
upstream=$(peel_committish "${upstream_name}") ||
480-
die "$(eval_gettext "invalid upstream \$upstream_name")"
480+
die "$(eval_gettext "invalid upstream '\$upstream_name'")"
481481
upstream_arg="$upstream_name"
482482
else
483483
if test -z "$onto"
@@ -518,7 +518,7 @@ case "$onto_name" in
518518
esac
519519

520520
# If the branch to rebase is given, that is the branch we will rebase
521-
# $branch_name -- branch being rebased, or HEAD (already detached)
521+
# $branch_name -- branch/commit being rebased, or HEAD (already detached)
522522
# $orig_head -- commit object name of tip of the branch before rebasing
523523
# $head_name -- refs/heads/<that-branch> or "detached HEAD"
524524
switch_to=
@@ -528,15 +528,18 @@ case "$#" in
528528
branch_name="$1"
529529
switch_to="$1"
530530

531-
if git show-ref --verify --quiet -- "refs/heads/$1" &&
532-
orig_head=$(git rev-parse -q --verify "refs/heads/$1")
531+
# Is it a local branch?
532+
if git show-ref --verify --quiet -- "refs/heads/$branch_name" &&
533+
orig_head=$(git rev-parse -q --verify "refs/heads/$branch_name")
533534
then
534-
head_name="refs/heads/$1"
535-
elif orig_head=$(git rev-parse -q --verify "$1")
535+
head_name="refs/heads/$branch_name"
536+
# If not is it a valid ref (branch or commit)?
537+
elif orig_head=$(git rev-parse -q --verify "$branch_name")
536538
then
537539
head_name="detached HEAD"
540+
538541
else
539-
die "$(eval_gettext "fatal: no such branch: \$branch_name")"
542+
die "$(eval_gettext "fatal: no such branch/commit '\$branch_name'")"
540543
fi
541544
;;
542545
0)
@@ -547,7 +550,7 @@ case "$#" in
547550
branch_name=$(expr "z$branch_name" : 'zrefs/heads/\(.*\)')
548551
else
549552
head_name="detached HEAD"
550-
branch_name=HEAD ;# detached
553+
branch_name=HEAD
551554
fi
552555
orig_head=$(git rev-parse --verify HEAD) || exit
553556
;;
@@ -598,11 +601,23 @@ then
598601
test -z "$switch_to" ||
599602
GIT_REFLOG_ACTION="$GIT_REFLOG_ACTION: checkout $switch_to" \
600603
git checkout -q "$switch_to" --
601-
say "$(eval_gettext "Current branch \$branch_name is up to date.")"
604+
if test "$branch_name" = "HEAD" &&
605+
! git symbolic-ref -q HEAD
606+
then
607+
say "$(eval_gettext "HEAD is up to date.")"
608+
else
609+
say "$(eval_gettext "Current branch \$branch_name is up to date.")"
610+
fi
602611
finish_rebase
603612
exit 0
604613
else
605-
say "$(eval_gettext "Current branch \$branch_name is up to date, rebase forced.")"
614+
if test "$branch_name" = "HEAD" &&
615+
! git symbolic-ref -q HEAD
616+
then
617+
say "$(eval_gettext "HEAD is up to date, rebase forced.")"
618+
else
619+
say "$(eval_gettext "Current branch \$branch_name is up to date, rebase forced.")"
620+
fi
606621
fi
607622
fi
608623

0 commit comments

Comments
 (0)