3 # Copyright (c) Josef "Jeff" Sipek, 2007
14 if [ -z "$patch" ]; then
15 die
"No patches are applied."
18 # make sure that there are no unapplied changes
19 if ! must_commit_first
; then
20 die
"Uncommited changes detected. Refresh first."
23 # Rename patches smartly
27 base
=$
(echo "$patch" \
28 |
sed -r -e 's:(\.diff?|\.patch)$::')
29 num
=$
(echo "$base" |
sed -nre 's:.*-([0-9]+)$:\1:'p
)
30 [ -n "$num" ] || num
=1
31 newpatch
="${base%-$num}-$(($num+1))${patch#$base}"
34 if [ -e "$GUILT_DIR/$branch/$newpatch" ]; then
35 die
"Patch \"$newpatch\" already exists. Choose another name."
39 cp "$GUILT_DIR/$branch/$patch" "$GUILT_DIR/$branch/$newpatch"
41 # replace the series & applied file references
42 series_rename_patch
"$patch" "$newpatch"
43 applied_rename_patch
"$patch" "$newpatch"