File 0002-Change-where-new-patches-are-inserted-in-series.patch of Package quilt
From 25d4d192ab283cb1581ce31e0307bdde64221b6e Mon Sep 17 00:00:00 2001
From: Benjamin Poirier <bpoirier@suse.de>
Date: Tue, 3 Oct 2017 16:30:47 -0400
Subject: [PATCH 2/5] Change where new patches are inserted in series
changes insert_in_series to add the new entry after the specified patch,
not before the next one. This makes a difference when there are comments or
empty lines in between the two.
---
quilt/import.in | 5 +++--
quilt/scripts/patchfns.in | 28 +++++++++++-----------------
2 files changed, 14 insertions(+), 19 deletions(-)
diff --git a/quilt/import.in b/quilt/import.in
index 7c84121..faa5a95 100644
--- a/quilt/import.in
+++ b/quilt/import.in
@@ -177,7 +177,7 @@ then
fi
fi
-before=$(patch_after "$(top_patch)")
+after=$(top_patch)
for orig_patch_file in "$@"
do
if [ -n "$opt_patch" ]
@@ -244,12 +244,13 @@ do
[ "$merged_patch_file" != "$patch_file" ] && rm -f "$merged_patch_file"
if ! patch_in_series $patch &&
- ! insert_in_series $patch "$patch_args" "$before"
+ ! insert_in_series $patch "$patch_args" "$after"
then
printf $"Failed to insert patch %s into file series\n" \
"$(print_patch $patch)" >&2
exit 1
fi
+ after=$patch
rm -rf $QUILT_PC/$patch
done
diff --git a/quilt/scripts/patchfns.in b/quilt/scripts/patchfns.in
index 1faaa7f..54522a5 100644
--- a/quilt/scripts/patchfns.in
+++ b/quilt/scripts/patchfns.in
@@ -231,14 +231,14 @@ patch_in_series()
insert_in_series()
{
local patch=$1 patch_args=$2
- local before tmpfile
+ local after tmpfile
if [ -e "$SERIES" -a ! -f "$SERIES" ]; then
printf $"%s is not a regular file\n" "$SERIES" >&2
return 1
fi
- before=${3-$(patch_after "$(top_patch)")}
+ after=${3-$(top_patch)}
if [ -n "$patch_args" ]
then
@@ -246,32 +246,26 @@ insert_in_series()
fi
tmpfile=$(gen_tempfile) || return 1
- mkdir -p "$(dirname "$SERIES")"
- if [ -n "$before" ]
+ mkdir -p $(dirname "$SERIES")
+ if [ -n "$after" ]
then
- awk '
- /^[[:space:]]*'"$(quote_awk_re $before)"'([ \t]|$)/ \
- {
- match($0, "^([[:space:]]*)'"$(quote_awk_re $before | sed -e 's:\\:\\\\:g')"'([ \t]|$)", a)
- print a[1] "'"$patch$patch_args"'"
- }
- { print }
- ' "$SERIES" > $tmpfile
+ sed -Ee 's/^([[:space:]]*)'"$(quote_sed_re $after)"'([ \t]|$).*$/&\n\1'"$(quote_sed_re $patch$patch_args)"'/' \
+ "$SERIES" > $tmpfile
status=$?
if [ $status -ne 0 ]
then
rm -f $tmpfile
return 1
fi
+
+ # Ensure there is a trailing newline in the file
+ ensure_trailing_newline $tmpfile
else
+ echo "$patch$patch_args" > $tmpfile
if [ -e "$SERIES" ]
then
- cat "$SERIES" > $tmpfile
-
- # Ensure there is a trailing newline before we append the rest
- ensure_trailing_newline $tmpfile
+ cat "$SERIES" >> $tmpfile
fi
- echo "$patch$patch_args" >> $tmpfile
fi
cat $tmpfile > "$SERIES"
rm -f $tmpfile
--
2.45.2