regression: 011 should test guilt-commit as well
[guilt/mob.git] / guilt-fold
blobe39705fe3337f397f18d78d4cce96d0e57161ac6
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 "^$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~"