commit ca6da77d8aee06c8367716562165d1a2f824faf8 from: Stefan Sperling date: Sun Mar 22 19:25:28 2020 UTC add a test for 'got rebase' to check behaviour on delete vs. delete commit - e70bf110de343a3c1fc422b6682f56853686772f commit + ca6da77d8aee06c8367716562165d1a2f824faf8 blob - 7423d96b389d81dc4599fdcc9579c42cf945db16 blob + 20827411beb4126c559b5d4b9088fc1734a02e53 --- regress/cmdline/rebase.sh +++ regress/cmdline/rebase.sh @@ -1055,7 +1055,107 @@ function test_rebase_trims_empty_dir { fi test_done "$testroot" "$ret" } + +function test_rebase_delete_missing_file { + local testroot=`test_init rebase_delete_missing_file` + + mkdir -p $testroot/repo/d/f/g + echo "new file" > $testroot/repo/d/f/g/new + (cd $testroot/repo && git add d/f/g/new) + git_commit $testroot/repo -m "adding a subdir" + local commit0=`git_show_head $testroot/repo` + + (cd $testroot/repo && git checkout -q -b newbranch) + echo "modified delta on branch" > $testroot/repo/gamma/delta + git_commit $testroot/repo -m "committing to delta on newbranch" + + (cd $testroot/repo && git rm -q beta d/f/g/new) + git_commit $testroot/repo -m "deleting beta and d/f/g/new on newbranch" + + local orig_commit1=`git_show_parent_commit $testroot/repo` + local orig_commit2=`git_show_head $testroot/repo` + + (cd $testroot/repo && git checkout -q master) + (cd $testroot/repo && git rm -q beta d/f/g/new) + git_commit $testroot/repo -m "removing beta and d/f/g/new on master" + local master_commit=`git_show_head $testroot/repo` + + got checkout $testroot/repo $testroot/wt > /dev/null + ret="$?" + if [ "$ret" != "0" ]; then + test_done "$testroot" "$ret" + return 1 + fi + (cd $testroot/wt && got rebase newbranch > $testroot/stdout) + + (cd $testroot/repo && git checkout -q newbranch) + local new_commit1=`git_show_head $testroot/repo` + + local short_orig_commit1=`trim_obj_id 28 $orig_commit1` + local short_orig_commit2=`trim_obj_id 28 $orig_commit2` + local short_new_commit1=`trim_obj_id 28 $new_commit1` + + echo "G gamma/delta" >> $testroot/stdout.expected + echo -n "$short_orig_commit1 -> $short_new_commit1" \ + >> $testroot/stdout.expected + echo ": committing to delta on newbranch" >> $testroot/stdout.expected + echo "! beta" >> $testroot/stdout.expected + echo "! d/f/g/new" >> $testroot/stdout.expected + echo -n "$short_orig_commit2 -> no-op change" \ + >> $testroot/stdout.expected + echo ": deleting beta and d/f/g/new on newbranch" \ + >> $testroot/stdout.expected + echo "Switching work tree to refs/heads/newbranch" \ + >> $testroot/stdout.expected + + cmp -s $testroot/stdout.expected $testroot/stdout + ret="$?" + if [ "$ret" != "0" ]; then + diff -u $testroot/stdout.expected $testroot/stdout + test_done "$testroot" "$ret" + return 1 + fi + + echo "modified delta on branch" > $testroot/content.expected + cat $testroot/wt/gamma/delta > $testroot/content + cmp -s $testroot/content.expected $testroot/content + ret="$?" + if [ "$ret" != "0" ]; then + diff -u $testroot/content.expected $testroot/content + test_done "$testroot" "$ret" + return 1 + fi + + if [ -e $testroot/wt/beta ]; then + echo "removed file beta still exists on disk" >&2 + test_done "$testroot" "1" + return 1 + fi + + (cd $testroot/wt && got status > $testroot/stdout) + + echo -n > $testroot/stdout.expected + cmp -s $testroot/stdout.expected $testroot/stdout + ret="$?" + if [ "$ret" != "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 $new_commit1 (newbranch)" > $testroot/stdout.expected + echo "commit $master_commit (master)" >> $testroot/stdout.expected + echo "commit $commit0" >> $testroot/stdout.expected + cmp -s $testroot/stdout.expected $testroot/stdout + ret="$?" + if [ "$ret" != "0" ]; then + diff -u $testroot/stdout.expected $testroot/stdout + fi + test_done "$testroot" "$ret" +} + run_test test_rebase_basic run_test test_rebase_ancestry_check run_test test_rebase_continue @@ -1068,3 +1168,4 @@ run_test test_rebase_no_commits_to_rebase run_test test_rebase_forward run_test test_rebase_out_of_date run_test test_rebase_trims_empty_dir +run_test test_rebase_delete_missing_file