3 # Copyright (c) Josef "Jeff" Sipek, 2007-2013
6 USAGE
="[-P <patch> ] <patch_file>"
7 if [ -z "$GUILT_VERSION" ]; then
8 echo "Invoking `basename "$0"` directly is no longer supported." >&2
20 newname
=`basename "$1"`
25 if [ $# -lt 1 ] ||
[ $# -gt 3 ] ||
[ -z "$newname" ] ||
[ -z "$oldname" ]; then
29 # make sure that there are no unapplied changes
30 if ! must_commit_first
; then
31 die
"Uncommited changes detected. Refresh first."
34 if [ ! -e "$oldname" ]; then
35 die
"Specified file does not exist."
38 if [ -e "$GUILT_DIR/$branch/$newname" ]; then
39 die
"Already tracking a patch under that name."
42 if ! valid_patchname
"$newname"; then
43 die
"The specified patch name contains invalid characters (:)."
46 # create any directories as needed
47 mkdir_dir
=`dirname "$GUILT_DIR/$branch/$newname"`
48 [ "$mkdir_dir" != "$GUILT_DIR/$branch" ] && mkdir
-p "$mkdir_dir"
50 cp "$oldname" "$GUILT_DIR/$branch/$newname"
52 # insert the patch into the series file
53 series_insert_patch
"$newname"