3 # Copyright (c) Josef "Jeff" Sipek, 2006-2013
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 while [ $# -gt 0 ] ; do
25 if [ ! -z "$msg" ]; then
36 if [ ! -z "$edit" ]; then
41 if [ ! -z "$patch" ]; then
50 if [ -z "$patch" ]; then
51 die
"You must specify a patch name"
54 if [ -f "$GUILT_DIR/$branch/$patch" ]; then
55 die
"patch '$patch' already exist"
58 iidx
=`wc -l < "$applied"`
60 # make sure that there are no unapplied changes
61 if [ -z "$force" ] && ! must_commit_first
; then
62 die
"Uncommited changes detected. Refresh first."
65 if ! valid_patchname
"$patch"; then
66 disp
"Patchname is invalid." >&2
67 die
"It must follow the rules in git-check-ref-format(1)."
70 # create any directories as needed
71 mkdir_dir
=`dirname "$GUILT_DIR/$branch/$patch"`
72 [ "$mkdir_dir" != "$GUILT_DIR/$branch" ] && mkdir
-p "$mkdir_dir"
74 # create the file with the right contents
76 # did we get a message with -m ?
77 [ ! -z "$msg" ] && printf "$msg\n\n"
79 # add a sign-off-by (-s)
80 [ "$signoff" = "t" ] && printf "Signed-off-by: `git var GIT_COMMITTER_IDENT | sed -e 's/>.*/>/'`\n\n"
81 ) >> "$GUILT_DIR/$branch/$patch"
84 [ "$edit" = "t" ] && git_editor
"$GUILT_DIR/$branch/$patch"
86 if [ ! -z "$force" ]; then
89 git
diff --binary HEAD
>> "$GUILT_DIR/$branch/$patch"
93 # insert the patch name into the series file
94 series_insert_patch
"$patch"
97 echo "$patch" >> "$applied"