3 # Copyright (c) Josef "Jeff" Sipek, 2006, 2007
6 USAGE
="[-s] [-e|-m message] <patchname>"
9 if [ $# -lt 1 -o $# -gt 4 ]; then
13 while [ $# -gt 0 ] ; do
21 if [ ! -z "$msg" ]; then
29 if [ ! -z "$edit" ]; then
34 if [ ! -z "$patch" ]; then
43 if [ -z "$patch" ]; then
44 die
"You must specify a patch name"
47 if [ -f "$GUILT_DIR/$branch/$patch" ]; then
48 die
"patch '$patch' already exist"
51 iidx
=`wc -l < $applied`
53 # make sure that there are no unapplied changes
54 if ! must_commit_first
; then
55 die
"Uncommited changes detected. Refresh first."
58 if ! valid_patchname
"$patch"; then
59 echo "Patchname is invalid." >&2
60 die
"it cannot begin with '/', './' or '../', or contain /./ or /../"
63 # create any directories as needed
64 [ "`dirname $patch`" != "." ] && mkdir
-p `dirname $GUILT_DIR/$branch/$patch`
66 # create the file with the right contents
68 # did we get a message with -m ?
69 [ ! -z "$msg" ] && echo "$msg"
71 # add a sign-off-by (-s)
72 [ "$signoff" = "t" ] && echo -e "\nSigned-off-by: `git-var GIT_COMMITTER_IDENT | sed -e 's/>.*/>/'`"
73 ) >> $GUILT_DIR/$branch/$patch
76 [ "$edit" = "t" ] && $editor $GUILT_DIR/$branch/$patch
78 # insert the patch name into the series file
79 series_insert_patch
$patch