Skip to content

Commit bb3f458

Browse files
johnkeepinggitster
authored andcommitted
rebase: fix fork-point with zero arguments
When no arguments are specified, $switch_to is empty so we end up passing the empty string to "git merge-base --fork-point", which causes an error. git-rebase carries on at this point, but in fact we have failed to apply the fork-point operation. It turns out that the test in t3400 that was meant to test this didn't actually need the fork-point behaviour, so enhance it to make sure that the fork-point is applied correctly. The modified test fails without the change to git-rebase.sh in this patch. Reported-by: Andreas Krey <[email protected]> Signed-off-by: John Keeping <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ad8261d commit bb3f458

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

git-rebase.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,8 @@ esac
534534

535535
if test "$fork_point" = t
536536
then
537-
new_upstream=$(git merge-base --fork-point "$upstream_name" "$switch_to")
537+
new_upstream=$(git merge-base --fork-point "$upstream_name" \
538+
"${switch_to:-HEAD}")
538539
if test -n "$new_upstream"
539540
then
540541
upstream=$new_upstream

t/t3400-rebase.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,19 @@ test_expect_success 'fail when upstream arg is missing and not configured' '
135135
'
136136

137137
test_expect_success 'default to common base in @{upstream}s reflog if no upstream arg' '
138+
git checkout -b default-base master &&
138139
git checkout -b default topic &&
139140
git config branch.default.remote . &&
140-
git config branch.default.merge refs/heads/master &&
141+
git config branch.default.merge refs/heads/default-base &&
141142
git rebase &&
142-
git rev-parse --verify master >expect &&
143+
git rev-parse --verify default-base >expect &&
144+
git rev-parse default~1 >actual &&
145+
test_cmp expect actual &&
146+
git checkout default-base &&
147+
git reset --hard HEAD^ &&
148+
git checkout default &&
149+
git rebase &&
150+
git rev-parse --verify default-base >expect &&
143151
git rev-parse default~1 >actual &&
144152
test_cmp expect actual
145153
'

0 commit comments

Comments
 (0)