git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/2] git-am foreign patch support: StGIT

From
Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
Date
May 25, 2009, 19:14 UTC
Message-ID
<1243278846-14120-3-git-send-email-giuseppe.bilotta@gmail.com>
In-Reply-To
<1243278846-14120-2-git-send-email-giuseppe.bilotta@gmail.com>
Convert StGIT patches to mbox format so that they can be imported.
Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
---
 git-am.sh |   32 ++++++++++++++++++++++++++++++++
 1 files changed, 32 insertions(+), 0 deletions(-)
diff --git a/git-am.sh b/git-am.sh
index 3508b7e..5199354 100755
--- a/git-am.sh
+++ b/git-am.sh
@@ -375,6 +375,38 @@ else
 			exit 1
 		}
 		;;
+	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
+			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 currently handled, sorry"
 		exit 1
-- 
1.6.3.1.245.g4529.dirty
Previous: Giuseppe BilottaNext: Junio C Hamano
Message 3 of 7 in “git-am foreign patch support”
  1. 0/2 git-am foreign patch supportGiuseppe Bilotta, May 25, 2009
  2. 1/2 git-am foreign patch support: format autodetectionGiuseppe Bilotta, May 25, 2009
  3. 2/2 git-am foreign patch support: StGITGiuseppe Bilotta, May 25, 2009
  4. Junio C HamanoMay 25, 2009
  5. Giuseppe BilottaMay 25, 2009
  6. Sverre RabbelierMay 25, 2009
  7. Giuseppe BilottaMay 25, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.