On 7/15/05, Tom Rini <[EMAIL PROTECTED]> wrote:
> On Fri, Jul 15, 2005 at 09:06:29PM +0200, jerome lacoste wrote:
> 
> > Hi,
> >
> > I would like to have a template patch header for my patches. That
> > should be primarily auto-picked up by quilt and maybe user
> > configurable on the command line (although I won't have the need if
> > it's automated).
> >
> > Would that be interesting to anyone? If so, what about allowing the
> > user to define the template somewhere like ./patches/.header, or
> > ./.header?
> 
> In conjunction with the 'header' or 'description' patches that have
> floated by before, this sounds very useful, especially in reminding /
> enforcing your co-developers that patches need headers.

OK. Here's a first attempt at it. I haven't tested it apart from the
unit test I attempt to provide.
On a Friday night, my productivity reach its lower limit in this
development environment, so it's pretty frustrating. :)

So if someone more bash savvy wants to take over from there...

Cheers,

Jerome
Index: quilt/quilt/test/template-header.test
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ quilt/quilt/test/template-header.test	2005-07-16 00:57:44.904881825 +0200
@@ -0,0 +1,56 @@
+This is a minimal test script that checks that patch template work.
+TODO:
+- fix the 'ugly hack'
+- check that refresh but empty template doesn't create an empty patch
+
+(To run, type `./run template-header.test' in this directory.)
+
+	$ rm -rf patches
+	$ mkdir patches
+
+	$ cat > patches/.header
+        <
+        < HEADER
+	<
+
+	$ mkdir d
+	$ cd d
+	$ touch file1
+	$ quilt new patch1.diff
+	> Patch %{P}patch1.diff is now on top
+
+	$ quilt add file1
+	> File d/file1 added to patch %{P}patch1.diff
+
+	$ echo "This is file one." >> file1
+
+	$ quilt refresh
+	> Refreshed patch %{P}patch1.diff
+
+	$ quilt diff | sed -e "s/\\t.*//"
+	> Index: test/d/file1
+	> ===================================================================
+	> --- /dev/null
+	> +++ test/d/file1
+	> @@ -0,0 +1 @@
+	> +This is file one.
+
+        # ugly hack. Is there a way to print a patch with its header?
+	$ cat ../patches/patch1.diff | sed -e "s/\\t.*//"
+	>
+	> HEADER
+	>
+	> Index: test/d/file1
+	> ===================================================================
+	> --- /dev/null
+	> +++ test/d/file1
+	> @@ -0,0 +1 @@
+	> +This is file one.
+
+	$ quilt pop -qaR
+	> Removing patch %{P}patch1.diff
+	> No patches applied
+
+	$ cd ..
+	$ rm -rf d
+	$ rm -rf .pc
Index: quilt/quilt/quilt/refresh.in
===================================================================
--- quilt.orig/quilt/quilt/refresh.in	2005-07-16 00:17:53.972041936 +0200
+++ quilt/quilt/quilt/refresh.in	2005-07-16 00:40:54.825859215 +0200
@@ -288,6 +288,11 @@
 	cat $tmp_header > $tmp_result
 fi
 
+if [ ! -e $patch_file ]
+then
+	patch_template_header >> $tmp_result
+fi
+
 cat $tmp_patch >> $tmp_result
 
 if [ -e $patch_file ] && \
Index: quilt/quilt/scripts/patchfns.in
===================================================================
--- quilt.orig/quilt/scripts/patchfns.in	2005-07-15 23:15:37.933315577 +0200
+++ quilt/quilt/scripts/patchfns.in	2005-07-16 00:30:01.853187156 +0200
@@ -761,6 +761,12 @@
 	eval $C
 }
 
+patch_template_header()
+{
+	[ -e $PATCH_TEMPLATE_HEADER ] || return 1
+	cat $PATCH_TEMPLATE_HEADER
+}
+
 #
 # If the working directory does not contain a $QUILT_PATCHES directory,
 # quilt searches for its base directory up the directory tree. If no
@@ -810,6 +816,7 @@
 	SERIES=$QUILT_PATCHES/series
 fi
 
+PATCH_TEMPLATE_HEADER="$QUILT_PATCHES/.header"
 DB="$QUILT_PC/applied-patches"
 
 if [ -z "$skip_version_check" ] && ! version_check
_______________________________________________
Quilt-dev mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/quilt-dev

Reply via email to