[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Quilt-dev] Some enhancements for the "quilt header" command
From: |
Joe Green |
Subject: |
Re: [Quilt-dev] Some enhancements for the "quilt header" command |
Date: |
Thu, 25 Aug 2005 16:48:10 -0700 |
User-agent: |
Mozilla Thunderbird 1.0.2 (X11/20050317) |
John Vandenberg wrote:
On 8/25/05, Joe Green <address@hidden> wrote:
This patch allows comments to be placed in header template files that will
be stripped out when the header is saved. These comments can be used to
prompt the user for the kind of information that should be in the header.
This implemenation assumes any line in the header beginning with "//" is a
comment, and strips it out.
For the comment marker, I think hash
would be more appropriate. When a // is on the first line of a file,
file(1) will report 'ASCII C++ program text'; a hash reports 'ASCII
text'.
Yes, I pointed out the sequence used because I thought there might be
some discussion about that. I have seen people use "#" comments in
patch headers, though, so I'm not sure it's OK to strip them out. I
wondered about "//" as well, but I've never seen anyone use that. The
sequence used is pretty arbitrary, though, so it's certainly open to
discussion.
As a side thought, it would be useful to be able to include
CVS/Template in the list of templates. CVS/Template may contain
comments prefixed with 'CVS: '.
It wouldn't be hard to do this, but Andreas doesn't seem to like coding
in CVS support.
quilt-padheader.patch
This patch adds a "--pad" option to the header command to automatically add
one or more blank lines to separate the header from the body.
It would be nice if this also stripped extra blank lines greater than --pad.
That's a good idea. I've attached an updated patch that does this.
--
Joe Green <address@hidden>
MontaVista Software, Inc.
|
Source: MontaVista Software, Inc. <address@hidden>
Type: Enhancement
Disposition: submit to http://savannah.nongnu.org/projects/quilt
Add "--pad" option to header command to allow forced padding by a specified
number of blank lines.
Index: quilt-0.42/quilt/header.in
===================================================================
--- quilt-0.42.orig/quilt/header.in
+++ quilt-0.42/quilt/header.in
@@ -21,7 +21,7 @@ fi
usage()
{
- printf $"Usage: quilt header [-a|-r|-e] [--backup] [--strip-diffstat]
[--strip-trailing-whitespace] [patch]\n"
+ printf $"Usage: quilt header [-a|-r|-e] [--backup] [--pad[=n]]
[--strip-diffstat] [--strip-trailing-whitespace] [patch]\n"
if [ x$1 = x-h ]
then
@@ -33,6 +33,12 @@ Print or change the header of the topmos
edit (-e) the header in \$EDITOR (%s). If none of these options is
given, print the patch header.
+--pad[=n]
+ Make sure a new header ends with \"n\" blank lines, adding or
+ removing blank lines as necessary. If \"--pad\" is specified alone,
+ \"n\" is assumed to be 1. If \"n\" is 0, padding is disabled and
+ no lines are added or removed.
+
--strip-diffstat
Strip diffstat output from the header.
@@ -48,6 +54,26 @@ Print or change the header of the topmos
fi
}
+maybe_pad_header()
+{
+ [ "$opt_pad" ] || opt_pad=0
+ if [ $opt_pad -gt 0 ]
+ then
+ @AWK@ -v pad=$opt_pad '
+ /^[ \t]*$/ { eat = eat $0 "\n"; next }
+ { print eat $0; eat = "" }
+ END {
+ while (pad > 0) {
+ print ""
+ pad -= 1
+ }
+ }
+ '
+ else
+ cat
+ fi
+}
+
maybe_strip_trailing_whitespace()
{
if [ -n "$opt_strip_trailing_whitespace" ]
@@ -77,7 +103,7 @@ maybe_strip_diffstat()
fi
}
-options=`getopt -o areh --long backup,strip-trailing-whitespace,strip-diffstat
-- "$@"`
+options=`getopt -o areh --long
backup,pad::,strip-trailing-whitespace,strip-diffstat -- "$@"`
if [ $? -ne 0 ]
then
@@ -101,6 +127,16 @@ do
--backup)
QUILT_BACKUP=1
shift ;;
+ --pad)
+ case "$2" in
+ "")
+ opt_pad=1 ;;
+ [0-9])
+ opt_pad="$2" ;;
+ *)
+ usage ;;
+ esac
+ shift 2 ;;
--strip-diffstat)
opt_strip_diffstat=1
shift ;;
@@ -197,7 +233,8 @@ else
fi
maybe_strip_diffstat < $tmp \
- | maybe_strip_trailing_whitespace > $tmp2
+ | maybe_strip_trailing_whitespace \
+ | maybe_pad_header > $tmp2
cat_file "$patch_file_or_null" | patch_body >> $tmp2 || exit 1