3 # Copyright (c) Josef "Jeff" Sipek, 2006-2011
6 USAGE
="[-f] [-s] [-e|-m message] <patchname>"
7 if [ -z "$GUILT_VERSION" ]; then
8 echo "Invoking `basename $0` directly is no longer supported." >&2
14 if [ $# -lt 1 ] ||
[ $# -gt 4 ]; then
18 while [ $# -gt 0 ] ; do
29 if [ ! -z "$msg" ]; then
37 if [ ! -z "$edit" ]; then
42 if [ ! -z "$patch" ]; then
51 if [ -z "$patch" ]; then
52 die
"You must specify a patch name"
55 if [ -f "$GUILT_DIR/$branch/$patch" ]; then
56 die
"patch '$patch' already exist"
59 iidx
=`wc -l < "$applied"`
61 # make sure that there are no unapplied changes
62 if [ -z "$force" ] && ! must_commit_first
; then
63 die
"Uncommited changes detected. Refresh first."
66 if ! valid_patchname
"$patch"; then
67 disp
"Patchname is invalid." >&2
68 die
"it cannot begin with '/', './' or '../', or contain /./, /../, or whitespace"
71 # create any directories as needed
72 mkdir_dir
=`dirname "$GUILT_DIR/$branch/$patch"`
73 [ "$mkdir_dir" != "$GUILT_DIR/$branch" ] && mkdir
-p "$mkdir_dir"
75 # create the file with the right contents
77 # did we get a message with -m ?
78 [ ! -z "$msg" ] && printf "$msg\n\n"
80 # add a sign-off-by (-s)
81 [ "$signoff" = "t" ] && printf "Signed-off-by: `git var GIT_COMMITTER_IDENT | sed -e 's/>.*/>/'`\n\n"
82 ) >> "$GUILT_DIR/$branch/$patch"
85 [ "$edit" = "t" ] && git_editor
"$GUILT_DIR/$branch/$patch"
87 if [ ! -z "$force" ]; then
90 git
diff --binary HEAD
>> "$GUILT_DIR/$branch/$patch"
94 # insert the patch name into the series file
95 series_insert_patch
"$patch"
98 echo "$patch" >> $applied