[GUILT PATCH] guilt-header: Add -e option for editing
From: Eric Lesh <hidden>
Date: 2016-06-15 22:43:25
Signed-off-by: Eric Lesh <redacted> --- Documentation/guilt-header.txt | 6 ++++-- guilt | 9 +++++++++ guilt-header | 20 +++++++++++++++++--- 3 files changed, 30 insertions(+), 5 deletions(-)
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