Documentation: guilt & git don't use hyphenated commands
[guilt.git] / guilt-delete
blob3e394f84f6d993ffe2a7608b0632fe80749e495b
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