Makefile: Forgot to add guilt-patchbomb to the list of scripts
[guilt.git] / guilt-push
blob4fb89e27c05dad1b4e50e461f7f550e6d40165a1
1 #!/bin/bash
3 # Copyright (c) Josef "Jeff" Sipek, 2006, 2007
6 source "`dirname $0`/guilt"
8 USAGE="$USAGE [-a | --all | <patchname>]"
10 if [ $# -gt 1 ]; then
11 print_usage
12 exit 1
15 patch="$1"
17 if [ "$patch" = "--all" -o "$patch" = "-a" ]; then
18 # we are supposed to push all patches, get the last one out of
19 # series
21 eidx=`get_series | wc -l`
22 if [ $eidx -eq 0 ]; then
23 echo "There are no patches to push" >&2
24 exit 1
26 elif [ -z "$patch" ]; then
27 # we are supposed to push only the next patch onto the stack
29 eidx=`wc -l < $applied`
30 eidx=`expr $eidx + 1`
31 else
32 # we're supposed to push only up to a patch, make sure the patch is
33 # in the series
35 eidx=`get_series | grep -ne "^$patch\$" | cut -d: -f1`
36 if [ $eidx -eq 0 ]; then
37 echo "Patch $patch is not in the series" >&2
38 exit 1
42 # make sure that there are no unapplied changes
43 if ! must_commit_first; then
44 echo "Uncommited changes detected. Refresh first." >&2
45 exit 1
48 # now, find the starting patch
49 sidx=`wc -l < $applied`
50 sidx=`expr $sidx + 1`
52 idx=0
53 for p in `get_series`; do
54 idx=`expr $idx + 1`
55 [ $idx -lt $sidx ] && continue
56 [ $idx -gt $eidx ] && break
58 echo "Applying patch..$p"
59 if [ ! -f "$GUILT_DIR/$branch/$p" ]; then
60 echo "Patch $patch does not exist. Aborting." >&2
61 exit 1
64 push_patch $p
66 # bail if necessary
67 if [ $? -eq 0 ]; then
68 echo "Patch applied."
69 else
70 echo "Patch applied with rejects. Fix it up, and refresh." >&2
71 exit 1
73 done