477
477
;;
478
478
esac
479
479
upstream=$( peel_committish " ${upstream_name} " ) ||
480
- die " $( eval_gettext " invalid upstream \$ upstream_name" ) "
480
+ die " $( eval_gettext " invalid upstream ' \$ upstream_name' " ) "
481
481
upstream_arg=" $upstream_name "
482
482
else
483
483
if test -z " $onto "
@@ -518,7 +518,7 @@ case "$onto_name" in
518
518
esac
519
519
520
520
# 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)
522
522
# $orig_head -- commit object name of tip of the branch before rebasing
523
523
# $head_name -- refs/heads/<that-branch> or "detached HEAD"
524
524
switch_to=
@@ -528,15 +528,18 @@ case "$#" in
528
528
branch_name=" $1 "
529
529
switch_to=" $1 "
530
530
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 " )
533
534
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 " )
536
538
then
537
539
head_name=" detached HEAD"
540
+
538
541
else
539
- die " $( eval_gettext " fatal: no such branch: \$ branch_name" ) "
542
+ die " $( eval_gettext " fatal: no such branch/commit ' \$ branch_name' " ) "
540
543
fi
541
544
;;
542
545
0)
@@ -547,7 +550,7 @@ case "$#" in
547
550
branch_name=$( expr " z$branch_name " : ' zrefs/heads/\(.*\)' )
548
551
else
549
552
head_name=" detached HEAD"
550
- branch_name=HEAD ; # detached
553
+ branch_name=HEAD
551
554
fi
552
555
orig_head=$( git rev-parse --verify HEAD) || exit
553
556
;;
@@ -598,11 +601,23 @@ then
598
601
test -z " $switch_to " ||
599
602
GIT_REFLOG_ACTION=" $GIT_REFLOG_ACTION : checkout $switch_to " \
600
603
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
602
611
finish_rebase
603
612
exit 0
604
613
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
606
621
fi
607
622
fi
608
623
0 commit comments