threads / patch / 9310

patchguilt-header: Add -e option for editing

Subject: [GUILT PATCH] guilt-header: Add -e option for editing

## tl;dr

2 messages between Jul 30, 2007 and Jul 30, 2007. Diffs are folded; open one to read it.

replies: 1people: 2as markdown or json

Eric Lesh· Jul 30, 2007, 14:34 UTC · lore
Signed-off-by: Eric Lesh <eclesh@ucla.edu>
---
 Documentation/guilt-header.txt |    6 ++++--
 guilt                          |    9 +++++++++
 guilt-header                   |   20 +++++++++++++++++---
 3 files changed, 30 insertions(+), 5 deletions(-)
Show changes to 3 files +30 −5

Documentation/guilt-header.txt, guilt, guilt-header

diff --git a/Documentation/guilt-header.txt b/Documentation/guilt-header.txt
index ed9ab34..d432959 100644
--- a/Documentation/guilt-header.txt
+++ b/Documentation/guilt-header.txt
@@ -11,10 +11,12 @@ include::usage-guilt-header.txt[]
 
 DESCRIPTION
 -----------
-Prints either the topmost patches' header or the header of a specified patch.
+Prints either the topmost patch's header or the header of a specified patch.
 
+-e::
+        Open the header in an editor, instead of printing it.
 <patchname>::
-	Name of the patch. 
+	Name of the patch.
 
 Author
 ------
diff --git a/guilt b/guilt
index f67bfb5..7f2b93c 100755
--- a/guilt
+++ b/guilt
@@ -209,6 +209,15 @@ do_make_header()
 	'
 }
 
+# usage: do_get_patch patchfile
+do_get_patch()
+{
+	cat "$1" | awk '
+BEGIN{}
+/^(diff|---)/,/END{}/
+'
+}
+
 # usage: do_get_header patchfile
 do_get_header()
 {
diff --git a/guilt-header b/guilt-header
index d07e2be..496cb5b 100755
--- a/guilt-header
+++ b/guilt-header
@@ -3,13 +3,18 @@
 # Copyright (c) Josef "Jeff" Sipek, 2006, 2007
 #
 
-USAGE="[<patchname>]"
+USAGE="[-e] [<patchname>]"
 . `dirname $0`/guilt
 
-if [ $# -gt 1 ]; then
+if [ $# -gt 2 ]; then
 	usage
 fi
 
+if [ "$1" = "-e" ]; then
+	edit=t
+	shift
+fi
+
 patch="$1"
 
 if [ -z "$patch" ]; then
@@ -34,6 +39,15 @@ for p in `get_series`; do
 	[ $idx -lt $eidx ] && continue
 	[ $idx -gt $eidx ] && break
 
-	do_get_header $GUILT_DIR/$branch/$p
+	if [ -z "$edit" ]; then
+		do_get_header $GUILT_DIR/$branch/$p
+	else
+		do_get_full_header $GUILT_DIR/$branch/$p > /tmp/guilt.msg.$$
+		do_get_patch  $GUILT_DIR/$branch/$p > /tmp/guilt.diff.$$
+		$editor "/tmp/guilt.msg.$$"
+		mv $GUILT_DIR/$branch/$p $GUILT_DIR/$branch/$p~
+		cat /tmp/guilt.msg.$$ > $GUILT_DIR/$branch/$p
+		cat /tmp/guilt.diff.$$ >> $GUILT_DIR/$branch/$p
+	fi
 done
 
-- 
1.5.2
Josef Sipek· Jul 30, 2007, 19:09 UTC · re: Eric Lesh · lore

Re: [GUILT PATCH] guilt-header: Add -e option for editing

On Mon, Jul 30, 2007 at 07:34:28AM -0700, Eric Lesh wrote:
Show 6 quoted lines
> Signed-off-by: Eric Lesh <eclesh@ucla.edu>
> ---
>  Documentation/guilt-header.txt |    6 ++++--
>  guilt                          |    9 +++++++++
>  guilt-header                   |   20 +++++++++++++++++---
>  3 files changed, 30 insertions(+), 5 deletions(-)

Applied. Right after applying your patch, I decided to clean things up a bit. This includes removal of the scan of the series => not needed as we already know the patch name anyway.

Thanks,
Josef 'Jeff' Sipek.
-- 
I already backed up the [server] once, I can do it again.

← back to recent threads