3 # Copyright (c) 2005 Junio C Hamano
7 echo >&2 "usage: $0"' [-n] [-o dir] [-<diff options>...] upstream [ our-head ]
9 Prepare each commit with its patch since our-head forked from upstream,
10 one file per patch, for e-mail submission. Each output file is
11 numbered sequentially from 1, and uses the first line of the commit
12 message (massaged for pathname safety) as the filename.
14 When -o is specified, output files are created in that directory; otherwise in
15 the current working directory.
17 When -n is specified, instead of "[PATCH] Subject", the first line is formatted
18 as "[PATCH N/M] Subject", unless you have only one patch.
30 while case "$#" in 0) break;; esac
33 -n|
--n|
--nu|
--num|
--numb|
--numbe|
--number|
--numbere|
--numbered)
35 -o=*|
--o=*|
--ou=*|
--out=*|
--outp=*|
--outpu=*|
--output=*|
--output-=*|\
36 --output-d=*|
--output-di=*|
--output-dir=*|
--output-dire=*|\
37 --output-direc=*|
--output-direct=*|
--output-directo=*|\
38 --output-director=*|
--output-directory=*)
39 outdir
=`expr "$1" : '-[^=]*=\(.*\)'` ;;
40 -o|
--o|
--ou|
--out|
--outp|
--outpu|
--output|
--output-|
--output-d|\
41 --output-di|
--output-dir|
--output-dire|
--output-direc|
--output-direct|\
42 --output-directo|
--output-director|
--output-directory)
43 case "$#" in 1) usage
;; esac; shift
45 -*) diff_opts
="$diff_opts$LF$1" ;;
52 2) linus
="$1" junio
="$2" ;;
53 1) linus
="$1" junio
=HEAD
;;
56 junio
=`git-rev-parse --verify "$junio"`
57 linus
=`git-rev-parse --verify "$linus"`
61 *) outdir
="$outdir/" ;;
63 test -d "$outdir" || mkdir
-p "$outdir" ||
exit
66 trap 'rm -f $tmp-*' 0 1 2 3 15
85 _x40
='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
86 _x40
="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
87 stripCommitHead
='/^'"$_x40"' (from '"$_x40"')$/d'
89 git-rev-list
--merge-order "$junio" "^$linus" >$series
90 total
=`wc -l <$series`
94 title
=`git-cat-file commit "$commit" |
96 sed -ne "$titleScript"`
102 *) num
=' '`printf "%d/%d" $i $total` ;;
105 file=`printf '%04d-%stxt' $i "$title"`
112 s|^|[PATCH'"$num"'] |
118 git-cat-file commit
"$commit" |
120 sed -ne "$mailScript"
123 git-diff-tree
-p $diff_opts "$commit" | git-apply
--stat --summary
125 git-diff-tree
-p $diff_opts "$commit" |
sed -e "$stripCommitHead"