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

# quilt should not remove symlinks to patch files
	$ echo foo > foo
	$ quilt new test.diff
	> Patch patches/test.diff is now on top

	$ quilt add foo
	> File foo added to patch patches/test.diff

	$ echo "foo changed" > foo
	$ quilt refresh
	> Refreshed patch patches/test.diff

# Setup a symlink
	$ mv patches/test.diff .
	$ ln -s ../test.diff patches/test.diff
	$ readlink patches/test.diff
	> ../test.diff

# Test the refresh
	$ echo "foo changed 2" > foo
	$ quilt refresh --no-index -p ab
	> Refreshed patch patches/test.diff

	$ readlink patches/test.diff
	> ../test.diff

# Test the refresh --backup
	$ echo "foo changed 3" > foo
	$ touch -r patches/test.diff test.timeref
	$ quilt refresh --backup --no-index -p ab
	> Refreshed patch patches/test.diff

	$ readlink patches/test.diff
	> ../test.diff

	$ cat patches/test.diff
	> --- a/foo
	> +++ b/foo
	> @@ -1 +1 @@
	> -foo
	> +foo changed 3

	$ readlink patches/test.diff~
	$ echo %{?}
	> 1

	$ cat patches/test.diff~
	> --- a/foo
	> +++ b/foo
	> @@ -1 +1 @@
	> -foo
	> +foo changed 2

	$ [ patches/test.diff~ -nt test.timeref ] && echo "mtimes differ"

# Test the header update
	$ quilt header -a
	< A test patch
	> Appended text to header of patch patches/test.diff

	$ readlink patches/test.diff
	> ../test.diff

# Test the header update with a backup
	$ touch -r patches/test.diff test.timeref
	$ quilt header -r --backup
	> Replaced header of patch patches/test.diff

	$ readlink patches/test.diff
	> ../test.diff

	$ cat patches/test.diff
	> --- a/foo
	> +++ b/foo
	> @@ -1 +1 @@
	> -foo
	> +foo changed 3

	$ readlink patches/test.diff~
	$ echo %{?}
	> 1

	$ cat patches/test.diff~
	> A test patch
	> --- a/foo
	> +++ b/foo
	> @@ -1 +1 @@
	> -foo
	> +foo changed 3

	$ [ patches/test.diff~ -nt test.timeref ] && echo "mtimes differ"

# Test the refresh when target is read-only
	$ chmod -w test.diff
	$ echo "foo changed 4" > foo
	$ quilt refresh --no-index -p ab
	> Refreshed patch patches/test.diff

	$ readlink patches/test.diff
	$ echo %{?}
	> 1

	$ cat patches/test.diff
	> --- a/foo
	> +++ b/foo
	> @@ -1 +1 @@
	> -foo
	> +foo changed 4

# Test the refresh --backup when target is read-only
	$ rm -f test.diff
	$ mv patches/test.diff .
	$ ln -s ../test.diff patches/test.diff
	$ chmod -w test.diff

	$ echo "foo changed 5" > foo
	$ quilt refresh --backup --no-index -p ab
	> Refreshed patch patches/test.diff

	$ readlink patches/test.diff
	$ echo %{?}
	> 1

	$ cat patches/test.diff
	> --- a/foo
	> +++ b/foo
	> @@ -1 +1 @@
	> -foo
	> +foo changed 5

	$ readlink patches/test.diff~
	$ echo %{?}
	> 1

	$ cat patches/test.diff~
	> --- a/foo
	> +++ b/foo
	> @@ -1 +1 @@
	> -foo
	> +foo changed 4