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 ! valid_patchname
"$newpatch"; then
35 die
"The specified patch name contains invalid characters (:)."
38 if [ -e "$GUILT_DIR/$branch/$newpatch" ]; then
39 die
"Patch \"$newpatch\" already exists. Choose another name."
43 cp "$GUILT_DIR/$branch/$patch" "$GUILT_DIR/$branch/$newpatch"
45 # replace the series & applied file references
46 series_rename_patch
"$patch" "$newpatch"
47 applied_rename_patch
"$patch" "$newpatch"
48 ref_rename_patch
"$patch" "$newpatch"