The sequence
quilt refresh --diffstat
echo "Appended line" | quilt header -a
puts the appended line _after_ the diffstat, contrary to expectation.
Instead, strip out the diffstat info (as is done already for "-r"),
and append stdin to what remains of the header.
---
quilt/header.in | 9 ++++++++-
quilt/scripts/patchfns.in | 17 +++++++++++++++++
test/header.test | 36 ++++++++++++++++++++++++++++++++++++
3 files changed, 61 insertions(+), 1 deletion(-)
Index: quilt/quilt/header.in
===================================================================
--- quilt.orig/quilt/header.in 2010-01-13 20:07:00.000000000 -0800
+++ quilt/quilt/header.in 2010-01-13 20:13:53.000000000 -0800
@@ -139,7 +139,14 @@ else
tmp2=$(gen_tempfile) || exit 1
add_exit_handler "rm -f $tmp $tmp2"
- ( if [ -z "$opt_replace" ]
+ ( if [ -n "$opt_append" ]
+ then
+ # diffstat lines are always at the end of the
+ # comment section proper, and are preceded by
+ # a "---" line and followed by a blank line.
+ cat_file $patch_file_or_null | patch_header \
+ | strip_diffstat_and_padding
+ elif [ -n "$opt_edit" ]
then
cat_file $patch_file_or_null | patch_header
fi
Index: quilt/test/header.test
===================================================================
--- quilt.orig/test/header.test 2010-01-13 20:07:00.000000000 -0800
+++ quilt/test/header.test 2010-01-13 20:29:27.000000000 -0800
@@ -45,5 +45,41 @@
> -foo
> +bar
+ $ quilt refresh --diffstat
+ > Refreshed patch %{P}patch
+
+ $ quilt header -r
+ < Header2
+ > Replaced header of patch patches/patch
+ $ head -n 2 %{P}patch
+ > Header2
+ > Index: d/foo
+
+ $ quilt refresh --diffstat
+ > Refreshed patch %{P}patch
+
+ $ quilt header -a
+ < Appended
+ > Appended text to header of patch patches/patch
+
+ $ quilt header
+ > Header2
+ > Appended
+ $ head -n 3 %{P}patch
+ > Header2
+ > Appended
+ > Index: d/foo
+
+ $ cat patches/patch
+ > Header2
+ > Appended
+ > Index: d/foo
+ > ===================================================================
+ > --- d.orig/foo
+ > +++ d/foo
+ > @@ -1 +1 @@
+ > -foo
+ > +bar
+
$ cd ..
$ rm -rf d
Index: quilt/quilt/scripts/patchfns.in
===================================================================
--- quilt.orig/quilt/scripts/patchfns.in 2010-01-13 20:07:00.000000000
-0800
+++ quilt/quilt/scripts/patchfns.in 2010-01-13 20:13:53.000000000 -0800
@@ -852,6 +852,23 @@ strip_diffstat()
'
}
+strip_diffstat_and_padding()
+{
+ # 'eat' stores lines that match the first pattern but may not
+ # be part of a diffstat.
+ awk '
+ /#? .* \| / || /^---$/ \
+ { eat = eat $0 "\n"
+ next }
+ /^#? .* files? changed(, .* insertions?\(\+\))?(, .* deletions?\(-\))?/
\
+ { eat = ""
+ getline
+ next }
+ { print eat $0
+ eat = "" }
+ '
+}
+
in_array()
{
local a=$1
_______________________________________________
Quilt-dev mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/quilt-dev