summaryrefslogtreecommitdiffstats
path: root/test/revert.test
blob: d86dcd6cdf9c8abceb5ccc3a71faa2fa53b8ca22 (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
	$ mkdir patches

	$ mkdir sub
	$ echo f1 > sub/f
	$ echo g1 > sub/g
	$ quilt new p.diff
	> Patch %{P}p.diff is now on top

	$ quilt add sub/f sub/g sub/h
	> File sub/f added to patch %{P}p.diff
	> File sub/g added to patch %{P}p.diff
	> File sub/h added to patch %{P}p.diff

	$ echo h1 > sub/h
	$ quilt revert sub/h
	> Changes to sub/h in patch %{P}p.diff reverted

	$ quilt diff -z

# Our patch modifies file f, deletes file g and creates file h
	$ echo f2 > sub/f
	$ rm -f sub/g
	$ echo h2 > sub/h
	$ quilt refresh
	> Refreshed patch %{P}p.diff

# Check if we can revert modifications
	$ cd sub
	$ echo f3 > f
	$ echo h3 > h
	$ quilt revert f g h
	> Changes to sub/f in patch %{_P}p.diff reverted
	> File sub/g is unchanged
	> Changes to sub/h in patch %{_P}p.diff reverted

	$ quilt diff -z

# Check if we can revert file creation
	$ echo g3 > g
	$ quilt revert f g
	> File sub/f is unchanged
	> Changes to sub/g in patch %{_P}p.diff reverted

	$ quilt diff -z
	$ [ ! -e g ] || echo "File sub/g shouldn't exist"

# Check if we can revert file deletion
	$ rm f h
	$ quilt revert f h
	> Changes to sub/f in patch %{_P}p.diff reverted
	> Changes to sub/h in patch %{_P}p.diff reverted

	$ quilt diff -z
	$ [ -e f ] || echo "File sub/f should exist"
	$ [ -e h ] || echo "File sub/h should exist"