diff options
-rw-r--r-- | quilt/scripts/patchfns.in | 35 | ||||
-rw-r--r-- | test/altered-series.test | 44 |
2 files changed, 76 insertions, 3 deletions
diff --git a/quilt/scripts/patchfns.in b/quilt/scripts/patchfns.in index 91012ec..f3baa29 100644 --- a/quilt/scripts/patchfns.in +++ b/quilt/scripts/patchfns.in @@ -953,6 +953,24 @@ version_check() return 1 } +consistency_check() +{ + local top applied patches + + top=$(top_patch) + applied=$(applied_before "$top") + patches=$(patches_before "$top") + + if [ "$applied" != "$patches" ] + then + return 1 + else + # Skip check until series file is modified again + touch "$DB" + return 0 + fi +} + print_patch() { echo "${QUILT_PATCHES_PREFIX:+$SUBDIR_DOWN$QUILT_PATCHES/}$1" @@ -1109,10 +1127,21 @@ fi DB="$QUILT_PC/applied-patches" -if [ -z "$skip_version_check" ] && ! version_check +if [ -z "$skip_version_check" ] then - printf $"The working tree was created by an older version of quilt. Please run 'quilt upgrade'.\n" >&2 - exit 1 + if ! version_check + then + printf $"The working tree was created by an older version of quilt. Please run 'quilt upgrade'.\n" >&2 + exit 1 + fi + + # Check if series file was modified manually, and if this is the case, + # make sure it is still consistent with the applied patches + if [ -s "$DB" -a ! "$DB" -nt "$SERIES" ] && [ "$QUILT_COMMAND" != pop ] && ! consistency_check + then + printf $"The series file no longer matches the applied patches. Please run 'quilt pop -a'.\n" >&2 + exit 1 + fi fi ### Local Variables: ### mode: shell-script diff --git a/test/altered-series.test b/test/altered-series.test new file mode 100644 index 0000000..5c231f3 --- /dev/null +++ b/test/altered-series.test @@ -0,0 +1,44 @@ +# Check that manual changes to the series file are detected + +$ mkdir patches +$ cat > patches/series +< 01.patch +< 02.patch +< 03.patch + +$ quilt push -q +> Applying patch patches/01.patch +> Patch patches/01.patch does not exist; applied empty patch +> Now at patch patches/01.patch + +$ quilt series -v +> = patches/01.patch +> patches/02.patch +> patches/03.patch + +# Touch the series file but preserve the order -> OK +$ touch patches/series + +$ quilt series -v +> = patches/01.patch +> patches/02.patch +> patches/03.patch + +# Change the order of the patch series -> complain +$ cat > patches/series +< 03.patch +< 01.patch +< 02.patch + +$ quilt series -v +> The series file no longer matches the applied patches. Please run 'quilt pop -a'. + +$ quilt pop -a +> Patch patches/01.patch appears to be empty, removing +> +> No patches applied + +$ quilt series -v +> patches/03.patch +> patches/01.patch +> patches/02.patch |