Skip to content

Commit 83c3161

Browse files
Robert ShearmanJunio C Hamano
authored andcommitted
rebase: Fix the detection of fast-forwarding of the current branch to upstream.
Previously, a rebasing operation with on a branch that is just tracking an upstream branch would output a confusing "Nothing to do" due to no patches being given to git-am. The test brings the behaviour back into line with that of just before e646c9c. Signed-off-by: Robert Shearman <rob@codeweavers.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent b63fafd commit 83c3161

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

git-rebase.sh

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -266,22 +266,19 @@ onto=$(git-rev-parse --verify "${onto_name}^0") || exit
266266

267267
# Check if we are already based on $onto, but this should be
268268
# done only when upstream and onto are the same.
269-
if test "$upstream" = "$onto"
269+
mb=$(git-merge-base "$onto" "$branch")
270+
if test "$upstream" = "$onto" && test "$mb" = "$onto"
270271
then
271-
mb=$(git-merge-base "$onto" "$branch")
272-
if test "$mb" = "$onto"
273-
then
274-
echo >&2 "Current branch $branch_name is up to date."
275-
exit 0
276-
fi
272+
echo >&2 "Current branch $branch_name is up to date."
273+
exit 0
277274
fi
278275

279276
# Rewind the head to "$onto"; this saves our current head in ORIG_HEAD.
280277
git-reset --hard "$onto"
281278

282279
# If the $onto is a proper descendant of the tip of the branch, then
283280
# we just fast forwarded.
284-
if test "$mb" = "$onto"
281+
if test "$mb" = "$branch"
285282
then
286283
echo >&2 "Fast-forwarded $branch to $newbase."
287284
exit 0

0 commit comments

Comments
 (0)