Guilt v0.37-rc1
[guilt.git] / guilt-delete
blob967ac10a901eb2c9ef81e91fbbb85e5d5247c4ae
1 #!/bin/sh
3 # Copyright (c) Josef "Jeff" Sipek, 2006-2013
6 USAGE="[-f] <patchname>"
7 if [ -z "$GUILT_VERSION" ]; then
8 echo "Invoking `basename "$0"` directly is no longer supported." >&2
9 exit 1
12 _main() {
14 case $# in
16 # just patchname
17 force=
20 # -f patchname
21 if [ "$1" != "-f" ]; then
22 usage
25 force=t
26 shift
29 usage
31 esac
33 patch="$1"
35 if [ -z "$patch" ]; then
36 die "You must specify a patch to delete"
39 if [ ! -f "$GUILT_DIR/$branch/$patch" ]; then
40 die "Patch $patch does not exist."
43 p=`grep -e "^$patch$" < "$applied"`
44 if [ ! -z "$p" ] ; then
45 die "Cannot delete an applied patch"
48 series_remove_patch "$patch"
50 guilt_hook "delete" "$patch"
52 [ ! -z "$force" ] && rm -f "$GUILT_DIR/$branch/$patch"
54 exit 0