3 # Copyright (c) Josef "Jeff" Sipek, 2007
6 USAGE
="[-P <patch> ] <patch_file>"
15 newname
=`basename "$1"`
20 if [ $# -lt 1 ] ||
[ $# -gt 3 ] ||
[ -z "$newname" ] ||
[ -z "$oldname" ]; then
24 # make sure that there are no unapplied changes
25 if ! must_commit_first
; then
26 die
"Uncommited changes detected. Refresh first."
29 if [ ! -e "$oldname" ]; then
30 die
"Specified file does not exist."
33 if [ -e "$GUILT_DIR/$branch/$newname" ]; then
34 die
"Already tracking a patch under that name."
37 if ! valid_patchname
"$newname"; then
38 die
"The specified patch name contains invalid characters (:)."
41 # create any directories as needed
42 mkdir_dir
=`dirname "$GUILT_DIR/$branch/$newname"`
43 [ "$mkdir_dir" != "$GUILT_DIR/$branch" ] && mkdir
-p "$mkdir_dir"
45 cp "$oldname" "$GUILT_DIR/$branch/$newname"
47 # insert the patch into the series file
48 series_insert_patch
"$newname"