rebase: rebasing can also be done when HEAD is detached

Attempting to rebase when the HEAD is detached and is already up to date with upstream (so there's nothing to do), the following message is shown Current branch HEAD is up to date. which is clearly wrong as HEAD is not a branch. Handle the special case of HEAD correctly to give a more precise error message. 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>

Kaartic Sivaraam committed Dec 16, 2017 at 14:33 UTC 08e66700dff55640d4698c081ab3732528563396
1 file changed +14 -2
git-rebase.sh
+14 -2
@@ -601,11 +601,23 @@ then
601 test -z "$switch_to" ||
602 GIT_REFLOG_ACTION="$GIT_REFLOG_ACTION: checkout $switch_to" \
603 git checkout -q "$switch_to" --
604 - 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
611 finish_rebase
612 exit 0
613 else
608 - 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
621 fi
622 fi
623