commit 9334723a60466be8c0bff5875128e9f02c32e5b1 from: Christian Weisgerber date: Mon Feb 27 20:17:36 2023 UTC add xfail test for "got diff" when a commit changed a file to a directory git diff: diff --git a/alpha b/alpha deleted file mode 100644 index 4a58007..0000000 --- a/alpha +++ /dev/null @@ -1 +0,0 @@ -alpha diff --git a/alpha/beta b/alpha/beta new file mode 100644 index 0000000..65b2df8 --- /dev/null +++ b/alpha/beta @@ -0,0 +1 @@ +beta got diff: diff d973bf45ce9b2b437b5d6352368e8406f9e256e2 34413d01304800f99058a1a42769e92afc534199 commit - d973bf45ce9b2b437b5d6352368e8406f9e256e2 commit + 34413d01304800f99058a1a42769e92afc534199 commit - 5c5396e5c1ee0b8ede1cce4c7262a946ab1b3970 commit + 9334723a60466be8c0bff5875128e9f02c32e5b1 blob - 68fc40572b1afa42c02409a2836ca23e2d7df464 blob + 84681e2a5ec0f41b9ea674365f6fb81fb230a356 --- regress/cmdline/diff.sh +++ regress/cmdline/diff.sh @@ -1783,6 +1783,37 @@ EOF ret=$? if [ $ret -ne 0 ]; then diff -u $testroot/stdout.expected $testroot/stdout + fi + test_done "$testroot" "$ret" +} + +test_diff_file_to_dir() { + local testroot=`test_init diff_file_to_dir` + local commit_id0=`git_show_head $testroot/repo` + + got checkout $testroot/repo $testroot/wt > /dev/null + ret=$? + if [ $ret -ne 0 ]; then + test_done "$testroot" "$ret" + return 1 + fi + + git_rm $testroot/repo alpha + mkdir $testroot/repo/alpha + echo eta > $testroot/repo/alpha/eta + (cd $testroot/repo && git add alpha/eta) + git_commit $testroot/repo -m "changed alpha into directory" + local commit_id1=`git_show_head $testroot/repo` + + echo "diff $commit_id0 $commit_id1" > $testroot/stdout.expected + echo "commit - $commit_id0" >> $testroot/stdout.expected + echo "commit + $commit_id1" >> $testroot/stdout.expected + got diff -r $testroot/repo $commit_id0 $commit_id1 > $testroot/stdout + # Diff should not be empty + cmp -s $testroot/stdout.expected $testroot/stdout + ret=$? + if [ $ret -eq 0 ]; then + ret="xfail file to directory" fi test_done "$testroot" "$ret" } @@ -1803,3 +1834,4 @@ run_test test_diff_crlf run_test test_diff_worktree_newfile_xbit run_test test_diff_commit_diffstat run_test test_diff_worktree_diffstat +run_test test_diff_file_to_dir