3 # Copyright (c) 2005 Junio C Hamano
6 . git-sh-setup-script || die
"Not a git archive."
9 echo >&2 "usage: $0"' [-n] [-o dir] [--mbox] [--check] [--sign] [-<diff options>...] upstream [ our-head ]
11 Prepare each commit with its patch since our-head forked from upstream,
12 one file per patch, for e-mail submission. Each output file is
13 numbered sequentially from 1, and uses the first line of the commit
14 message (massaged for pathname safety) as the filename.
16 When -o is specified, output files are created in that directory; otherwise in
17 the current working directory.
19 When -n is specified, instead of "[PATCH] Subject", the first line is formatted
20 as "[PATCH N/M] Subject", unless you have only one patch.
22 When --mbox is specified, the output is formatted to resemble
23 UNIX mailbox format, and can be concatenated together for processing
36 while case "$#" in 0) break;; esac
39 -a|
--a|
--au|
--aut|
--auth|
--autho|
--author)
41 -c|
--c|
--ch|
--che|
--chec|
--check)
43 -d|
--d|
--da|
--dat|
--date)
45 -m|
--m|
--mb|
--mbo|
--mbox)
46 date=t author
=t mbox
=t
;;
47 -n|
--n|
--nu|
--num|
--numb|
--numbe|
--number|
--numbere|
--numbered)
49 -s|
--s|
--si|
--sig|
--sign)
51 -o=*|
--o=*|
--ou=*|
--out=*|
--outp=*|
--outpu=*|
--output=*|
--output-=*|\
52 --output-d=*|
--output-di=*|
--output-dir=*|
--output-dire=*|\
53 --output-direc=*|
--output-direct=*|
--output-directo=*|\
54 --output-director=*|
--output-directory=*)
55 outdir
=`expr "$1" : '-[^=]*=\(.*\)'` ;;
56 -o|
--o|
--ou|
--out|
--outp|
--outpu|
--output|
--output-|
--output-d|\
57 --output-di|
--output-dir|
--output-dire|
--output-direc|
--output-direct|\
58 --output-directo|
--output-director|
--output-directory)
59 case "$#" in 1) usage
;; esac; shift
61 -*) diff_opts
="$diff_opts$LF$1" ;;
82 me
=`git-var GIT_AUTHOR_IDENT | sed -e 's/>.*/>/'`
86 *) outdir
="$outdir/" ;;
88 test -d "$outdir" || mkdir
-p "$outdir" ||
exit
91 trap 'rm -f $tmp-*' 0 1 2 3 15
100 s/^\[PATCH[^]]*\] *//
101 s/[^-a-z.A-Z_0-9]/-/g
114 s/author \(.*>\) \(.*\)$/au='\''\1'\'' ad='\''\2'\''/p
118 _x40
='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
119 _x40
="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
120 stripCommitHead
='/^'"$_x40"' (from '"$_x40"')$/d'
122 git-rev-list
--no-merges --merge-order \
123 $
(git-rev-parse
--revs-only "$revpair") >$series
124 total
=`wc -l <$series | tr -dc "[0-9]"`
128 git-cat-file commit
"$commit" | git-stripspace
>$commsg
129 title
=`sed -ne "$titleScript" <$commsg`
135 *) num
=' '`printf "%d/%d" $i $total` ;;
139 file=`printf '%04d-%stxt' $i "$title"`
146 s|^\[PATCH[^]]*\] *||'
150 echo 'From nobody Mon Sep 17 00:00:00 2001' ;# UNIX "From" line
151 mailScript
="$mailScript"'
152 s|^|Subject: [PATCH'"$num"'] |'
155 mailScript
="$mailScript"'
156 s|^|[PATCH'"$num"'] |'
160 eval "$(sed -ne "$whosepatchScript" $commsg)"
161 test "$author,$au" = ",$me" ||
{
162 mailScript
="$mailScript"'
166 test "$date,$au" = ",$me" ||
{
167 mailScript
="$mailScript"'
172 mailScript
="$mailScript"'
178 sed -ne "$mailScript" <$commsg
180 test "$signoff" = "t" && {
181 offsigner
=`git-var GIT_COMMITTER_IDENT | sed -e 's/>.*/>/'`
183 echo "Signed-off-by: $offsigner"
189 git-diff-tree
-p $diff_opts "$commit" | git-apply
--stat --summary
191 git-diff-tree
-p $diff_opts "$commit" |
sed -e "$stripCommitHead"
201 # This is slightly modified from Andrew Morton's Perfect Patch.
202 # Lines you introduce should not have trailing whitespace.
203 # Also check for an indentation that has SP before a TAB.
204 grep -n '^+\([ ]* .*\|.*[ ]\)$' "$outdir$file"
206 : do not
exit with non-zero because we saw no problem
in the last one.