summaryrefslogtreecommitdiff
path: root/git-am.sh
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2009-05-27 11:25:18 +0200
committerJunio C Hamano <gitster@pobox.com>2009-05-28 23:07:43 -0700
commitc574e683b587ee3c302317e4fa9c83cd4605cd82 (patch)
treea1a229ac46616e8778fa84ccd0ed5ae34928d1c2 /git-am.sh
parent15ced753ac091314941abb28302f7109a9e86b81 (diff)
downloadgit-c574e683b587ee3c302317e4fa9c83cd4605cd82.tar.gz
git-am foreign patch support: StGIT support
Support StGIT patches by implementing a simple perl-based converter mimicking StGIT's own parse_patch. Also support StGIT patch series by 'exploding' the index into a list of files and re-running the mail splitting with patch_format set to stgit. Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-am.sh')
-rwxr-xr-xgit-am.sh57
1 files changed, 57 insertions, 0 deletions
diff --git a/git-am.sh b/git-am.sh
index 552b888703..0ff1f577a3 100755
--- a/git-am.sh
+++ b/git-am.sh
@@ -191,6 +191,63 @@ 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`
+ # Perl 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
+ perl -ne 'BEGIN { $subject = 0 }
+ if ($subject > 1) { print ; }
+ elsif (/^\s+$/) { next ; }
+ elsif (/^Author:/) { print s/Author/From/ ; }
+ elsif (/^(From|Date)/) { print ; }
+ elsif ($subject) {
+ $subject = 2 ;
+ print "\n" ;
+ print ;
+ } else {
+ print "Subject: ", $_ ;
+ $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