]> git.ipfire.org Git - thirdparty/git.git/blame - t/t0026-eol-config.sh
l10n: fr v2.23.0 round 2
[thirdparty/git.git] / t / t0026-eol-config.sh
CommitLineData
942e7747
EB
1#!/bin/sh
2
3test_description='CRLF conversion'
4
5. ./test-lib.sh
6
7has_cr() {
8 tr '\015' Q <"$1" | grep Q >/dev/null
9}
10
11test_expect_success setup '
12
13 git config core.autocrlf false &&
14
a48fcd83 15 echo "one text" > .gitattributes &&
942e7747
EB
16
17 for w in Hello world how are you; do echo $w; done >one &&
18 for w in I am very very fine thank you; do echo $w; done >two &&
19 git add . &&
20
21 git commit -m initial &&
22
8deeab4a
EP
23 one=$(git rev-parse HEAD:one) &&
24 two=$(git rev-parse HEAD:two) &&
942e7747
EB
25
26 echo happy.
27'
28
29test_expect_success 'eol=lf puts LFs in normalized file' '
30
31 rm -f .gitattributes tmp one two &&
32 git config core.eol lf &&
33 git read-tree --reset -u HEAD &&
34
35 ! has_cr one &&
36 ! has_cr two &&
8deeab4a
EP
37 onediff=$(git diff one) &&
38 twodiff=$(git diff two) &&
66e1fe7d 39 test -z "$onediff" && test -z "$twodiff"
942e7747
EB
40'
41
42test_expect_success 'eol=crlf puts CRLFs in normalized file' '
43
44 rm -f .gitattributes tmp one two &&
45 git config core.eol crlf &&
46 git read-tree --reset -u HEAD &&
47
48 has_cr one &&
49 ! has_cr two &&
8deeab4a
EP
50 onediff=$(git diff one) &&
51 twodiff=$(git diff two) &&
66e1fe7d 52 test -z "$onediff" && test -z "$twodiff"
942e7747
EB
53'
54
55test_expect_success 'autocrlf=true overrides eol=lf' '
56
57 rm -f .gitattributes tmp one two &&
58 git config core.eol lf &&
59 git config core.autocrlf true &&
60 git read-tree --reset -u HEAD &&
61
62 has_cr one &&
63 has_cr two &&
8deeab4a
EP
64 onediff=$(git diff one) &&
65 twodiff=$(git diff two) &&
66e1fe7d 66 test -z "$onediff" && test -z "$twodiff"
942e7747
EB
67'
68
69test_expect_success 'autocrlf=true overrides unset eol' '
70
71 rm -f .gitattributes tmp one two &&
72 git config --unset-all core.eol &&
73 git config core.autocrlf true &&
74 git read-tree --reset -u HEAD &&
75
76 has_cr one &&
77 has_cr two &&
8deeab4a
EP
78 onediff=$(git diff one) &&
79 twodiff=$(git diff two) &&
66e1fe7d 80 test -z "$onediff" && test -z "$twodiff"
942e7747
EB
81'
82
5491e9e2
PT
83test_expect_success NATIVE_CRLF 'eol native is crlf' '
84
85 rm -rf native_eol && mkdir native_eol &&
86 (
87 cd native_eol &&
88 printf "*.txt text\n" >.gitattributes &&
89 printf "one\r\ntwo\r\nthree\r\n" >filedos.txt &&
90 printf "one\ntwo\nthree\n" >fileunix.txt &&
91 git init &&
92 git config core.autocrlf false &&
93 git config core.eol native &&
94 git add filedos.txt fileunix.txt &&
95 git commit -m "first" &&
96 rm file*.txt &&
97 git reset --hard HEAD &&
98 has_cr filedos.txt &&
99 has_cr fileunix.txt
100 )
101'
102
942e7747 103test_done