summaryrefslogtreecommitdiffstats
path: root/test/import.test
blob: 3a11930b249353da58c81da0d70b45e5b01cc1ea (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
	$ mkdir patches

	$ quilt new patch1.diff
	> Patch %{P}patch1.diff is now on top

	$ quilt add f
	> File f added to patch %{P}patch1.diff

	$ echo f > f

	$ quilt refresh
	> Refreshed patch %{P}patch1.diff

	$ quilt new patchR.diff
	> Patch %{P}patchR.diff is now on top

	$ quilt add f
	> File f added to patch %{P}patchR.diff

	$ rm -f f

	$ quilt refresh
	> Refreshed patch %{P}patchR.diff

	$ quilt fork patchRp0.diff
	> Fork of patch %{P}patchR.diff created as %{P}patchRp0.diff

	$ quilt refresh -p0
	> Refreshed patch %{P}patchRp0.diff

	$ quilt pop -a
	> Removing patch patches/patchRp0.diff
	> Restoring f
	>
	> Removing patch patches/patch1.diff
	> Removing f
	>
	> No patches applied

	$ mkdir t
	$ mv patches/patch1.diff t/patch1.diff
	$ mv patches/patchR.diff t/patchR.diff
	$ mv patches/patchRp0.diff t/patchRp0.diff

	# test importing into an empty series
	$ rm -rf patches/ .pc/
	$ mkdir patches
	$ quilt import t/patch1.diff
	> Importing patch t/patch1.diff (stored as patches/patch1.diff)

	$ quilt push
	> Applying patch patches/patch1.diff
	>~ patching file `?f'?
	>
	> Now at patch patches/patch1.diff

	$ quilt new patch2.diff
	> Patch %{P}patch2.diff is now on top

	$ quilt add g
	> File g added to patch %{P}patch2.diff

	$ echo g > g

	$ quilt refresh
	> Refreshed patch %{P}patch2.diff

	$ quilt pop
	> Removing patch patches/patch2.diff
	> Removing g
	>
	> Now at patch patches/patch1.diff

	$ quilt header -a
	< original description
	> Appended text to header of patch patches/patch1.diff

	$ quilt pop
	> Removing patch patches/patch1.diff
	> Removing f
	>
	> No patches applied

	$ quilt delete patch1
	> Removed patch patches/patch1.diff

	$ cat patches/series
	> patch2.diff

	# test a few error cases

	$ quilt import missing.diff
	> Patch missing.diff does not exist

	$ quilt import patches/patch1.diff
	> Importing patch patches/patch1.diff

	$ quilt import patches/patch2.diff
	> Patch patches/patch2.diff already exists in series.

	# a simple use of import

	$ quilt import t/patch1.diff
	> Patch patches/patch1.diff exists. Replace with -f.

	$ quilt import -f t/patch1.diff
	> Replacing patch patches/patch1.diff with new version

	# an import requiring a description merge
	$ sed -e 's/original/new/' patches/patch1.diff > t/patch1.diff
	$ quilt import t/patch1.diff
	> Patch patches/patch1.diff exists. Replace with -f.

	$ quilt import -f t/patch1.diff
	> Patch headers differ:
	> @@ -1 +1 @@
	> -original description
	> +new description
	> Please use -d {o|a|n} to specify which patch header(s) to keep.

	$ quilt import -d a -f t/patch1.diff
	> Replacing patch patches/patch1.diff with new version

	# quilt header does not work in this case because it stops at '---'
	$ head -n 3 patches/patch1.diff
	> original description
	> ---
	> new description

	$ quilt import -d n -f t/patch1.diff
	> Replacing patch patches/patch1.diff with new version

	$ quilt header patch1
	> new description

	$ quilt delete patch1
	> Removed patch patches/patch1.diff

	# make sure it accepts non-conflicting names
	# a small presentation problem here

	$ cp patches/patch1.diff t/patch1.patch
	$ quilt import t/patch1.patch
	> Importing patch t/patch1.patch (stored as patches/patch1.patch)

	$ ls patches/
	> patch1.diff
	> patch1.patch
	> patch2.diff
	> series

	$ cat patches/series
	> patch1.patch
	> patch2.diff

	$ quilt delete patch1.diff
	> Patch patch1.diff is not in series

	# test importing a reverse patch
	$ rm -rf patches/ .pc/
	$ mkdir patches
	$ quilt import -R t/patchR.diff
	> Importing patch t/patchR.diff (stored as patches/patchR.diff)

	$ quilt push
	> Applying patch patches/patchR.diff
	>~ patching file `?f'?
	>
	> Now at patch patches/patchR.diff

	$ cat f
	> f

	$ cat patches/series
	> patchR.diff -R

	# test that comments are preserved
	$ echo "# Test of -R import" > patches/series
	$ echo "patchR.diff -R # This patch was originally -R -p1" >> patches/series

	# refreshing a reverse patch un-reverses it
	$ quilt refresh
	> Refreshed patch %{P}patchR.diff

	$ cat patches/series
	> # Test of -R import
	> patchR.diff # This patch was originally -R -p1

	$ touch f
	$ quilt pop
	> Removing patch patches/patchR.diff
	> Removing f
	>
	> No patches applied

	# test importing a reverse patch with strip level
	$ rm -rf patches/ .pc/
	$ mkdir patches
	$ quilt import -R -p0 t/patchRp0.diff
	> Importing patch t/patchRp0.diff (stored as patches/patchRp0.diff)

	$ quilt push
	> Applying patch patches/patchRp0.diff
	>~ patching file `?f'?
	>
	> Now at patch patches/patchRp0.diff

	$ cat f
	> f

	$ cat patches/series
	> patchRp0.diff -p0 -R

	# refreshing a reverse patch un-reverses it
	$ quilt refresh
	> Refreshed patch %{P}patchRp0.diff

	$ cat patches/series
	> patchRp0.diff -p0

	$ touch f
	$ quilt pop
	> Removing patch patches/patchRp0.diff
	> Removing f
	>
	> No patches applied

	# Test importing multiple patches at once
	$ rm -rf patches/ .pc/
	$ mkdir patches
	$ quilt import t/patch1.diff t/patchR.diff
	> Importing patch t/patch1.diff (stored as patches/patch1.diff)
	> Importing patch t/patchR.diff (stored as patches/patchR.diff)

	$ cat patches/series
	> patch1.diff
	> patchR.diff

	$ rm -rf patches/ .pc/
	$ mkdir patches
	$ quilt import t/patchR.diff
	> Importing patch t/patchR.diff (stored as patches/patchR.diff)
	$ quilt import t/patch1.diff
	> Importing patch t/patch1.diff (stored as patches/patch1.diff)

	$ cat patches/series
	> patch1.diff
	> patchR.diff

# Also test importing when in a subdirectory
	$ touch empty.patch
	$ cd t
	$ touch empty2.patch
	$ quilt import ../empty.patch
	> Importing patch ../empty.patch (stored as ../patches/empty.patch)
	$ quilt import %{PWD}/empty2.patch
	> Importing patch %{PWD}/empty2.patch (stored as ../patches/empty2.patch)