[prev in list] [next in list] [prev in thread] [next in thread]
List: git
Subject: [PATCH] Add git-format-patch-script.
From: Junio C Hamano <junkio () cox ! net>
Date: 2005-05-31 21:50:26
Message-ID: 7vpsv7vzdp.fsf () assigned-by-dhcp ! cox ! net
[Download RAW message or body]
The script takes two HEADs and optionally one directory name,
and prepares a patch file for each commit between the named
HEADS in a separate file in the named directory. The directory
defaults to the $cwd.
This is in the same spirit as the recent additions of helper
scripts to make core GIT plumbing more comfortable to use.
Signed-off-by: Junio C Hamano <junkio@cox.net>
---
Makefile | 3 +-
git-format-patch-script | 66 +++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 68 insertions(+), 1 deletions(-)
diff --git a/Makefile b/Makefile
--- a/Makefile
+++ b/Makefile
@@ -22,7 +22,8 @@ INSTALL=install
SCRIPTS=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-deltafy-script git-fetch-script git-status-script \
+ git-commit-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,66 @@
+#!/bin/sh
+#
+# Copyright (c) 2005 Junio C Hamano
+#
+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 $O "$commit" | git-apply --stat
+ echo
+ git-diff-tree -p $O "$commit" | sed -e "$stripCommitHead"
+ echo '------------'
+ } >"$outdir$file"
+done <$series
+
------------
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic