]>
Commit | Line | Data |
---|---|---|
c4593faf JH |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2009 Junio C Hamano | |
4 | ||
5 | test_description='git-apply notices removal patches generated by GNU diff' | |
6 | ||
f54f48fc ÆAB |
7 | |
8 | TEST_PASSES_SANITIZE_LEAK=true | |
c4593faf JH |
9 | . ./test-lib.sh |
10 | ||
11 | test_expect_success setup ' | |
12 | cat <<-EOF >c && | |
13 | diff -ruN a/file b/file | |
14 | --- a/file TS0 | |
15 | +++ b/file TS1 | |
16 | @@ -0,0 +1 @@ | |
17 | +something | |
18 | EOF | |
19 | ||
20 | cat <<-EOF >d && | |
21 | diff -ruN a/file b/file | |
22 | --- a/file TS0 | |
23 | +++ b/file TS1 | |
24 | @@ -1 +0,0 @@ | |
25 | -something | |
26 | EOF | |
27 | ||
28 | timeWest="1982-09-16 07:00:00.000000000 -0800" && | |
29 | timeGMT="1982-09-16 15:00:00.000000000 +0000" && | |
30 | timeEast="1982-09-17 00:00:00.000000000 +0900" && | |
31 | ||
32 | epocWest="1969-12-31 16:00:00.000000000 -0800" && | |
33 | epocGMT="1970-01-01 00:00:00.000000000 +0000" && | |
34 | epocEast="1970-01-01 09:00:00.000000000 +0900" && | |
a1980c4e | 35 | epocWest2="1969-12-31 16:00:00 -08:00" && |
c4593faf JH |
36 | |
37 | sed -e "s/TS0/$epocWest/" -e "s/TS1/$timeWest/" <c >createWest.patch && | |
38 | sed -e "s/TS0/$epocEast/" -e "s/TS1/$timeEast/" <c >createEast.patch && | |
39 | sed -e "s/TS0/$epocGMT/" -e "s/TS1/$timeGMT/" <c >createGMT.patch && | |
40 | ||
41 | sed -e "s/TS0/$timeWest/" -e "s/TS1/$timeWest/" <c >addWest.patch && | |
42 | sed -e "s/TS0/$timeEast/" -e "s/TS1/$timeEast/" <c >addEast.patch && | |
43 | sed -e "s/TS0/$timeGMT/" -e "s/TS1/$timeGMT/" <c >addGMT.patch && | |
44 | ||
45 | sed -e "s/TS0/$timeWest/" -e "s/TS1/$timeWest/" <d >emptyWest.patch && | |
46 | sed -e "s/TS0/$timeEast/" -e "s/TS1/$timeEast/" <d >emptyEast.patch && | |
47 | sed -e "s/TS0/$timeGMT/" -e "s/TS1/$timeGMT/" <d >emptyGMT.patch && | |
48 | ||
49 | sed -e "s/TS0/$timeWest/" -e "s/TS1/$epocWest/" <d >removeWest.patch && | |
50 | sed -e "s/TS0/$timeEast/" -e "s/TS1/$epocEast/" <d >removeEast.patch && | |
51 | sed -e "s/TS0/$timeGMT/" -e "s/TS1/$epocGMT/" <d >removeGMT.patch && | |
a1980c4e | 52 | sed -e "s/TS0/$timeWest/" -e "s/TS1/$epocWest2/" <d >removeWest2.patch && |
c4593faf | 53 | |
1c5e94f4 | 54 | echo something >something |
c4593faf JH |
55 | ' |
56 | ||
57 | for patch in *.patch | |
58 | do | |
59 | test_expect_success "test $patch" ' | |
60 | rm -f file .git/index && | |
61 | case "$patch" in | |
62 | create*) | |
63 | # must be able to create | |
64 | git apply --index $patch && | |
65 | test_cmp file something && | |
66 | # must notice the file is already there | |
67 | >file && | |
68 | git add file && | |
69 | test_must_fail git apply $patch | |
70 | ;; | |
71 | add*) | |
72 | # must be able to create or patch | |
73 | git apply $patch && | |
74 | test_cmp file something && | |
75 | >file && | |
76 | git apply $patch && | |
77 | test_cmp file something | |
78 | ;; | |
79 | empty*) | |
80 | # must leave an empty file | |
81 | cat something >file && | |
82 | git add file && | |
83 | git apply --index $patch && | |
84 | test -f file && | |
1c5e94f4 | 85 | test_must_be_empty file |
c4593faf JH |
86 | ;; |
87 | remove*) | |
88 | # must remove the file | |
89 | cat something >file && | |
90 | git add file && | |
91 | git apply --index $patch && | |
92 | ! test -f file | |
93 | ;; | |
94 | esac | |
95 | ' | |
96 | done | |
97 | ||
98 | test_done |