[PATCH] guilt: skip empty line after from: line in patch descriptoin
[guilt.git] / guilt-fold
blob07d77a106e0f748f7a9f9ab09781de6e437ff43c
1 #!/bin/sh
3 # Copyright (c) Josef "Jeff" Sipek, 2006-2011
6 USAGE="[-k] <patchname>"
7 if [ -z "$GUILT_VERSION" ]; then
8 echo "Invoking $GUILT directly is no longer supported." >&2
9 exit 1
12 _main() {
14 if [ "$1" = "-k" ]; then
15 keep=t
16 shift
19 if [ $# -ne 1 ]; then
20 usage
23 patch="$1"
24 if [ -z "$patch" ]; then
25 die "No patch name supplied."
28 # make sure it is a file
29 if [ ! -f "$GUILT_DIR/$branch/$patch" ]; then
30 die "Patch $patch does not exist."
33 # make sure that there are no unapplied changes
34 if ! must_commit_first; then
35 die "Uncommited changes detected. Refresh first."
38 # make sure it is not applied
39 pline=`cat "$applied" | grep -e "^$patch$"`
40 if [ ! -z "$pline" ]; then
41 die "Patch is applied. Pop the patch first."
44 fold_patch "$patch"
46 # back it up just in case :)
47 [ -z "$keep" ] && mv "$GUILT_DIR/$branch/$patch" "$GUILT_DIR/$branch/$patch~"