[PATCH] guilt: fix "from: xxx" filtering in the patch description
[guilt.git] / guilt-patchbomb
blobb72a7063333b369192396947d13175f2c5b920da
1 #!/bin/sh
3 # Copyright (c) Josef "Jeff" Sipek, 2007-2011
6 DO_NOT_CHECK_BRANCH_EXISTENCE=1
8 USAGE="[-n] [-s] [--in-reply-to <msgid>] [--git] [--subject-prefix <prefix>] [<hash> | <since>..[<until>] | ..<until>]"
9 if [ -z "$GUILT_VERSION" ]; then
10 echo "Invoking `basename $0` directly is no longer supported." >&2
11 exit 1
14 _main() {
16 TMP_FILE=`get_tmp_file file`
18 while [ $# -gt 0 ]; do
19 case "$1" in
20 -n)
21 do_not_send=t
23 -s)
24 no_sign_off=t
26 --subject-prefix)
27 subject_prefix="$2"
28 shift
30 --in-reply-to)
31 reply_to="$2"
32 shift
34 --git)
35 gitdiff=t
38 break
40 esac
41 shift
42 done
44 r=`munge_hash_range "$1"`
45 if [ $? -ne 0 ]; then
46 usage
49 # display the list of commits to be sent as patches
50 git log --pretty=oneline "$r" | cut -c 1-8,41- | $pager
52 _disp "Are these what you want to send? [Y/n] "
53 read n
54 if [ "$n" = "n" ] || [ "$n" = "N" ]; then
55 die "Aborting..."
58 dir=`get_tmp_file patchbomb -d`
59 disp "Using '$dir' as temporary directory"
61 # more than one patch?
62 if [ `git rev-list "$r" | wc -l` -gt 1 ]; then
63 format_opts="-n" # include "n/m" in the subject
64 send_opts="--no-chain-reply-to --compose" # compose
67 [ ! -z "$gitdiff" ] && format_opts="$format_opts -C -M --find-copies-harder"
68 [ -z "$no_sign_off" ] && format_opts="$format_opts -s"
70 if [ -z "$subject_prefix" ]; then
71 git format-patch $format_opts -o $dir "$r"
72 else
73 git format-patch $format_opts --subject-prefix="$subject_prefix" -o $dir "$r"
76 # get the to/cc addresses
77 _disp "Enter all the To: email addresses (separated by space): "
78 read rawto
79 _disp "Enter all the Cc: email addresses (separated by space): "
80 read rawcc
82 # convert list of email addresses to command line options
83 to_opts=""
84 for rt in $rawto; do
85 to_opts="$to_opts --to $rt"
86 done
87 for rc in $rawcc; do
88 to_opts="$to_opts --cc $rc"
89 done
91 opts="$send_opts $to_opts"
93 # last possible point to abort!
94 _disp "Proceed with patchbomb (this is the last chance to abort)? [y/N] "
95 read n
96 if [ "$n" != "y" ] && [ "$n" != "Y" ]; then
97 die "Aborting..."
100 # ...and off they go.
101 cmd="git send-email"
102 if [ ! -z "$do_not_send" ]; then
103 disp "-n passed: not sending, command that would be executed:" >&2
104 cmd="echo git send-email"
107 if [ -z "$reply_to" ]; then
108 $cmd $opts $dir
109 else
110 $cmd --in-reply-to "$reply_to" $opts $dir
113 # cleanup?
114 _disp "Delete temporary directory? [Y/n] "
115 read n
117 [ "$n" = "n" ] || [ "$n" = "N" ] && exit 0
118 rm -rf $dir