Merge branch 'ab/gitweb-abbrev-links'
[git.git] / t / t4138-apply-ws-expansion.sh
blob0ffe33fbefdc72c664d3914da234f7d4052ed462
1 #!/bin/sh
3 # Copyright (C) 2015 Kyle J. McKay
6 test_description='git apply test patches with whitespace expansion.'
8 . ./test-lib.sh
10 test_expect_success setup '
12 ## create test-N, patchN.patch, expect-N files
15 # test 1
16 printf "\t%s\n" 1 2 3 4 5 6 >before &&
17 printf "\t%s\n" 1 2 3 >after &&
18 printf "%64s\n" a b c >>after &&
19 printf "\t%s\n" 4 5 6 >>after &&
20 git diff --no-index before after |
21 sed -e "s/before/test-1/" -e "s/after/test-1/" >patch1.patch &&
22 printf "%64s\n" 1 2 3 4 5 6 >test-1 &&
23 printf "%64s\n" 1 2 3 a b c 4 5 6 >expect-1 &&
25 # test 2
26 printf "\t%s\n" a b c d e f >before &&
27 printf "\t%s\n" a b c >after &&
28 n=10 &&
29 x=1 &&
30 while test $x -lt $n
32 printf "%63s%d\n" "" $x >>after
33 x=$(( $x + 1 ))
34 done &&
35 printf "\t%s\n" d e f >>after &&
36 git diff --no-index before after |
37 sed -e "s/before/test-2/" -e "s/after/test-2/" >patch2.patch &&
38 printf "%64s\n" a b c d e f >test-2 &&
39 printf "%64s\n" a b c >expect-2 &&
40 x=1 &&
41 while test $x -lt $n
43 printf "%63s%d\n" "" $x >>expect-2
44 x=$(( $x + 1 ))
45 done &&
46 printf "%64s\n" d e f >>expect-2 &&
48 # test 3
49 printf "\t%s\n" a b c d e f >before &&
50 printf "\t%s\n" a b c >after &&
51 n=100 &&
52 x=0 &&
53 while test $x -lt $n
55 printf "%63s%02d\n" "" $x >>after
56 x=$(( $x + 1 ))
57 done &&
58 printf "\t%s\n" d e f >>after &&
59 git diff --no-index before after |
60 sed -e "s/before/test-3/" -e "s/after/test-3/" >patch3.patch &&
61 printf "%64s\n" a b c d e f >test-3 &&
62 printf "%64s\n" a b c >expect-3 &&
63 x=0 &&
64 while test $x -lt $n
66 printf "%63s%02d\n" "" $x >>expect-3
67 x=$(( $x + 1 ))
68 done &&
69 printf "%64s\n" d e f >>expect-3 &&
71 # test 4
72 >before &&
73 x=0 &&
74 while test $x -lt 50
76 printf "\t%02d\n" $x >>before
77 x=$(( $x + 1 ))
78 done &&
79 cat before >after &&
80 printf "%64s\n" a b c >>after &&
81 while test $x -lt 100
83 printf "\t%02d\n" $x >>before
84 printf "\t%02d\n" $x >>after
85 x=$(( $x + 1 ))
86 done &&
87 git diff --no-index before after |
88 sed -e "s/before/test-4/" -e "s/after/test-4/" >patch4.patch &&
89 >test-4 &&
90 x=0 &&
91 while test $x -lt 50
93 printf "%63s%02d\n" "" $x >>test-4
94 x=$(( $x + 1 ))
95 done &&
96 cat test-4 >expect-4 &&
97 printf "%64s\n" a b c >>expect-4 &&
98 while test $x -lt 100
100 printf "%63s%02d\n" "" $x >>test-4
101 printf "%63s%02d\n" "" $x >>expect-4
102 x=$(( $x + 1 ))
103 done &&
105 git config core.whitespace tab-in-indent,tabwidth=63 &&
106 git config apply.whitespace fix
110 # Note that `patch` can successfully apply all patches when run
111 # with the --ignore-whitespace option.
113 for t in 1 2 3 4
115 test_expect_success 'apply with ws expansion (t=$t)' '
116 git apply patch$t.patch &&
117 test_cmp test-$t expect-$t
119 done
121 test_done