guilt-fold: merge headers of the 2 patches
[guilt.git] / guilt-fold
blobdf2a6191be045b5b616148dd96a29d141eacdd3e
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 it is a file
24 if [ ! -f "$GUILT_DIR/$branch/$patch" ]; then
25 die "Patch $patch does not exist."
28 # make sure that there are no unapplied changes
29 if ! must_commit_first; then
30 die "Uncommited changes detected. Refresh first."
33 # make sure it is not applied
34 pline=`cat $applied | grep -e "^$patch$"`
35 if [ ! -z "$pline" ]; then
36 die "Patch is applied. Pop the patch first."
39 fold_patch "$patch"
41 # back it up just in case :)
42 [ -z "$keep" ] && mv "$GUILT_DIR/$branch/$patch" "$GUILT_DIR/$branch/$patch~"