Package: quilt / 0.65-3

restrict-patch-names Patch series | download
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
Description: Enforce valid patch names
 Allowing patch names to contain spaces would require major changes
 (such as the format of the series file), so we'd better detect that
 the user tries to use spaces in the patch name, and refuse it.
 .
 Also, refuse patches named series, as it would result in awful
 corruptions of the internal state.
Author: Martin Quinson
---
 quilt/fork.in                  |    2 +
 quilt/import.in                |    2 +
 quilt/new.in                   |    2 +
 quilt/rename.in                |    2 +
 quilt/scripts/patchfns.in      |   17 ++++++++++++
 test/restrict-patch-names.test |   56 +++++++++++++++++++++++++++++++++++++++++
 6 files changed, 81 insertions(+)

--- a/quilt/scripts/patchfns.in
+++ b/quilt/scripts/patchfns.in
@@ -1000,6 +1000,23 @@
 	fi
 }
 
+# We don't want patch with spaces in their name
+check_potential_patchname()
+{
+	local patch="$1"
+	if echo "$patch" | grep -q ' '
+	then
+		printf $"Patch name '%s' invalid: cannot contain spaces.\n" "$patch" >&2
+		exit 1
+	fi
+
+	if [ "$patch" = "$QUILT_SERIES" ]
+	then
+		printf $"No patch can be named '%s' as this would conflict with the\nseries file used internally by quilt.\n" "$QUILT_SERIES" >&2
+		exit 1
+	fi
+}
+
 print_patch()
 {
 	echo "${QUILT_PATCHES_PREFIX:+$SUBDIR_DOWN$QUILT_PATCHES/}$1"
--- a/quilt/new.in
+++ b/quilt/new.in
@@ -92,6 +92,8 @@
 
 patch=${1#$QUILT_PATCHES/}
 
+check_potential_patchname "$patch"
+
 if patch_in_series $patch
 then
 	printf $"Patch %s exists already\n" "$(print_patch $patch)" >&2
--- a/quilt/import.in
+++ b/quilt/import.in
@@ -186,6 +186,8 @@
 		patch=${orig_patch_file##*/}
 	fi
 
+	check_potential_patchname "$patch"
+
 	patch_file=$(find_patch_file "$orig_patch_file") || exit 1
 	merged_patch_file="$patch_file"
 
--- a/quilt/fork.in
+++ b/quilt/fork.in
@@ -77,6 +77,8 @@
 
 new_patch=${new_patch#$QUILT_PATCHES/}
 
+check_potential_patchname "$new_patch"
+
 if patch_in_series $new_patch || \
    [ -d "$QUILT_PC/$new_patch" ] || \
    [ -e "$(patch_file_name $new_patch)" ]
--- a/quilt/rename.in
+++ b/quilt/rename.in
@@ -77,6 +77,8 @@
 
 new_patch=${1#$QUILT_PATCHES/}
 
+check_potential_patchname "$new_patch"
+
 if patch_in_series "$new_patch" || \
    [ -d "$QUILT_PC/$new_patch" ] || \
    [ -e "$(patch_file_name "$new_patch")" ]
--- /dev/null
+++ b/test/restrict-patch-names.test
@@ -0,0 +1,56 @@
+$ mkdir patches
+
+$ quilt new "name with spaces"
+> Patch name 'name with spaces' invalid: cannot contain spaces.
+$ echo %{?}
+> 1
+
+$ quilt new series
+> No patch can be named 'series' as this would conflict with the
+> series file used internally by quilt.
+$ echo %{?}
+> 1
+
+
+
+$ echo "+toto" > patchfile
+
+$ quilt import -P 'name2 with spaces' patchfile
+> Patch name 'name2 with spaces' invalid: cannot contain spaces.
+$ echo %{?}
+> 1
+
+$ quilt import -P series patchfile
+> No patch can be named 'series' as this would conflict with the
+> series file used internally by quilt.
+$ echo %{?}
+> 1
+
+
+
+$ quilt new patch1
+> Patch patches/patch1 is now on top
+
+$ quilt fork "patch 1"
+> Patch name 'patch 1' invalid: cannot contain spaces.
+$ echo %{?}
+> 1
+
+$ quilt fork series
+> No patch can be named 'series' as this would conflict with the
+> series file used internally by quilt.
+$ echo %{?}
+> 1
+
+
+
+$ quilt rename "patch 1"
+> Patch name 'patch 1' invalid: cannot contain spaces.
+$ echo %{?}
+> 1
+
+$ quilt rename series
+> No patch can be named 'series' as this would conflict with the
+> series file used internally by quilt.
+$ echo %{?}
+> 1