summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2016-05-06 14:45:44 -0700
committerJunio C Hamano <gitster@pobox.com>2016-05-06 14:45:44 -0700
commit89d3eafe9019b407d6b2cf8913c6845bde50b178 (patch)
treefcfdaf135f8c67c35f093048e6d6b35e4caa883a
parent54b0ac57ab90c233a5a076904173c82e3d7db509 (diff)
parent79f43447d2b542d1e521987287822ff376d43e93 (diff)
downloadgit-89d3eafe9019b407d6b2cf8913c6845bde50b178.tar.gz
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
-rw-r--r--git-rebase--merge.sh4
-rwxr-xr-xt/t3402-rebase-merge.sh9
-rwxr-xr-xt/t3421-rebase-topology-linear.sh4
3 files changed, 14 insertions, 3 deletions
diff --git a/git-rebase--merge.sh b/git-rebase--merge.sh
index 2cc2a6d273..8d43db9069 100644
--- a/git-rebase--merge.sh
+++ b/git-rebase--merge.sh
@@ -67,7 +67,9 @@ call_merge () {
GIT_MERGE_VERBOSITY=1 && export GIT_MERGE_VERBOSITY
fi
test -z "$strategy" && strategy=recursive
- eval 'git-merge-$strategy' $strategy_opts '"$cmt^" -- "$hd" "$cmt"'
+ # If cmt doesn't have a parent, don't include it as a base
+ base=$(git rev-parse --verify --quiet $cmt^)
+ eval 'git-merge-$strategy' $strategy_opts $base ' -- "$hd" "$cmt"'
rv=$?
case "$rv" in
0)
diff --git a/t/t3402-rebase-merge.sh b/t/t3402-rebase-merge.sh
index 8f64505e4f..488945e007 100755
--- a/t/t3402-rebase-merge.sh
+++ b/t/t3402-rebase-merge.sh
@@ -85,6 +85,15 @@ test_expect_success 'rebase -Xtheirs' '
! grep 11 original
'
+test_expect_success 'rebase -Xtheirs from orphan' '
+ git checkout --orphan orphan-conflicting master~2 &&
+ echo "AB $T" >> original &&
+ git commit -morphan-conflicting original &&
+ git rebase -Xtheirs master &&
+ grep AB original &&
+ ! grep 11 original
+'
+
test_expect_success 'merge and rebase should match' '
git diff-tree -r test-rebase test-merge >difference &&
if test -s difference
diff --git a/t/t3421-rebase-topology-linear.sh b/t/t3421-rebase-topology-linear.sh
index 9c55cba198..68fe2003ef 100755
--- a/t/t3421-rebase-topology-linear.sh
+++ b/t/t3421-rebase-topology-linear.sh
@@ -253,7 +253,7 @@ test_run_rebase () {
"
}
test_run_rebase success ''
-test_run_rebase failure -m
+test_run_rebase success -m
test_run_rebase success -i
test_run_rebase success -p
@@ -268,7 +268,7 @@ test_run_rebase () {
"
}
test_run_rebase success ''
-test_run_rebase failure -m
+test_run_rebase success -m
test_run_rebase success -i
test_run_rebase failure -p