From: Junio C Hamano <junkio@cox.net>
To: Linus Torvalds <torvalds@osdl.org>
Cc: git@vger.kernel.org
Subject: [PATCH] Add script for patch submission via e-mail.
Date: Fri, 10 Jun 2005 18:32:30 -0700 [thread overview]
Message-ID: <7vll5h7k5t.fsf@assigned-by-dhcp.cox.net> (raw)
This git-format-patch-script is what I use to prepare patches
for e-mail submission.
Typical usage is:
$ git-format-patch-script -B -C --find-copies-harder HEAD linus
to prepare each commit with its patch since "HEAD" forked from
"linus", one file per patch for e-mail submission. Each output
file is numbered sequentially from 1, and uses the first line of
the commit message (massaged for pathname safety) as the
filename.
$ git-format-patch-script -B -C --find-copies-harder HEAD linus .patch/
creates output files in .patch/ directory.
Signed-off-by: Junio C Hamano <junkio@cox.net>
---
*** Linus I am submitting this one because some patches on
*** read-tree I am going to send you will need this for
*** formatting into a form that is easier to review. And this
*** in turn can use diff-tree --find-copies-harder, which I
*** indeed used to generate the patches that follow.
Makefile | 3 +-
git-format-patch-script | 93 +++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 95 insertions(+), 1 deletions(-)
diff --git a/Makefile b/Makefile
--- a/Makefile
+++ b/Makefile
@@ -23,7 +23,8 @@ INSTALL=install
SCRIPTS=git git-apply-patch-script git-merge-one-file-script git-prune-script \
git-pull-script git-tag-script git-resolve-script git-whatchanged \
git-deltafy-script git-fetch-script git-status-script git-commit-script \
- git-log-script git-shortlog git-cvsimport-script
+ git-log-script git-shortlog git-cvsimport-script \
+ git-format-patch-script
PROG= git-update-cache git-diff-files git-init-db git-write-tree \
git-read-tree git-commit-tree git-cat-file git-fsck-cache \
diff --git a/git-format-patch-script b/git-format-patch-script
new file mode 100755
--- /dev/null
+++ b/git-format-patch-script
@@ -0,0 +1,93 @@
+#!/bin/sh
+#
+# Copyright (c) 2005 Junio C Hamano
+#
+# Typical usage is:
+#
+# $ git-format-patch-script -B -C --find-copies-harder HEAD linus
+#
+# to prepare each commit with its patch since "HEAD" forked from
+# "linus", one file per patch for e-mail submission. Each output file is
+# numbered sequentially from 1, and uses the first line of the commit
+# message (massaged for pathname safety) as the filename.
+#
+# $ git-format-patch-script -B -C --find-copies-harder HEAD linus .patch/
+#
+# creates output files in .patch/ directory.
+
+diff_opts=
+IFS='
+'
+LF='
+'
+while case "$#" in 0) break;; esac
+do
+ case "$1" in
+ -*) diff_opts="$diff_opts$LF$1" ;;
+ *) break ;;
+ esac
+ shift
+done
+
+junio="$1"
+linus="$2"
+outdir="${3:-./}"
+
+tmp=.tmp-series$$
+trap 'rm -f $tmp-*' 0 1 2 3 15
+
+series=$tmp-series
+
+titleScript='
+ 1,/^$/d
+ : loop
+ /^$/b loop
+ s/[^-a-z.A-Z_0-9]/-/g
+ s/^--*//g
+ s/--*$//g
+ s/---*/-/g
+ s/$/.txt/
+ s/\.\.\.*/\./g
+ q
+'
+
+_x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
+_x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
+stripCommitHead='/^'"$_x40"' (from '"$_x40"')$/d'
+
+O=
+if test -f .git/patch-order
+then
+ O=-O.git/patch-order
+fi
+git-rev-list "$junio" "^$linus" >$series
+total=`wc -l <$series`
+i=$total
+while read commit
+do
+ title=`git-cat-file commit "$commit" | sed -e "$titleScript"`
+ num=`printf "%d/%d" $i $total`
+ file=`printf '%04d-%s' $i "$title"`
+ i=`expr "$i" - 1`
+ echo "$file"
+ {
+ mailScript='
+ 1,/^$/d
+ : loop
+ /^$/b loop
+ s|^|[PATCH '"$num"'] |
+ : body
+ p
+ n
+ b body'
+
+ git-cat-file commit "$commit" | sed -ne "$mailScript"
+ echo '---'
+ echo
+ git-diff-tree -p $diff_opts $O "$commit" | git-apply --stat
+ echo
+ git-diff-tree -p $diff_opts $O "$commit" | sed -e "$stripCommitHead"
+ echo '------------'
+ } >"$outdir$file"
+done <$series
+
------------
next reply other threads:[~2005-06-11 1:28 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-06-11 1:32 Junio C Hamano [this message]
2005-07-05 9:34 ` [PATCH] Add script for patch submission via e-mail Petr Baudis
2005-07-05 9:39 ` Jon Seymour
2005-07-05 15:20 ` Junio C Hamano
2005-07-05 16:18 ` Jon Seymour
2005-07-05 20:19 ` Junio C Hamano
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7vll5h7k5t.fsf@assigned-by-dhcp.cox.net \
--to=junkio@cox.net \
--cc=git@vger.kernel.org \
--cc=torvalds@osdl.org \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).