Download raw body.
got diff chomps trailing \r
Stefan Sperling:
> As a first step it would be nice to have is a regression test.
There already is test_diff_crlf(), but it confirms that the trailing
carriage return is omitted.
Here's a tweak to make it actually test the desired behavior.
Yes, the sed 'l' command is in POSIX.
diff /home/naddy/got
commit - 79cd0a74be4fd59c3cbfc4f35772ba4336b950be
path + /home/naddy/got
blob - 74c5c3277048c41e7d957d274e2fd708fbd7e022
file + regress/cmdline/diff.sh
--- regress/cmdline/diff.sh
+++ regress/cmdline/diff.sh
@@ -1308,7 +1308,7 @@ test_diff_crlf() {
return 1
fi
- printf 'test\r\n' > $testroot/wt/crlf
+ printf 'one\r\ntwo\r\nthree\r\n' > $testroot/wt/crlf
(cd $testroot/wt && got add crlf && got commit -m +crlf) >/dev/null
ret=$?
if [ $ret -ne 0 ]; then
@@ -1316,14 +1316,16 @@ test_diff_crlf() {
return 1
fi
- printf 'test 2\r\n' > $testroot/wt/crlf
- (cd $testroot/wt && got diff | sed -n '/^---/,$p' > $testroot/stdout)
- cat <<EOF > $testroot/stdout.expected
---- crlf
-+++ crlf
-@@ -1 +1 @@
--test
-+test 2
+ printf 'one\r\ntwain\r\nthree\r\n' > $testroot/wt/crlf
+ (cd $testroot/wt && got diff | sed -n '/^---/,$l' > $testroot/stdout)
+ cat <<\EOF > $testroot/stdout.expected
+--- crlf$
++++ crlf$
+@@ -1,3 +1,3 @@$
+ one\r$
+-two\r$
++twain\r$
+ three\r$
EOF
cmp -s $testroot/stdout.expected $testroot/stdout
--
Christian "naddy" Weisgerber naddy@mips.inka.de
got diff chomps trailing \r