commit e4e80ba431438f463a867e2d2d80b264faa19b07 from: Christian Weisgerber via: Thomas Adam date: Wed Mar 01 14:29:45 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 - 601f05cdbeb8a43249702cafae41b9dee4811bd6 commit + e4e80ba431438f463a867e2d2d80b264faa19b07 blob - f3a3dc7d1991a6544fc58a1b0d83a5ac5b04b8dd blob + cdfcbf919035db7b57b79f083ae2ad1157d8b9d9 --- 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