{"thread":{"id":"782","subject":"[PATCH] Add git-format-patch-script.","startedAt":"2005-05-31T21:50:26Z","lastAt":"2005-05-31T21:50:26Z","messageCount":1,"participants":["Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"4323","messageId":"7vpsv7vzdp.fsf@assigned-by-dhcp.cox.net","threadId":"782","inReplyTo":null,"subject":"[PATCH] Add git-format-patch-script.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-05-31T21:50:26Z","receivedAt":"2005-05-31T21:50:26Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"The script takes two HEADs and optionally one directory name,\nand prepares a patch file for each commit between the named\nHEADS in a separate file in the named directory.  The directory\ndefaults to the $cwd.\n\nThis is in the same spirit as the recent additions of helper\nscripts to make core GIT plumbing more comfortable to use.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\n\n Makefile                |    3 +-\n git-format-patch-script |   66 +++++++++++++++++++++++++++++++++++++++++++++++\n 2 files changed, 68 insertions(+), 1 deletions(-)\n\ndiff --git a/Makefile b/Makefile\n--- a/Makefile\n+++ b/Makefile\n@@ -22,7 +22,8 @@ INSTALL=install\n \n SCRIPTS=git-apply-patch-script git-merge-one-file-script git-prune-script \\\n \tgit-pull-script git-tag-script git-resolve-script git-whatchanged \\\n-\tgit-deltafy-script git-fetch-script git-status-script git-commit-script\n+\tgit-deltafy-script git-fetch-script git-status-script \\\n+\tgit-commit-script git-format-patch-script\n \n PROG=   git-update-cache git-diff-files git-init-db git-write-tree \\\n \tgit-read-tree git-commit-tree git-cat-file git-fsck-cache \\\ndiff --git a/git-format-patch-script b/git-format-patch-script\nnew file mode 100755\n--- /dev/null\n+++ b/git-format-patch-script\n@@ -0,0 +1,66 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2005 Junio C Hamano\n+#\n+junio=\"$1\"\n+linus=\"$2\"\n+outdir=\"${3:-./}\"\n+\n+tmp=.tmp-series$$\n+trap 'rm -f $tmp-*' 0 1 2 3 15\n+\n+series=$tmp-series\n+\n+titleScript='\n+\t1,/^$/d\n+\t: loop\n+\t/^$/b loop\n+\ts/[^-a-z.A-Z_0-9]/-/g\n+\ts/^--*//g\n+\ts/--*$//g\n+\ts/---*/-/g\n+\ts/$/.txt/\n+        s/\\.\\.\\.*/\\./g\n+\tq\n+'\n+\n+_x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'\n+_x40=\"$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40\"\n+stripCommitHead='/^'\"$_x40\"' (from '\"$_x40\"')$/d'\n+\n+O=\n+if test -f .git/patch-order\n+then\n+    O=-O.git/patch-order\n+fi\n+git-rev-list \"$junio\" \"$linus\" >$series\n+total=`wc -l <$series`\n+i=$total\n+while read commit\n+do\n+    title=`git-cat-file commit \"$commit\" | sed -e \"$titleScript\"`\n+    num=`printf \"%d/%d\" $i $total`\n+    file=`printf '%04d-%s' $i \"$title\"`\n+    i=`expr \"$i\" - 1`\n+    echo \"$file\"\n+    {\n+\tmailScript='\n+\t1,/^$/d\n+\t: loop\n+\t/^$/b loop\n+\ts|^|[PATCH '\"$num\"'] |\n+\t: body\n+\tp\n+\tn\n+\tb body'\n+\n+\tgit-cat-file commit \"$commit\" | sed -ne \"$mailScript\"\n+\techo '---'\n+\techo\n+\tgit-diff-tree -p $O \"$commit\" | git-apply --stat\n+\techo\n+\tgit-diff-tree -p $O \"$commit\" | sed -e \"$stripCommitHead\"\n+\techo '------------'\n+    } >\"$outdir$file\"\n+done <$series\n+\n------------\n\n"}]}