git-format-patch: --stdout option.
This new flag generates the mbox formatted output to the standard output, instead of saving them into a file per patch and implies --mbox. It also fixes a corner case where the commit does not have *any* message. Signed-off-by: Junio C Hamano <junkio@cox.net>
Junio C Hamano committed
Oct 6, 2005 at 14:25 UTC
655c7470e2ea7f25f22703b6654d7570e1567a39
1 file changed
+42
-30
git-format-patch.sh
+42
-30
@@ -6,7 +6,7 @@
6
. git-sh-setup || die "Not a git archive."
7
8
usage () {
9
- echo >&2 "usage: $0"' [-n] [-o dir] [--keep-subject] [--mbox] [--check] [--signoff] [-<diff options>...] upstream [ our-head ]
9
+ echo >&2 "usage: $0"' [-n] [-o dir | --stdout] [--keep-subject] [--mbox] [--check] [--signoff] [-<diff options>...] upstream [ our-head ]
10
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
@@ -49,6 +49,8 @@ do
49
numbered=t ;;
50
-s|--s|--si|--sig|--sign|--signo|--signof|--signoff)
51
signoff=t ;;
52
+ --st|--std|--stdo|--stdou|--stdout)
53
+ stdout=t mbox=t date=t author=t ;;
54
-o=*|--o=*|--ou=*|--out=*|--outp=*|--outpu=*|--output=*|--output-=*|\
55
--output-d=*|--output-di=*|--output-dir=*|--output-dire=*|\
56
--output-direc=*|--output-direct=*|--output-directo=*|\
@@ -141,25 +143,7 @@ do
143
esac
144
done >$series
145
144
-total=`wc -l <$series | tr -dc "[0-9]"`
145
-i=1
146
-while read commit
147
-do
148
- git-cat-file commit "$commit" | git-stripspace >$commsg
149
- title=`sed -ne "$titleScript" <$commsg`
150
- case "$numbered" in
151
- '') num= ;;
152
- *)
153
- case $total in
154
- 1) num= ;;
155
- *) num=' '`printf "%d/%d" $i $total` ;;
156
- esac
157
- esac
158
-
159
- file=`printf '%04d-%stxt' $i "$title"`
160
- i=`expr "$i" + 1`
161
- echo "* $file"
162
- {
146
+process_one () {
147
mailScript='
148
/./d
149
/^$/n'
@@ -178,6 +162,7 @@ do
162
echo 'From nobody Mon Sep 17 00:00:00 2001' ;# UNIX "From" line
163
;;
164
esac
165
+
166
eval "$(sed -ne "$whosepatchScript" $commsg)"
167
test "$author,$au" = ",$me" || {
168
mailScript="$mailScript"'
@@ -196,7 +181,9 @@ Date: '"$ad"
181
n
182
b body'
183
199
- sed -ne "$mailScript" <$commsg
184
+ (cat $commsg ; echo; echo) |
185
+ sed -ne "$mailScript" |
186
+ git-stripspace
187
188
test "$signoff" = "t" && {
189
offsigner=`git-var GIT_COMMITTER_IDENT | sed -e 's/>.*/>/'`
@@ -222,14 +209,39 @@ Date: '"$ad"
209
echo
210
;;
211
esac
225
- } >"$outdir$file"
226
- case "$check" in
227
- t)
228
- # This is slightly modified from Andrew Morton's Perfect Patch.
229
- # Lines you introduce should not have trailing whitespace.
230
- # Also check for an indentation that has SP before a TAB.
231
- grep -n '^+\([ ]* .*\|.*[ ]\)$' "$outdir$file"
232
-
233
- : do not exit with non-zero because we saw no problem in the last one.
212
+}
213
+
214
+total=`wc -l <$series | tr -dc "[0-9]"`
215
+i=1
216
+while read commit
217
+do
218
+ git-cat-file commit "$commit" | git-stripspace >$commsg
219
+ title=`sed -ne "$titleScript" <$commsg`
220
+ case "$numbered" in
221
+ '') num= ;;
222
+ *)
223
+ case $total in
224
+ 1) num= ;;
225
+ *) num=' '`printf "%d/%d" $i $total` ;;
226
+ esac
227
esac
228
+
229
+ file=`printf '%04d-%stxt' $i "$title"`
230
+ if test '' = "$stdout"
231
+ then
232
+ echo "* $file"
233
+ process_one >"$outdir$file"
234
+ if test t = "$check"
235
+ then
236
+ # This is slightly modified from Andrew Morton's Perfect Patch.
237
+ # Lines you introduce should not have trailing whitespace.
238
+ # Also check for an indentation that has SP before a TAB.
239
+ grep -n '^+\([ ]* .*\|.*[ ]\)$' "$outdir$file"
240
+ :
241
+ fi
242
+ else
243
+ echo >&2 "* $file"
244
+ process_one
245
+ fi
246
+ i=`expr "$i" + 1`
247
done <$series