@matheusbsbs / matheus-bagliano / commits / 6d8d8e0de3
Fork 0

git-am: Add tests for `--keep-cr`, `--no-keep-cr` and `am.keepcr`

Add tests for git-am using files with DOS line endings for various combinations of `--keep-cr`, `--no-keep-cr` and `am.keepcr`. Signed-off-by: Stefan-W. Hahn <stefan.hahn@s-hahn.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Stefan-W. Hahn committed Feb 27, 2010 at 15:20 UTC 6d8d8e0de3ca753cd482012d3695602e36356145
1 file changed +96
t/t4253-am-keep-cr-dos.sh new
+96
@@ -0,0 +1,96 @@
1 +#!/bin/sh
2 +#
3 +# Copyright (c) 2010 Stefan-W. Hahn
4 +#
5 +
6 +test_description='git-am mbox with dos line ending.
7 +
8 +'
9 +. ./test-lib.sh
10 +
11 +# Three patches which will be added as files with dos line ending.
12 +
13 +cat >file1 <<\EOF
14 +line 1
15 +EOF
16 +
17 +cat >file1a <<\EOF
18 +line 1
19 +line 4
20 +EOF
21 +
22 +cat >file2 <<\EOF
23 +line 1
24 +line 2
25 +EOF
26 +
27 +cat >file3 <<\EOF
28 +line 1
29 +line 2
30 +line 3
31 +EOF
32 +
33 +test_expect_success 'setup repository with dos files' '
34 + append_cr <file1 >file &&
35 + git add file &&
36 + git commit -m Initial &&
37 + git tag initial &&
38 + append_cr <file2 >file &&
39 + git commit -a -m Second &&
40 + append_cr <file3 >file &&
41 + git commit -a -m Third
42 +'
43 +
44 +test_expect_success 'am with dos files without --keep-cr' '
45 + git checkout -b dosfiles initial &&
46 + git format-patch -k initial..master &&
47 + test_must_fail git am -k -3 000*.patch &&
48 + git am --abort &&
49 + rm -rf .git/rebase-apply 000*.patch
50 +'
51 +
52 +test_expect_success 'am with dos files with --keep-cr' '
53 + git checkout -b dosfiles-keep-cr initial &&
54 + git format-patch -k --stdout initial..master | git am --keep-cr -k -3 &&
55 + git diff --exit-code master
56 +'
57 +
58 +test_expect_success 'am with dos files config am.keepcr' '
59 + git config am.keepcr 1 &&
60 + git checkout -b dosfiles-conf-keepcr initial &&
61 + git format-patch -k --stdout initial..master | git am -k -3 &&
62 + git diff --exit-code master
63 +'
64 +
65 +test_expect_success 'am with dos files config am.keepcr overriden by --no-keep-cr' '
66 + git config am.keepcr 1 &&
67 + git checkout -b dosfiles-conf-keepcr-override initial &&
68 + git format-patch -k initial..master &&
69 + test_must_fail git am -k -3 --no-keep-cr 000*.patch &&
70 + git am --abort &&
71 + rm -rf .git/rebase-apply 000*.patch
72 +'
73 +
74 +test_expect_success 'am with dos files with --keep-cr continue' '
75 + git checkout -b dosfiles-keep-cr-continue initial &&
76 + git format-patch -k initial..master &&
77 + append_cr <file1a >file &&
78 + git commit -m "different patch" file &&
79 + test_must_fail git am --keep-cr -k -3 000*.patch &&
80 + append_cr <file2 >file &&
81 + git add file &&
82 + git am -3 --resolved &&
83 + git diff --exit-code master
84 +'
85 +
86 +test_expect_success 'am with unix files config am.keepcr overriden by --no-keep-cr' '
87 + git config am.keepcr 1 &&
88 + git checkout -b unixfiles-conf-keepcr-override initial &&
89 + cp -f file1 file &&
90 + git commit -m "line ending to unix" file &&
91 + git format-patch -k initial..master &&
92 + git am -k -3 --no-keep-cr 000*.patch &&
93 + git diff --exit-code -w master
94 +'
95 +
96 +test_done