Ignore empty/commented series lines
[gq.git] / gq-push
blob00c261fad0584ae19c25c4dafd74ea8badcd1ffe
1 #!/bin/bash
3 # Copyright (c) Josef "Jeff" Sipek, 2006
6 source "`dirname $0`/gq.lib"
8 patch="$1"
10 if [ "$patch" = "--all" -o "$patch" = "-a" ]; then
11 # we are supposed to push all patches, get the last one out of
12 # series
14 eidx=`get_series | wc -l`
15 if [ $eidx -eq 0 ]; then
16 echo "There are no patches to push"
17 exit 1
19 elif [ -z "$patch" ]; then
20 # we are supposed to push only the next patch onto the stack
22 eidx=`wc -l < $applied`
23 eidx=`expr $eidx + 1`
24 else
25 # we're supposed to push only up to a patch, make sure the patch is
26 # in the series
28 eidx=`get_series | grep -ne "^$patch\$" | cut -d: -f1`
29 if [ $eidx -eq 0 ]; then
30 echo "Patch $patch is not in the series"
31 exit 1
35 # make sure that there are no unapplied changes
36 if ! must_commit_first; then
37 echo "Uncommited changes detected. Refresh first."
38 exit 1
41 # now, find the starting patch
42 sidx=`wc -l < $applied`
43 sidx=`expr $sidx + 1`
45 bail=0
46 idx=0
47 for p in `get_series`; do
48 idx=`expr $idx + 1`
49 [ $idx -lt $sidx ] && continue
50 [ $idx -gt $eidx ] && break
52 echo "Applying patch..$p"
53 if [ ! -f "$GQ_DIR/$branch/$p" ]; then
54 echo "Patch $patch does not exist. Aborting."
55 exit 1
58 push_patch $p
59 bail=$?
61 # mark patch as applied
62 echo $p >> $applied
64 # bail if necessary
65 if [ $bail -eq 0 ]; then
66 echo "Patch applied."
67 else
68 echo "Patch applied with rejects. Fix it up, and refresh."
69 exit 1
71 done