Skip to content

Commit 89d3eaf

Browse files
committed
Merge branch 'bw/rebase-merge-entire-branch'
"git rebase -m" could be asked to rebase an entire branch starting from the root, but failed by assuming that there always is a parent commit to the first commit on the branch. * bw/rebase-merge-entire-branch: git-rebase--merge: don't include absent parent as a base
2 parents 54b0ac5 + 79f4344 commit 89d3eaf

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

git-rebase--merge.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ call_merge () {
6767
GIT_MERGE_VERBOSITY=1 && export GIT_MERGE_VERBOSITY
6868
fi
6969
test -z "$strategy" && strategy=recursive
70-
eval 'git-merge-$strategy' $strategy_opts '"$cmt^" -- "$hd" "$cmt"'
70+
# If cmt doesn't have a parent, don't include it as a base
71+
base=$(git rev-parse --verify --quiet $cmt^)
72+
eval 'git-merge-$strategy' $strategy_opts $base ' -- "$hd" "$cmt"'
7173
rv=$?
7274
case "$rv" in
7375
0)

t/t3402-rebase-merge.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,15 @@ test_expect_success 'rebase -Xtheirs' '
8585
! grep 11 original
8686
'
8787

88+
test_expect_success 'rebase -Xtheirs from orphan' '
89+
git checkout --orphan orphan-conflicting master~2 &&
90+
echo "AB $T" >> original &&
91+
git commit -morphan-conflicting original &&
92+
git rebase -Xtheirs master &&
93+
grep AB original &&
94+
! grep 11 original
95+
'
96+
8897
test_expect_success 'merge and rebase should match' '
8998
git diff-tree -r test-rebase test-merge >difference &&
9099
if test -s difference

t/t3421-rebase-topology-linear.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ test_run_rebase () {
253253
"
254254
}
255255
test_run_rebase success ''
256-
test_run_rebase failure -m
256+
test_run_rebase success -m
257257
test_run_rebase success -i
258258
test_run_rebase success -p
259259

@@ -268,7 +268,7 @@ test_run_rebase () {
268268
"
269269
}
270270
test_run_rebase success ''
271-
test_run_rebase failure -m
271+
test_run_rebase success -m
272272
test_run_rebase success -i
273273
test_run_rebase failure -p
274274

0 commit comments

Comments
 (0)