Skip to content

Commit 08e6670

Browse files
sivaraamgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]> Signed-off-by: Kaartic Sivaraam <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ca7de7b commit 08e6670

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

git-rebase.sh

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -601,11 +601,23 @@ then
601601
test -z "$switch_to" ||
602602
GIT_REFLOG_ACTION="$GIT_REFLOG_ACTION: checkout $switch_to" \
603603
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
605611
finish_rebase
606612
exit 0
607613
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
609621
fi
610622
fi
611623

0 commit comments

Comments
 (0)