[GUILT 4/6] Run regression tests in a directory which contains spaces
[guilt.git] / guilt-header
blob99107089aa4cfe797d5a2ba1d9cc4a6dca06b48c
1 #!/bin/sh
3 # Copyright (c) Josef "Jeff" Sipek, 2006-2011
6 USAGE="[-eE] [<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 patch=`get_top`
19 if [ "$1" = "-e" ]; then
20 edit=t
21 patch=`get_top`
22 elif [ "$1" = "-E" ]; then
23 edit=t
24 full=t
25 patch=`get_top`
26 else
27 patch="$1"
31 if [ "$1" = "-e" ]; then
32 edit=t
33 patch="$2"
34 elif [ "$1" = "-E" ]; then
35 edit=t
36 full=t
37 patch="$2"
38 else
39 usage
42 esac
44 # are there any patches applied?
45 [ -z "$patch" ] && die "No patches applied."
47 # check that patch exists in the series
48 ret=`get_full_series | grep -e "^$patch\$" | wc -l`
49 if [ $ret -eq 0 ]; then
50 die "Patch $patch is not in the series"
53 # FIXME: warn if we're editing an applied patch
55 TMP_MSG=`get_tmp_file msg`
56 TMP_DIFF=`get_tmp_file diff`
58 if [ -z "$edit" ]; then
59 do_get_header "$GUILT_DIR/$branch/$patch"
60 else
61 if [ -n "$full" ]; then
62 git_editor "$GUILT_DIR/$branch/$patch"
63 exit $?
65 do_get_full_header "$GUILT_DIR/$branch/$patch" > "$TMP_MSG"
66 do_get_patch "$GUILT_DIR/$branch/$patch" > "$TMP_DIFF"
67 git_editor "$TMP_MSG"
68 mv "$GUILT_DIR/$branch/$patch" "$GUILT_DIR/$branch/$patch~"
71 cat "$TMP_MSG"
72 cat "$TMP_DIFF"
73 ) > "$GUILT_DIR/$branch/$patch"
76 rm -f "$TMP_MSG" "$TMP_DIFF"