3 # Copyright (c) Josef "Jeff" Sipek, 2007-2011
7 if [ -z "$GUILT_VERSION" ]; then
8 echo "Invoking `basename $0` directly is no longer supported." >&2
19 if [ -z "$patch" ]; then
20 die
"No patches are applied."
23 # make sure that there are no unapplied changes
24 if ! must_commit_first
; then
25 die
"Uncommited changes detected. Refresh first."
28 # Rename patches smartly
32 base
=$
(echo "$patch" \
33 |
sed -r -e 's:(\.diff?|\.patch)$::')
34 num
=$
(echo "$base" |
sed -nre 's:.*-([0-9]+)$:\1:'p
)
35 [ -n "$num" ] || num
=1
36 newpatch
="${base%-$num}-$(($num+1))${patch#$base}"
39 if ! valid_patchname
"$newpatch"; then
40 die
"The specified patch name contains invalid characters (:)."
43 if [ -e "$GUILT_DIR/$branch/$newpatch" ]; then
44 die
"Patch \"$newpatch\" already exists. Choose another name."
48 cp "$GUILT_DIR/$branch/$patch" "$GUILT_DIR/$branch/$newpatch"
50 # replace the series & applied file references
51 series_rename_patch
"$patch" "$newpatch"
52 applied_rename_patch
"$patch" "$newpatch"
53 ref_rename_patch
"$patch" "$newpatch"