[PATCH] Regression test suite needs bash, that's OK.
[guilt.git] / guilt-patchbomb
blobc1c3ea0a207d713012b9b5ba8cd7784e8a47785e
1 #!/bin/bash
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 . 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" -o "$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 # last possible point to abort!
73 echo -n "Proceed with patchbomb (this is the last chance to abort)? [y/N] "
74 read n
75 if [ "$n" != "y" -a "$n" != "Y" ]; then
76 die "Aborting..."
79 # ...and off they go.
80 cmd="git-send-email"
81 if [ ! -z "$do_not_send" ]; then
82 echo "-n passed: not sending, command that would be executed:" >&2
83 cmd="echo git-send-email"
86 if [ -z "$reply_to" ]; then
87 $cmd $opts $dir
88 else
89 $cmd --in-reply-to "$reply_to" $opts $dir
92 # cleanup?
93 echo -n "Delete temporary directory? [Y/n] "
94 read n
96 [ "$n" = "n" -o "$n" = "N" ] && exit 0
97 rm -rf $dir