guilt: Document push_patch's new argument
[guilt.git] / guilt-new
blob4692503f096dc41fbb36c13b1543090c33a9fc94
1 #!/bin/bash
3 # Copyright (c) Josef "Jeff" Sipek, 2006, 2007
6 source "`dirname $0`/guilt"
8 USAGE="$USAGE [-s] [-e|-m message] <patchname>"
10 if [ $# -lt 1 -o $# -gt 4 ]; then
11 print_usage
12 exit 1
15 while [ $# -gt 0 ] ; do
16 case "$1" in
17 -s)
18 signoff=t
20 -e)
21 edit=t
23 if [ ! -z "$msg" ]; then
24 print_usage
25 exit 1
28 -m)
29 msg="$2"
30 shift
32 if [ ! -z "$edit" ]; then
33 print_usage
34 exit 1
38 if [ ! -z "$patch" ]; then
39 print_usage
40 exit 1
42 patch="$1"
44 esac
45 shift
46 done
48 if [ -z "$patch" ]; then
49 print_usage
50 echo "You must specify a patch name"
51 exit 1
54 if [ -f "$GUILT_DIR/$branch/$patch" ]; then
55 echo "patch '$patch' already exist" >&2
56 exit 1
59 iidx=`wc -l < $applied`
61 # make sure that there are no unapplied changes
62 if ! must_commit_first; then
63 echo "Uncommited changes detected. Refresh first."
64 exit 1
67 # create any directories as needed
68 [ "`dirname $patch`" != "." ] && mkdir -p `dirname $GUILT_DIR/$branch/$patch`
70 # create the file with the right contents
72 # did we get a message with -m ?
73 [ ! -z "$msg" ] && echo "$msg"
75 # add a sign-off-by (-s)
76 [ "$signoff" = "t" ] && echo -e "\nSigned-off-by: `git-var GIT_COMMITTER_IDENT | sed -e 's/>.*/>/'`"
77 ) >> $GUILT_DIR/$branch/$patch
79 # edit -e ?
80 [ "$edit" = "t" ] && $editor $GUILT_DIR/$branch/$patch
82 # insert the patch name into the series file
83 series_insert_patch $patch
85 # apply the patch
86 push_patch $patch