From: Eyvind Bernhardsen <eyvind.bernhardsen@gmail.com>
To: git@vger.kernel.org
Cc: hasan.aljudy@gmail.com, kusmabite@googlemail.com,
torvalds@linux-foundation.org, prohaska@zib.de,
gitster@pobox.com
Subject: [PATCH/RFC 2/3] Add tests for per-repository eol normalization
Date: Fri, 7 May 2010 00:27:34 +0200 [thread overview]
Message-ID: <38d9735b135503ca444e82d3aaa9107ea18439e6.1273183206.git.eyvind.bernhardsen@gmail.com> (raw)
In-Reply-To: <cover.1273183206.git.eyvind.bernhardsen@gmail.com>
Signed-off-by: Eyvind Bernhardsen <eyvind.bernhardsen@gmail.com>
---
t/t0025-auto-eol.sh | 180 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 180 insertions(+), 0 deletions(-)
create mode 100755 t/t0025-auto-eol.sh
diff --git a/t/t0025-auto-eol.sh b/t/t0025-auto-eol.sh
new file mode 100755
index 0000000..5acee2d
--- /dev/null
+++ b/t/t0025-auto-eol.sh
@@ -0,0 +1,180 @@
+#!/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 &&
+
+ 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}Q; done | q_to_cr >two &&
+ git add . &&
+
+ git commit -m initial &&
+
+ one=`git rev-parse HEAD:one` &&
+ two=`git rev-parse HEAD:two` &&
+
+ for w in Some extra lines here; do echo $w; done >>one &&
+ git diff >patch.file &&
+ patched=`git hash-object --stdin <one` &&
+ git read-tree --reset -u HEAD &&
+
+ echo happy.
+'
+
+test_expect_success 'default settings cause no changes' '
+
+ rm -f .gitattributes tmp one two &&
+ git read-tree --reset -u HEAD &&
+
+ if has_cr one || ! has_cr two
+ then
+ echo "Eh? $f"
+ false
+ fi &&
+ onediff=`git diff one` &&
+ twodiff=`git diff two` &&
+ test -z "$onediff" -a -z "$twodiff"
+'
+
+test_expect_success 'no auto-eol, explicit eolstyle=native causes no changes' '
+
+ rm -f .gitattributes tmp one two &&
+ git config core.eolstyle native &&
+ git read-tree --reset -u HEAD &&
+
+ if has_cr one || ! has_cr two
+ then
+ echo "Eh? $f"
+ false
+ fi &&
+ onediff=`git diff one` &&
+ twodiff=`git diff two` &&
+ test -z "$onediff" -a -z "$twodiff"
+'
+
+test_expect_failure 'auto-eol=true, eolStyle=crlf <=> autocrlf=true' '
+
+ rm -f .gitattributes tmp one two &&
+ git config core.autocrlf false &&
+ git config core.eolstyle crlf &&
+ echo "* auto-eol" > .gitattributes &&
+ git read-tree --reset -u HEAD &&
+ unset missing_cr &&
+
+ for f in one two
+ do
+ if ! has_cr "$f"
+ then
+ echo "Eh? $f"
+ missing_cr=1
+ break
+ fi
+ done &&
+ test -z "$missing_cr"
+'
+
+test_expect_failure 'auto-eol=true, eolStyle=lf <=> autocrlf=input' '
+
+ rm -f .gitattributes tmp one two &&
+ git config core.autocrlf false &&
+ git config core.eolstyle lf &&
+ echo "* auto-eol" > .gitattributes &&
+ git read-tree --reset -u HEAD &&
+
+ if has_cr one || ! has_cr two
+ then
+ echo "Eh? $f"
+ false
+ fi &&
+ onediff=`git diff one` &&
+ twodiff=`git diff two` &&
+ test -z "$onediff" -a -n "$twodiff"
+'
+
+test_expect_success 'auto-eol=true, eolStyle=false <=> autocrlf=false' '
+
+ rm -f .gitattributes tmp one two &&
+ git config core.autocrlf false &&
+ git config core.eolstyle false &&
+ echo "* auto-eol" > .gitattributes &&
+ git read-tree --reset -u HEAD &&
+
+ if has_cr one || ! has_cr two
+ then
+ echo "Eh? $f"
+ false
+ fi
+ onediff=`git diff one` &&
+ twodiff=`git diff two` &&
+ test -z "$onediff" -a -z "$twodiff"
+'
+
+test_expect_success 'autocrlf=true overrides auto-eol=true, eolStyle=lf' '
+
+ rm -f .gitattributes tmp one two &&
+ git config core.autocrlf true &&
+ git config core.eolstyle lf &&
+ echo "* auto-eol" > .gitattributes &&
+ git read-tree --reset -u HEAD &&
+ unset missing_cr &&
+
+ for f in one two
+ do
+ if ! has_cr "$f"
+ then
+ echo "Eh? $f"
+ missing_cr=1
+ break
+ fi
+ done &&
+ test -z "$missing_cr"
+'
+
+test_expect_success 'autocrlf=input overrides auto-eol=true, eolStyle=crlf' '
+
+ rm -f .gitattributes tmp one two &&
+ git config core.autocrlf input &&
+ git config core.eolstyle crlf &&
+ echo "* auto-eol" > .gitattributes &&
+ git read-tree --reset -u HEAD &&
+
+ if has_cr one || ! has_cr two
+ then
+ echo "Eh? $f"
+ false
+ fi &&
+ onediff=`git diff one` &&
+ twodiff=`git diff two` &&
+ test -z "$onediff" -a -n "$twodiff"
+'
+
+test_expect_success 'autocrlf=true overrides auto-eol=true, eolStyle=false' '
+
+ rm -f .gitattributes tmp one two &&
+ git config core.autocrlf true &&
+ git config core.eolstyle false &&
+ echo "* auto-eol" > .gitattributes &&
+ git read-tree --reset -u HEAD &&
+ unset missing_cr &&
+
+ for f in one two
+ do
+ if ! has_cr "$f"
+ then
+ echo "Eh? $f"
+ missing_cr=1
+ break
+ fi
+ done &&
+ test -z "$missing_cr"
+'
+
+test_done
--
1.7.1.3.gb95c9
next prev parent reply other threads:[~2010-05-06 22:27 UTC|newest]
Thread overview: 82+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-05 10:01 What should be the CRLF policy when win + Linux? mat
2010-05-05 13:27 ` Ramkumar Ramachandra
2010-05-06 9:27 ` mat
2010-05-06 10:03 ` Erik Faye-Lund
2010-05-06 2:35 ` hasen j
2010-05-06 7:29 ` Wilbert van Dolleweerd
2010-05-06 15:34 ` hasen j
2010-05-06 17:15 ` Linus Torvalds
2010-05-06 17:26 ` Erik Faye-Lund
2010-05-06 20:00 ` hasen j
2010-05-06 20:23 ` Linus Torvalds
2010-05-06 20:40 ` Erik Faye-Lund
2010-05-06 22:14 ` hasen j
2010-05-06 23:25 ` Erik Faye-Lund
2010-05-18 15:13 ` Anthony W. Youngman
2010-05-06 22:27 ` [PATCH/RFC 0/3] Per-repository end-of-line normalization Eyvind Bernhardsen
2010-05-06 22:27 ` [PATCH/RFC 1/3] Add "auto-eol" attribute and "core.eolStyle" config variable Eyvind Bernhardsen
2010-05-06 22:27 ` Eyvind Bernhardsen [this message]
2010-05-06 22:27 ` [PATCH/RFC 3/3] Add per-repository eol normalization Eyvind Bernhardsen
2010-05-06 23:38 ` [PATCH/RFC 0/3] Per-repository end-of-line normalization Avery Pennarun
2010-05-06 23:54 ` Avery Pennarun
2010-05-07 8:45 ` Erik Faye-Lund
2010-05-07 16:33 ` Junio C Hamano
2010-05-07 16:57 ` Avery Pennarun
2010-05-07 17:10 ` Linus Torvalds
2010-05-07 19:02 ` Linus Torvalds
2010-05-07 19:11 ` Avery Pennarun
2010-05-07 19:16 ` Linus Torvalds
2010-05-07 19:35 ` Avery Pennarun
2010-05-07 19:45 ` Linus Torvalds
2010-05-07 19:58 ` Avery Pennarun
2010-05-07 20:06 ` Linus Torvalds
2010-05-07 20:17 ` Linus Torvalds
2010-05-07 20:42 ` Eyvind Bernhardsen
2010-05-07 20:57 ` Linus Torvalds
2010-05-07 21:17 ` Eyvind Bernhardsen
2010-05-07 21:23 ` Linus Torvalds
2010-05-07 21:30 ` Avery Pennarun
2010-05-07 21:37 ` Eyvind Bernhardsen
2010-05-07 21:58 ` Linus Torvalds
2010-05-07 21:54 ` Linus Torvalds
2010-05-07 22:14 ` Linus Torvalds
2010-05-07 22:34 ` Avery Pennarun
2010-05-07 22:54 ` hasen j
2010-05-07 23:18 ` Linus Torvalds
2010-05-07 23:47 ` hasen j
2010-05-07 23:50 ` Linus Torvalds
2010-05-08 0:19 ` hasen j
2010-05-08 0:33 ` Linus Torvalds
2010-05-08 1:39 ` hasen j
2010-05-08 1:49 ` Linus Torvalds
2010-05-08 2:49 ` hasen j
2010-05-08 3:31 ` Robert Buck
2010-05-08 3:45 ` Avery Pennarun
2010-05-08 10:36 ` hasen j
2010-05-08 11:36 ` Robert Buck
2010-05-08 3:34 ` Avery Pennarun
2010-05-08 0:31 ` Avery Pennarun
2010-05-07 22:19 ` Avery Pennarun
2010-05-08 20:49 ` Dmitry Potapov
2010-05-08 21:54 ` Linus Torvalds
2010-05-08 23:42 ` Dmitry Potapov
2010-05-09 7:49 ` Eyvind Bernhardsen
2010-05-09 10:35 ` Robert Buck
2010-05-07 20:58 ` Avery Pennarun
2010-05-07 19:23 ` Eyvind Bernhardsen
2010-05-07 19:31 ` Nicolas Pitre
2010-05-07 19:36 ` Avery Pennarun
2010-05-07 20:29 ` Nicolas Pitre
2010-05-07 21:00 ` Avery Pennarun
2010-05-07 21:12 ` Nicolas Pitre
2010-05-07 21:26 ` Avery Pennarun
2010-05-07 22:09 ` A Large Angry SCM
2010-05-07 22:10 ` Avery Pennarun
2010-05-07 19:40 ` Linus Torvalds
2010-05-07 20:32 ` Nicolas Pitre
2010-05-07 19:06 ` Junio C Hamano
2010-05-07 19:25 ` Eyvind Bernhardsen
2010-05-07 19:41 ` Finn Arne Gangstad
2010-05-07 20:06 ` Avery Pennarun
2010-05-07 20:11 ` Eyvind Bernhardsen
2010-05-07 7:15 ` What should be the CRLF policy when win + Linux? Gelonida
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=38d9735b135503ca444e82d3aaa9107ea18439e6.1273183206.git.eyvind.bernhardsen@gmail.com \
--to=eyvind.bernhardsen@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=hasan.aljudy@gmail.com \
--cc=kusmabite@googlemail.com \
--cc=prohaska@zib.de \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).