commit 0543436dc194839e6e3ffa7cecc87f4774eb0350 from: Omar Polo date: Tue Jul 26 13:45:14 2022 UTC add a simple test for 'got diff' against CRLF files commit - 8d504b53f2bee4e17d49158a312294699094ed1e commit + 0543436dc194839e6e3ffa7cecc87f4774eb0350 blob - a5ad3625b8799d5d92ac2652db6bc28541dfad27 blob + 136f659b08eaf6408f6c79e05f6440fe7c754523 --- regress/cmdline/diff.sh +++ regress/cmdline/diff.sh @@ -1257,7 +1257,43 @@ test_diff_ignored_file() { fi test_done "$testroot" "$ret" } + +test_diff_crlf() { + local testroot=`test_init diff_crlf` + + got checkout $testroot/repo $testroot/wt > /dev/null + ret=$? + if [ $ret -ne 0 ]; then + test_done "$testroot" $ret + return 1 + fi + printf 'test\r\n' > $testroot/wt/crlf + (cd $testroot/wt && got add crlf && got commit -m +crlf) >/dev/null + ret=$? + if [ $ret -ne 0 ]; then + test_done "$testroot" $ret + return 1 + fi + + printf 'test 2\r\n' > $testroot/wt/crlf + (cd $testroot/wt && got diff | sed -n '/^---/,$p' > $testroot/stdout) + cat < $testroot/stdout.expected +--- crlf ++++ crlf +@@ -1 +1 @@ +-test ++test 2 +EOF + + 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_parseargs "$@" run_test test_diff_basic run_test test_diff_shows_conflict @@ -1270,3 +1306,4 @@ run_test test_diff_symlinks_in_repo run_test test_diff_binary_files run_test test_diff_commits run_test test_diff_ignored_file +run_test test_diff_crlf