Guilt v0.19
[guilt.git] / guilt-patchbomb
blob9c26c5d9f050539616a847c215dd3851eeaf4ffc
1 #!/bin/bash
3 # Copyright (c) Josef "Jeff" Sipek, 2007
6 DO_NOT_CHECK_BRANCH_EXISTENCE=1
7 source "`dirname $0`/guilt"
9 USAGE="$USAGE [-n] <since>[..[<until>]]"
10 # this means:
11 # <hash> - one commit
12 # <hash>.. - hash until head
13 # <hash>..<hash> - from hash to hash
15 case $# in
17 r="$1"
20 r="$2"
21 do_not_send=t
23 if [ "$1" != "-n" ]; then
24 print_usage
25 exit 1
29 print_usage
30 exit 1
32 esac
34 r="$1"
36 # FIXME: allow r="<hash>"
37 # FIXME: allow in-reply-to
39 # find a suitable pager (this might be a good candidate for putting it into
40 # the lib)
41 pager="$PAGER"
42 if [ -z "$pager" ]; then
43 pager="more"
46 # display the list of commits to be sent as patches
47 git-log --pretty=oneline "$r" | cut -c 1-8,41- | $pager
49 echo -n "Are these what you want to send? [Y/n] "
50 read n
51 if [ "$n" = "n" -o "$n" = "N" ]; then
52 echo "Aborting..."
53 exit 0
56 dir=/tmp/patches-$RANDOM/
57 if [ -e $dir ]; then
58 echo "Conspiracy uncovered: Temporary dir '$dir' already exists" >&2
59 exit 1
61 echo "Using '$dir' as temporary directory"
63 git-format-patch -o $dir -n -s "$r"
65 # get the to/cc addresses
66 echo -n "Enter all the To: email addresses (separated by space): "
67 read rawto
68 echo -n "Enter all the Cc: email addresses (separated by space): "
69 read rawcc
71 # convert list of email addresses to command line options
72 to_opts=""
73 for rt in $rawto; do
74 to_opts="$to_opts --to $rt"
75 done
76 for rc in $rawcc; do
77 to_opts="$to_opts --cc $rc"
78 done
80 opts=""
81 # FIXME: if more than one patch:
82 opts="--no-chain-reply-to --compose"
83 # fi
84 opts="$opts $to_opts"
86 # last possible point to abort!
87 echo "About to execute 'git-send-email $opts $dir'"
88 echo -n "Proceed with patchbomb (this is the last chance to abort)? [y/N] "
89 read n
90 if [ "$n" != "y" -a "$n" != "Y" ]; then
91 echo "Aborting..."
92 exit 0
95 # ...and off they go.
96 if [ -z "$do_not_send" ]; then
97 git-send-email $opts $dir
98 else
99 echo "-n passed: not sending, command that would be executed:" >&2
100 echo git-send-email $opts $dir
103 # cleanup?
104 echo -n "Delete temporary directory? [Y/n] "
105 read n
107 [ "$n" != "n" -a "$n" != "N" ] && exit 0
108 rm -rf $dir