delete: use series_remove_patch instead of opencoding the logic
[guilt.git] / guilt-fold
blob6f52523c356540b628ac45ebf68b3f6d18d87cd4
1 #!/bin/bash
3 # Copyright (c) Josef "Jeff" Sipek, 2006, 2007
6 USAGE="<patchname>"
7 . guilt
9 if [ $# -ne 1 ]; then
10 usage
13 patch="$1"
14 if [ -z "$patch" ]; then
15 die "No patch name supplied."
18 # make sure that there are no unapplied changes
19 if ! must_commit_first; then
20 die "Uncommited changes detected. Refresh first."
23 # make sure it is not applied
24 pline=`cat $applied | grep -e "^[0-9a-f]\{40\}:$patch\$"`
25 if [ ! -z "$pline" ]; then
26 die "Patch is applied. Pop the patch first."
29 # make sure it is a file
30 if [ ! -f "$GUILT_DIR/$branch/$patch" ]; then
31 die "Patch '$patch' is not a regular file."
34 fold_patch "$patch"
36 # back it up just in case :)
37 mv "$1" "$1~"