From: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>,
Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
Subject: [PATCHv2 3/4] git-am foreign patch support: StGIT support
Date: Tue, 26 May 2009 02:38:09 +0200 [thread overview]
Message-ID: <1243298290-5909-4-git-send-email-giuseppe.bilotta@gmail.com> (raw)
In-Reply-To: <1243298290-5909-3-git-send-email-giuseppe.bilotta@gmail.com>
Support StGIT patches by implementing a simple awk-based converter
mimicking StGIT's own parse_patch. Also support StGIT patch series by
'exploding' the index into a lif of files and re-running the mail
splitting with patch_format set to stgit.
---
git-am.sh | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 60 insertions(+), 0 deletions(-)
diff --git a/git-am.sh b/git-am.sh
index 4cf66aa..1a00830 100755
--- a/git-am.sh
+++ b/git-am.sh
@@ -203,6 +203,66 @@ split_patches () {
exit 1
}
;;
+ stgit-series)
+ if test $# -ne 1
+ then
+ echo "Only one StGIT patch series can be applied at once"
+ exit 1
+ fi
+ series_dir=`dirname "$1"`
+ series_file="$1"
+ shift
+ {
+ set x
+ while read filename
+ do
+ set "$@" "$series_dir/$filename"
+ done
+ # remove the safety x
+ shift
+ # remove the arg coming from the first-line comment
+ shift
+ } < "$series_file"
+ # set the patch format appropriately
+ patch_format=stgit
+ # now handle the actual StGIT patches
+ split_patches "$@"
+ ;;
+ stgit)
+ this=0
+ for stgit in "$@"
+ do
+ this=`expr "$this" + 1`
+ msgnum=`printf "%0${prec}d" $this`
+ touch "$dotest/$msgnum"
+ # Awk version of StGIT parse_patch. The first nonemptyline
+ # not starting with Author, From or Date is the
+ # subject, and the body starts with the next nonempty
+ # line not starting with Author, From or Date
+ awk 'BEGIN { subject=0 }
+ {
+ if (subject > 1)
+ print ;
+ else if (/^$/) next ;
+ else if (/^Author:/) print sub("Author", "From"), $ORS ;
+ else if (/^(From|Date)/) print ;
+ else if (subject) {
+ subject = 2 ;
+ print "" ;
+ print ;
+ } else {
+ print "Subject:", $0 ;
+ subject = 1;
+ }
+ }' "$stgit" > "$dotest/$msgnum" || {
+ echo "Failed to import $patch_format patch $stgit"
+ exit 1
+ }
+ done
+ echo "$this" > "$dotest/last"
+ this=
+ msgnum=
+ ;;
*)
echo "Patch format $patch_format is not supported."
exit 1
--
1.6.3.1.248.gb44be
next prev parent reply other threads:[~2009-05-26 0:39 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-26 0:38 [PATCHv2 0/4] git-am support for foreign patches Giuseppe Bilotta
2009-05-26 0:38 ` [PATCHv2 1/4] git-am foreign patch support: introduce patch_format Giuseppe Bilotta
2009-05-26 0:38 ` [PATCHv2 2/4] git-am foreign patch support: autodetect some patch formats Giuseppe Bilotta
2009-05-26 0:38 ` Giuseppe Bilotta [this message]
2009-05-26 0:38 ` [PATCHv2 4/4] git-am: refactor 'cleaning up and aborting' Giuseppe Bilotta
2009-05-27 7:19 ` Junio C Hamano
2009-05-27 7:19 ` [PATCHv2 3/4] git-am foreign patch support: StGIT support Junio C Hamano
2009-05-27 8:29 ` Giuseppe Bilotta
2009-05-27 20:50 ` Junio C Hamano
2009-05-27 7:19 ` [PATCHv2 2/4] git-am foreign patch support: autodetect some patch formats Junio C Hamano
2009-05-27 8:19 ` Giuseppe Bilotta
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1243298290-5909-4-git-send-email-giuseppe.bilotta@gmail.com \
--to=giuseppe.bilotta@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).