diff options
author | Vincent Ambo <Vincent Ambo> | 2020-01-11T23·36+0000 |
---|---|---|
committer | Vincent Ambo <Vincent Ambo> | 2020-01-11T23·40+0000 |
commit | 7ef0d62730840ded097b524104cc0a0904591a63 (patch) | |
tree | a670f96103667aeca4789a95d94ca0dff550c4ce /third_party/git/t/t0026-eol-config.sh | |
parent | 6a2a3007077818e24a3d56fc492ada9206a10cf0 (diff) | |
parent | 1b593e1ea4d2af0f6444d9a7788d5d99abd6fde5 (diff) |
merge(third_party/git): Merge squashed git subtree at v2.23.0 r/373
Merge commit '1b593e1ea4d2af0f6444d9a7788d5d99abd6fde5' as 'third_party/git'
Diffstat (limited to 'third_party/git/t/t0026-eol-config.sh')
-rwxr-xr-x | third_party/git/t/t0026-eol-config.sh | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/third_party/git/t/t0026-eol-config.sh b/third_party/git/t/t0026-eol-config.sh new file mode 100755 index 000000000000..c5203e232c8b --- /dev/null +++ b/third_party/git/t/t0026-eol-config.sh @@ -0,0 +1,103 @@ +#!/bin/sh + +test_description='CRLF conversion' + +. ./test-lib.sh + +has_cr() { + tr '\015' Q <"$1" | grep Q >/dev/null +} + +test_expect_success setup ' + + git config core.autocrlf false && + + echo "one text" > .gitattributes && + + for w in Hello world how are you; do echo $w; done >one && + for w in I am very very fine thank you; do echo $w; done >two && + git add . && + + git commit -m initial && + + one=$(git rev-parse HEAD:one) && + two=$(git rev-parse HEAD:two) && + + echo happy. +' + +test_expect_success 'eol=lf puts LFs in normalized file' ' + + rm -f .gitattributes tmp one two && + git config core.eol lf && + git read-tree --reset -u HEAD && + + ! has_cr one && + ! has_cr two && + onediff=$(git diff one) && + twodiff=$(git diff two) && + test -z "$onediff" && test -z "$twodiff" +' + +test_expect_success 'eol=crlf puts CRLFs in normalized file' ' + + rm -f .gitattributes tmp one two && + git config core.eol crlf && + git read-tree --reset -u HEAD && + + has_cr one && + ! has_cr two && + onediff=$(git diff one) && + twodiff=$(git diff two) && + test -z "$onediff" && test -z "$twodiff" +' + +test_expect_success 'autocrlf=true overrides eol=lf' ' + + rm -f .gitattributes tmp one two && + git config core.eol lf && + git config core.autocrlf true && + git read-tree --reset -u HEAD && + + has_cr one && + has_cr two && + onediff=$(git diff one) && + twodiff=$(git diff two) && + test -z "$onediff" && test -z "$twodiff" +' + +test_expect_success 'autocrlf=true overrides unset eol' ' + + rm -f .gitattributes tmp one two && + git config --unset-all core.eol && + git config core.autocrlf true && + git read-tree --reset -u HEAD && + + has_cr one && + has_cr two && + onediff=$(git diff one) && + twodiff=$(git diff two) && + test -z "$onediff" && test -z "$twodiff" +' + +test_expect_success NATIVE_CRLF 'eol native is crlf' ' + + rm -rf native_eol && mkdir native_eol && + ( + cd native_eol && + printf "*.txt text\n" >.gitattributes && + printf "one\r\ntwo\r\nthree\r\n" >filedos.txt && + printf "one\ntwo\nthree\n" >fileunix.txt && + git init && + git config core.autocrlf false && + git config core.eol native && + git add filedos.txt fileunix.txt && + git commit -m "first" && + rm file*.txt && + git reset --hard HEAD && + has_cr filedos.txt && + has_cr fileunix.txt + ) +' + +test_done |