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 <a.krey@gmx.de> Signed-off-by: John Keeping <john@keeping.me.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
John Keeping committed
Jan 9, 2014 at 19:47 UTC
bb3f45838b859c8b17a53a24579a304333868cc8
2 files changed
+12
-3
git-rebase.sh
+2
-1
@@ -534,7 +534,8 @@ esac
534
535
if test "$fork_point" = t
536
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}")
539
if test -n "$new_upstream"
540
then
541
upstream=$new_upstream
t/t3400-rebase.sh
+10
-2
@@ -135,11 +135,19 @@ test_expect_success 'fail when upstream arg is missing and not configured' '
135
'
136
137
test_expect_success 'default to common base in @{upstream}s reflog if no upstream arg' '
138
+ git checkout -b default-base master &&
139
git checkout -b default topic &&
140
git config branch.default.remote . &&
140
- git config branch.default.merge refs/heads/master &&
141
+ git config branch.default.merge refs/heads/default-base &&
142
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 &&
151
git rev-parse default~1 >actual &&
152
test_cmp expect actual
153
'