regression: test 021: test pop code
[guilt.git] / guilt-fold
blobfa930e881894eb63d52920726aa83a5d883c9b09
1 #!/bin/sh
3 # Copyright (c) Josef "Jeff" Sipek, 2006, 2007
6 USAGE="[-k] <patchname>"
7 . `dirname $0`/guilt
9 if [ "$1" = "-k" ]; then
10 keep=t
11 shift
14 if [ $# -ne 1 ]; then
15 usage
18 patch="$1"
19 if [ -z "$patch" ]; then
20 die "No patch name supplied."
23 # make sure that there are no unapplied changes
24 if ! must_commit_first; then
25 die "Uncommited changes detected. Refresh first."
28 # make sure it is not applied
29 pline=`cat $applied | grep -e "^[0-9a-f]\{40\}:$patch\$"`
30 if [ ! -z "$pline" ]; then
31 die "Patch is applied. Pop the patch first."
34 # make sure it is a file
35 if [ ! -f "$GUILT_DIR/$branch/$patch" ]; then
36 die "Patch '$patch' is not a regular file."
39 fold_patch "$patch"
41 # back it up just in case :)
42 [ -z "$keep" ] && mv "$GUILT_DIR/$branch/$patch" "$GUILT_DIR/$branch/$patch~"