commit 831297da020634f03598418e375149da41098308 from: Omar Polo via: Thomas Adam date: Tue Jul 26 13:45:44 2022 UTC add a simple test for 'got diff' against CRLF files commit - adee8ef20615e62d3f032c73878219d81c5ce072 commit + 831297da020634f03598418e375149da41098308 blob - 94f402340943fa24af2622ae5b16240e2e9dc93d blob + e95a96d48ee8f125b8283577041ff01d0310081e --- 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