Check HEAD hash against what we expect before push/pop/refresh
[guilt.git] / guilt-new
blob48fbb6fee8f5d7b310daffd701731cf5886bedea
1 #!/bin/bash
3 # Copyright (c) Josef "Jeff" Sipek, 2006, 2007
6 source "`dirname $0`/guilt"
8 USAGE="$USAGE <patchname>"
10 if [ $# -ne 1 ]; then
11 print_usage
12 exit 1
15 patch="$1"
17 if [ -z "$patch" ]; then
18 print_usage
19 echo "You must specify a patch name"
20 exit 1
23 iidx=`wc -l < $applied`
25 # make sure that there are no unapplied changes
26 if ! must_commit_first; then
27 echo "Uncommited changes detected. Refresh first."
28 exit 1
31 # create any directories as needed
32 [ "`dirname $patch`" != "." ] && mkdir -p `dirname $GUILT_DIR/$branch/$patch`
34 # create the empty patch file
35 touch $GUILT_DIR/$branch/$patch
37 top=`get_top`
39 if [ ! -z "$top" ]; then
40 sed -i -e "s,^$top\$,$top\n$patch," $series
41 else
42 echo "$patch" > $series.tmp
43 cat $series >> $series.tmp
44 mv $series.tmp $series
47 # apply the patch
48 push_patch $patch