commit 0a706d22c0eedf209fc5cc5821872ac9b47ecfd4 from: Stefan Sperling date: Wed Sep 21 10:57:30 2022 UTC add regression test which covers fast-forward rebase + path-prefix commit - 6f04a73d17761092a3a7ab07632cd1a89d4bfd21 commit + 0a706d22c0eedf209fc5cc5821872ac9b47ecfd4 blob - 59b9d0cacb742bc1bd8bb4c444a37d5f22de820a blob + b4c4e91be5c394d1da835c1b1a9d9bc16a8124e3 --- regress/cmdline/rebase.sh +++ regress/cmdline/rebase.sh @@ -983,6 +983,113 @@ test_rebase_forward() { (cd $testroot/wt && got up -b origin/master > /dev/null) (cd $testroot/wt && got rebase master \ + > $testroot/stdout 2> $testroot/stderr) + + echo "Forwarding refs/heads/master to commit $commit2" \ + > $testroot/stdout.expected + echo "Switching work tree to refs/heads/master" \ + >> $testroot/stdout.expected + cmp -s $testroot/stdout.expected $testroot/stdout + ret=$? + if [ $ret -ne 0 ]; then + diff -u $testroot/stdout.expected $testroot/stdout + test_done "$testroot" "$ret" + return 1 + fi + + # Ensure that rebase operation was completed correctly + (cd $testroot/wt && got rebase -a \ + > $testroot/stdout 2> $testroot/stderr) + echo -n "" > $testroot/stdout.expected + cmp -s $testroot/stdout.expected $testroot/stdout + ret=$? + if [ $ret -ne 0 ]; then + diff -u $testroot/stdout.expected $testroot/stdout + test_done "$testroot" "$ret" + return 1 + fi + echo "got: rebase operation not in progress" > $testroot/stderr.expected + cmp -s $testroot/stderr.expected $testroot/stderr + ret=$? + if [ $ret -ne 0 ]; then + diff -u $testroot/stderr.expected $testroot/stderr + test_done "$testroot" "$ret" + return 1 + fi + + (cd $testroot/wt && got branch -n > $testroot/stdout) + echo "master" > $testroot/stdout.expected + cmp -s $testroot/stdout.expected $testroot/stdout + ret=$? + if [ $ret -ne 0 ]; then + diff -u $testroot/stdout.expected $testroot/stdout + test_done "$testroot" "$ret" + return 1 + fi + + (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout) + echo "commit $commit2 (master, origin/master)" > $testroot/stdout.expected + echo "commit $commit1" >> $testroot/stdout.expected + echo "commit $commit0" >> $testroot/stdout.expected + cmp -s $testroot/stdout.expected $testroot/stdout + ret=$? + if [ $ret -ne 0 ]; then + diff -u $testroot/stdout.expected $testroot/stdout + test_done "$testroot" "$ret" + return 1 + fi + + # Forward-only rebase operations should not be backed up + (cd $testroot/repo && got rebase -l > $testroot/stdout) + echo -n > $testroot/stdout.expected + cmp -s $testroot/stdout.expected $testroot/stdout + ret=$? + if [ $ret -ne 0 ]; then + diff -u $testroot/stdout.expected $testroot/stdout + fi + test_done "$testroot" "$ret" +} + +test_rebase_forward_path_prefix() { + local testroot=`test_init rebase_forward_path_prefix` + local commit0=`git_show_head $testroot/repo` + + got checkout $testroot/repo $testroot/wt-full > /dev/null + ret=$? + if [ $ret -ne 0 ]; then + test_done "$testroot" "$ret" + return 1 + fi + + echo "change alpha 1" > $testroot/wt-full/alpha + (cd $testroot/wt-full && got commit -m 'test rebase_forward' \ + > /dev/null) + local commit1=`git_show_head $testroot/repo` + + echo "change alpha 2" > $testroot/wt-full/alpha + (cd $testroot/wt-full && got commit -m 'test rebase_forward' \ + > /dev/null) + local commit2=`git_show_head $testroot/repo` + + # Simulate a situation where fast-forward is required. + # We want to fast-forward master to origin/master: + # commit 3907e11dceaae2ca7f8db79c2af31794673945ad (origin/master) + # commit ffcffcd102cf1af6572fbdbb4cf07a0f1fd2d840 (master) + # commit 87a6a8a2263a15b61c016ff1720b24741d455eb5 + (cd $testroot/repo && got ref -d master >/dev/null) + (cd $testroot/repo && got ref -c $commit1 refs/heads/master) + (cd $testroot/repo && got ref -c $commit2 refs/remotes/origin/master) + + # Work tree which uses a path-prefix and will be used for rebasing + got checkout -p epsilon -b origin/master $testroot/repo $testroot/wt \ + > /dev/null + ret=$? + if [ $ret -ne 0 ]; then + test_done "$testroot" "$ret" + return 1 + fi + + (cd $testroot/wt && /usr/local/bin/got rebase master \ > $testroot/stdout 2> $testroot/stderr) echo "Forwarding refs/heads/master to commit $commit2" \ @@ -1694,6 +1801,7 @@ run_test test_rebase_path_prefix run_test test_rebase_preserves_logmsg run_test test_rebase_no_commits_to_rebase run_test test_rebase_forward +run_test test_rebase_forward_path_prefix run_test test_rebase_out_of_date run_test test_rebase_trims_empty_dir run_test test_rebase_delete_missing_file