Documentation: document series -e option
[guilt.git] / guilt-patchbomb
blob99d213222471090e4ea19206f9ea053fcaeb847b
1 #!/bin/sh
3 # Copyright (c) Josef "Jeff" Sipek, 2007
6 DO_NOT_CHECK_BRANCH_EXISTENCE=1
8 USAGE="[-n] [--in-reply-to <msgid>] [<hash> | <since>..[<until>] | ..<until>]"
9 . `dirname $0`/guilt
11 while [ $# -gt 0 ]; do
12 case "$1" in
13 -n)
14 do_not_send=t
16 --in-reply-to)
17 reply_to="$2"
18 shift
21 break
23 esac
24 shift
25 done
27 r=`munge_hash_range "$1"`
28 if [ $? -ne 0 ]; then
29 usage
32 # display the list of commits to be sent as patches
33 git-log --pretty=oneline "$r" | cut -c 1-8,41- | $pager
35 echo -n "Are these what you want to send? [Y/n] "
36 read n
37 if [ "$n" = "n" ] || [ "$n" = "N" ]; then
38 die "Aborting..."
41 dir=/tmp/patches-$RANDOM/
42 if [ -e $dir ]; then
43 die "Conspiracy uncovered: Temporary dir '$dir' already exists"
45 echo "Using '$dir' as temporary directory"
47 git-format-patch -o $dir -n -s "$r"
49 # get the to/cc addresses
50 echo -n "Enter all the To: email addresses (separated by space): "
51 read rawto
52 echo -n "Enter all the Cc: email addresses (separated by space): "
53 read rawcc
55 # convert list of email addresses to command line options
56 to_opts=""
57 for rt in $rawto; do
58 to_opts="$to_opts --to $rt"
59 done
60 for rc in $rawcc; do
61 to_opts="$to_opts --cc $rc"
62 done
64 opts=""
66 # more than 1 commit
67 if [ `git-rev-list "$r" | wc -l` -gt 1 ]; then
68 opts="$opts --no-chain-reply-to --compose"
70 opts="$opts $to_opts"
72 ls "$dir" | while read n; do
73 fulln="$dir/$n"
75 do_get_full_header "$fulln" | awk '
76 BEGIN{p=0}
77 /^$/{p=1}
78 /^[Cc][Cc]: / && (p==1){print substr($0, 5)}
79 ' | sed -n -e '
80 1 h
81 2,$ H
82 $ {
84 s/\n/, /g
86 }' > /tmp/guilt.$$.tmp
87 if [ -s /tmp/guilt.$$.tmp ]; then
88 head -1 "$fulln" > "$fulln~"
89 echo -n "Cc: " >> "$fulln~"
90 cat /tmp/guilt.$$.tmp >> "$fulln~"
91 tail -n +2 "$fulln" >> "$fulln~"
92 mv "$fulln~" "$fulln"
93 echo "${n:0:4}: Including Cc from patch description"
94 rm -f /tmp/guilt.$$.tmp
95 else
96 echo "${n:0:4}: No Cc found in patch description"
98 done
100 # last possible point to abort!
101 echo -n "Proceed with patchbomb (this is the last chance to abort)? [y/N] "
102 read n
103 if [ "$n" != "y" ] && [ "$n" != "Y" ]; then
104 die "Aborting..."
107 # ...and off they go.
108 cmd="git-send-email"
109 if [ ! -z "$do_not_send" ]; then
110 echo "-n passed: not sending, command that would be executed:" >&2
111 cmd="echo git-send-email"
114 if [ -z "$reply_to" ]; then
115 $cmd $opts $dir
116 else
117 $cmd --in-reply-to "$reply_to" $opts $dir
120 # cleanup?
121 echo -n "Delete temporary directory? [Y/n] "
122 read n
124 [ "$n" = "n" ] || [ "$n" = "N" ] && exit 0
125 rm -rf $dir