3 # Copyright (c) Josef "Jeff" Sipek, 2006, 2007
6 USAGE
="[-f] [-s] [-e|-m message] <patchname>"
9 if [ $# -lt 1 ] ||
[ $# -gt 4 ]; then
13 while [ $# -gt 0 ] ; do
24 if [ ! -z "$msg" ]; then
32 if [ ! -z "$edit" ]; then
37 if [ ! -z "$patch" ]; then
46 if [ -z "$patch" ]; then
47 die
"You must specify a patch name"
50 if [ -f "$GUILT_DIR/$branch/$patch" ]; then
51 die
"patch '$patch' already exist"
54 iidx
=`wc -l < "$applied"`
56 # make sure that there are no unapplied changes
57 if [ -z "$force" ] && ! must_commit_first
; then
58 die
"Uncommited changes detected. Refresh first."
61 if ! valid_patchname
"$patch"; then
62 disp
"Patchname is invalid." >&2
63 die
"it cannot begin with '/', './' or '../', or contain /./, /../, or whitespace"
66 # create any directories as needed
67 mkdir_dir
=`dirname "$GUILT_DIR/$branch/$patch"`
68 [ "$mkdir_dir" != "$GUILT_DIR/$branch" ] && mkdir
-p "$mkdir_dir"
70 # create the file with the right contents
72 # did we get a message with -m ?
73 [ ! -z "$msg" ] && printf "$msg\n\n"
75 # add a sign-off-by (-s)
76 [ "$signoff" = "t" ] && printf "Signed-off-by: `git var GIT_COMMITTER_IDENT | sed -e 's/>.*/>/'`\n\n"
77 ) >> "$GUILT_DIR/$branch/$patch"
80 [ "$edit" = "t" ] && git_editor
"$GUILT_DIR/$branch/$patch"
82 if [ ! -z "$force" ]; then
85 git
diff --binary HEAD
>> "$GUILT_DIR/$branch/$patch"
89 # insert the patch name into the series file
90 series_insert_patch
"$patch"
93 echo "$patch" >> $applied