3 # Copyright (c) Josef "Jeff" Sipek, 2006-2013
6 USAGE
="[-eE] [<patchname>]"
7 if [ -z "$GUILT_VERSION" ]; then
8 echo "Invoking `basename "$0"` directly is no longer supported." >&2
19 if [ "$1" = "-e" ]; then
22 elif [ "$1" = "-E" ]; then
31 if [ "$1" = "-e" ]; then
34 elif [ "$1" = "-E" ]; then
44 # are there any patches applied?
45 [ -z "$patch" ] && die
"No patches applied."
47 # check that patch exists in the series
48 TMP_FULL_SERIES
=`get_tmp_file series`
49 get_full_series
> "$TMP_FULL_SERIES"
52 if [ "$x" = "$patch" ]; then
56 done < "$TMP_FULL_SERIES"
57 if [ -z "$found_patch" ]; then
58 TMP_MATCHES
=`get_tmp_file series`
59 grep "$patch" < "$TMP_FULL_SERIES" > "$TMP_MATCHES"
60 nr
=`wc -l < $TMP_MATCHES`
61 if [ $nr -gt 1 ]; then
62 echo "$patch does not uniquely identify a patch. Did you mean any of these?" >&2
63 sed 's/^/ /' "$TMP_MATCHES" >&2
64 rm -f "$TMP_MATCHES" "$TMP_FULL_SERIES"
66 elif [ $nr -eq 0 ]; then
67 rm -f "$TMP_MATCHES" "$TMP_FULL_SERIES"
68 die
"Patch $patch is not in the series"
70 found_patch
=`cat $TMP_MATCHES`
73 rm -f "$TMP_FULL_SERIES"
76 # FIXME: warn if we're editing an applied patch
78 TMP_MSG
=`get_tmp_file msg`
79 TMP_DIFF
=`get_tmp_file diff`
81 if [ -z "$edit" ]; then
82 do_get_header
"$GUILT_DIR/$branch/$patch"
84 if [ -n "$full" ]; then
85 git_editor
"$GUILT_DIR/$branch/$patch"
88 do_get_full_header
"$GUILT_DIR/$branch/$patch" > "$TMP_MSG"
89 do_get_patch
"$GUILT_DIR/$branch/$patch" > "$TMP_DIFF"
91 mv "$GUILT_DIR/$branch/$patch" "$GUILT_DIR/$branch/$patch~"
96 ) > "$GUILT_DIR/$branch/$patch"
99 rm -f "$TMP_MSG" "$TMP_DIFF"