push: fixed push pushing more than it should
[guilt/mob.git] / guilt-header
blob66521ac86847373141dd9b2a4a6b7f36ada18bbc
1 #!/bin/sh
3 # Copyright (c) Josef "Jeff" Sipek, 2006, 2007
6 USAGE="[-e] [<patchname>]"
7 . `dirname $0`/guilt
9 case $# in
11 patch=`get_top`
14 if [ "$1" = "-e" ]; then
15 edit=t
16 patch=`get_top`
17 else
18 patch="$1"
22 [ "$1" != "-e" ] && usage
24 edit=t
25 patch="$2"
28 esac
30 # are there any patches applied?
31 [ -z "$patch" ] && die "No patches applied."
33 # check that patch exists in the series
34 ret=`get_series | grep -e "^$patch\$" | wc -l`
35 if [ $ret -eq 0 ]; then
36 die "Patch $patch is not in the series"
39 # FIXME: warn if we're editing an applied patch
41 TMP_MSG=`get_tmp_file msg`
42 TMP_DIFF=`get_tmp_file diff`
44 if [ -z "$edit" ]; then
45 do_get_header "$GUILT_DIR/$branch/$patch"
46 else
47 do_get_full_header "$GUILT_DIR/$branch/$patch" > "$TMP_MSG"
48 do_get_patch "$GUILT_DIR/$branch/$patch" > "$TMP_DIFF"
49 git_editor "$TMP_MSG"
50 mv "$GUILT_DIR/$branch/$patch" "$GUILT_DIR/$branch/$patch~"
53 cat "$TMP_MSG"
54 cat "$TMP_DIFF"
55 ) > "$GUILT_DIR/$branch/$patch"
58 rm -f "$TMP_MSG" "$TMP_DIFF"