commit be9db6c2d00fb3a74f65c0ce4dc01359aa1986fc from: Stefan Sperling via: Thomas Adam date: Thu Mar 07 16:35:54 2024 UTC add an xfail test for a case where rebase fails to forward a branch Because 'got rebase' only does a first-parent traversal it will try to rebase commits which appear in the history of a branch, even when the branch to be rebased is already based on that history. This results in spurious merge conflicts as existing changes get re-applied. The desired behaviour would be that 'got rebase' forwards the branch, as it does when the 'got merge -M' command used by this test case is replaced by a simple 'got merge' which avoids creating a merge commit. Problem reported by naddy in the "Landry's firefox repository" thread: https://marc.gameoftrees.org/mail/1706721001.20565_0.html commit - fcd37601b2164589187ee62342b0ead13d3288af commit + be9db6c2d00fb3a74f65c0ce4dc01359aa1986fc blob - 2054bedb08f8feba973a66370ee61cbc6fb10ed8 blob + 46f11f7c161db17549ba3c6ba4055ffcc81b97ce --- regress/cmdline/rebase.sh +++ regress/cmdline/rebase.sh @@ -2185,7 +2185,73 @@ test_rebase_across_merge_commit() { test_done "$testroot" 0 } + +test_rebase_merged_history_traversal() { + local testroot=`test_init rebase_merged_history_traversal` + local commit0=`git_show_branch_head $testroot/repo master` + + if ! got checkout $testroot/repo $testroot/wt >/dev/null; then + test_done "$testroot" 1 + return 1 + fi + (cd $testroot/wt && got branch -c $commit0 newbranch1) >/dev/null + echo "modified alpha on newbranch1" >$testroot/wt/alpha + (cd $testroot/wt && got commit -m 'edit alpha') >/dev/null + (cd $testroot/wt && got update) >/dev/null + local commit2=`git_show_branch_head $testroot/repo master` + + echo "modified alpha on newbranch1 again" >$testroot/wt/alpha + (cd $testroot/wt && got commit -m 'edit alpha again') >/dev/null + (cd $testroot/wt && got update) >/dev/null + local commit3=`git_show_branch_head $testroot/repo newbranch1` + + echo -n '' > $testroot/stderr.expected + + (cd $testroot/wt && got update -b master) >/dev/null + (cd $testroot/wt && got merge -M newbranch1 >$testroot/stdout \ + 2> $testroot/stderr) + ret=$? + if [ $ret -ne 0 ]; then + echo "merge command failed unexpectedly" >&2 + diff -u $testroot/stderr.expected $testroot/stderr + test_done "$testroot" "1" + return 1 + fi + + local merge_commit=`git_show_head $testroot/repo` + + echo "G alpha" > $testroot/stdout.expected + echo -n "Merged refs/heads/newbranch1 into refs/heads/master: " \ + >> $testroot/stdout.expected + echo $merge_commit >> $testroot/stdout.expected + if ! cmp -s $testroot/stdout.expected $testroot/stdout; then + diff -u $testroot/stdout.expected $testroot/stdout + test_done "$testroot" 1 + return 1 + fi + + echo "modified delta on master" >$testroot/wt/gamma/delta + (cd $testroot/wt && got commit -m 'edit delta') >/dev/null + local commit1=`git_show_branch_head $testroot/repo master` + + (cd $testroot/wt && got branch newbranch2) >/dev/null + (cd $testroot/wt && got rebase newbranch1) > $testroot/stdout \ + 2> $testroot/stderr + + echo "Forwarding refs/heads/newbranch1 to commit $commit1" > \ + $testroot/stdout.expected + echo "Switching work tree to refs/heads/newbranch1" \ + >> $testroot/stdout.expected + + if ! cmp -s $testroot/stdout.expected $testroot/stdout; then + #diff -u $testroot/stdout.expected $testroot/stdout + ret="xfail ($(head -n1 $testroot/stdout))" + fi + + test_done "$testroot" "$ret" +} + test_parseargs "$@" run_test test_rebase_basic run_test test_rebase_ancestry_check @@ -2210,3 +2276,4 @@ run_test test_rebase_out_of_date2 run_test test_rebase_one_commit run_test test_rebase_merge_commit run_test test_rebase_across_merge_commit +run_test test_rebase_merged_history_traversal