commit 13cd1d190795ee2b0bd10c7e4590dac2900cc248 from: Stefan Sperling date: Sun Mar 03 10:18:59 2024 UTC add a test which checks what happens when a merge commit is rebased commit - e05fd55cbfee4e4023db6595ae04fa79275c8637 commit + 13cd1d190795ee2b0bd10c7e4590dac2900cc248 blob - bec03a3f9a01f0d363aee654100fd1f0280b1d9d blob + abdf21ec1321e65913253407eca32329e0d42b6d --- regress/cmdline/rebase.sh +++ regress/cmdline/rebase.sh @@ -2006,7 +2006,105 @@ test_rebase_one_commit() { test_done "$testroot" 0 } + +test_rebase_merge_commit() { + local testroot=`test_init rebase_merge_commit` + 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 + + 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 -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` + + (cd $testroot/wt && got branch -c $commit0 newbranch2) >/dev/null + echo "modified beta on newbranch2" >$testroot/wt/beta + (cd $testroot/wt && got commit -m 'edit beta') >/dev/null + (cd $testroot/wt && got update) >/dev/null + local commit4=`git_show_branch_head $testroot/repo newbranch2` + + echo "modified beta on newbranch2 again" >$testroot/wt/beta + (cd $testroot/wt && got commit -m 'edit beta again') >/dev/null + (cd $testroot/wt && got update) >/dev/null + local commit5=`git_show_branch_head $testroot/repo newbranch2` + + echo -n '' > $testroot/stderr.expected + + (cd $testroot/wt && got merge newbranch1 >$testroot/stdout \ + 2> $testroot/stderr) + ret=$? + if [ $ret -ne 0 ]; then + echo "merge comand failed unexpectedly" >&2 + diff -u $testroot/stderr.expected $testroot/stderr + test_done "$testroot" "1" + return 1 + fi + + local merge_commit=`git_show_branch_head $testroot/repo newbranch2` + + echo "G alpha" >> $testroot/stdout.expected + echo -n "Merged refs/heads/newbranch1 into refs/heads/newbranch2: " \ + >> $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 + + (cd $testroot/wt && got update -b master) >/dev/null + (cd $testroot/wt && got rebase newbranch2) > $testroot/stdout + + local new_commit5=`git_show_parent_commit $testroot/repo newbranch2` + local short_orig_commit5=`trim_obj_id 28 $commit5` + local short_new_commit5=`trim_obj_id 28 $new_commit5` + + local new_commit4=`git_show_parent_commit $testroot/repo $new_commit5` + local short_orig_commit4=`trim_obj_id 28 $commit4` + local short_new_commit4=`trim_obj_id 28 $new_commit4` + + local new_merge_commit=`git_show_branch_head $testroot/repo newbranch2` + local short_orig_merge_commit=`trim_obj_id 28 $merge_commit` + local short_new_merge_commit=`trim_obj_id 28 $new_merge_commit` + + echo "G beta"> $testroot/stdout.expected + echo "$short_orig_commit4 -> $short_new_commit4: edit beta" \ + >> $testroot/stdout.expected + echo "G beta" >> $testroot/stdout.expected + echo "$short_orig_commit5 -> $short_new_commit5: edit beta again" \ + >> $testroot/stdout.expected + echo "G alpha" >> $testroot/stdout.expected + echo -n "$short_orig_merge_commit -> $short_new_merge_commit: " \ + >> $testroot/stdout.expected + echo "merge refs/heads/newbranch1 into refs/head" \ + >> $testroot/stdout.expected + echo "Switching work tree to refs/heads/newbranch2" \ + >> $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 + + test_done "$testroot" 0 +} + test_parseargs "$@" run_test test_rebase_basic run_test test_rebase_ancestry_check @@ -2029,3 +2127,4 @@ run_test test_rebase_nonbranch run_test test_rebase_umask run_test test_rebase_out_of_date2 run_test test_rebase_one_commit +run_test test_rebase_merge_commit