status: Major cleanup of status
[guilt.git] / guilt-patchbomb
blob2926388ee14ee5a45332fd6fa4d3a1bea8e5ed38
1 #!/bin/bash
3 # Copyright (c) Josef "Jeff" Sipek, 2007
6 DO_NOT_CHECK_BRANCH_EXISTENCE=1
8 USAGE="[-n] [<hash> | <since>..[<until>] | ..<until>]"
9 . guilt
11 case $# in
13 r="$1"
16 r="$2"
17 do_not_send=t
19 if [ "$1" != "-n" ]; then
20 usage
24 usage
26 esac
28 r=`munge_hash_range $r`
30 # FIXME: allow in-reply-to
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=""
65 if [ `git-rev-list "$r" | wc -l` -gt 1 ]; then
66 # more than 1 commit
67 opts="--no-chain-reply-to --compose"
69 opts="$opts $to_opts"
71 # last possible point to abort!
72 echo "About to execute 'git-send-email $opts $dir'"
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 if [ -z "$do_not_send" ]; then
81 git-send-email $opts $dir
82 else
83 echo "-n passed: not sending, command that would be executed:" >&2
84 echo git-send-email $opts $dir
87 # cleanup?
88 echo -n "Delete temporary directory? [Y/n] "
89 read n
91 [ "$n" = "n" -o "$n" = "N" ] && exit 0
92 rm -rf $dir