In the case of a generated or manually tweaked series file, it can
happen that the same patch shows up twice in the series file. Check
for this before pushing any patch, otherwise we would corrupt quilt's
internal database.

This fixes bug #20628:
https://savannah.nongnu.org/bugs/?20628
---
 quilt/push.in                       |   10 ++++++++++
 test/duplicate-patch-in-series.test |   31 +++++++++++++++++++++++++++++++
 2 files changed, 41 insertions(+)

--- /dev/null   1970-01-01 00:00:00.000000000 +0000
+++ quilt/test/duplicate-patch-in-series.test   2014-02-26 18:17:01.240836748 
+0100
@@ -0,0 +1,31 @@
+# Check that duplicate patches in generated series files won't cause havoc
+# See bug #20628 at https://savannah.nongnu.org/bugs/?20628
+
+$ mkdir patches
+$ echo "old line" > file.txt
+
+$ cat > patches/first.patch
+< --- file.txt
+< +++ file.txt
+< @@ -1 +1 @@
+< -old line
+< +new line
+
+$ cat > patches/series
+< first.patch -p0
+< first.patch -p0
+
+$ quilt push
+> Applying patch %{P}first.patch
+> patching file file.txt
+>
+> Now at patch %{P}first.patch
+
+$ quilt push
+> Patch %{P}first.patch is already applied; check your series file
+
+$ quilt pop
+> Removing patch %{P}first.patch
+> Restoring file.txt
+>
+> No patches applied
--- quilt.orig/quilt/push.in    2014-01-20 12:02:58.874246011 +0100
+++ quilt/quilt/push.in 2014-02-26 18:18:27.093721147 +0100
@@ -177,6 +177,16 @@ add_patch()
        local patch_file=$(patch_file_name "$patch")
        local file status tmp
 
+       # In theory, the patch can't be already applied. However in the case
+       # of a generated or manually tweaked series file, this could happen and
+       # cause havoc, so play it safe and check.
+       if is_applied "$patch"
+       then
+               printf $"Patch %s is already applied; check your series file\n" 
\
+                      "$(print_patch "$patch")"
+               return 1
+       fi
+
        printf $"Applying patch %s\n" "$(print_patch "$patch")"
        trap "interrupt $patch" SIGINT
 

-- 
Jean Delvare
Suse L3 Support


_______________________________________________
Quilt-dev mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/quilt-dev

Reply via email to