3 # Copyright (c) Josef "Jeff" Sipek, 2006
6 source "`dirname $0`/gq.lib"
8 export GIT_DIR
=`find_git_dir`
9 GQ_DIR
="$GIT_DIR/patches"
11 branch
=`get_branch_verify`
12 series
="$GQ_DIR/$branch/series"
13 applied
="$GQ_DIR/$branch/status"
17 if [ "$patch" = "--all" -o "$patch" = "-a" ]; then
18 # we are supposed to push all patches, get the last one out of
21 eidx
=`wc -l < $series`
22 if [ $eidx -eq 0 ]; then
23 echo "There are no patches to push"
26 elif [ -z "$patch" ]; then
27 # we are supposed to push only the next patch onto the stack
29 eidx
=`wc -l < $applied`
32 # we're supposed to push only up to a patch, make sure the patch is
35 eidx
=`cat $series | grep -ne "^$patch\$" | cut -d: -f1`
36 if [ $eidx -eq 0 ]; then
37 echo "Patch $patch is not in the series"
42 # make sure that there are no unapplied changes
43 if ! must_commit_first
; then
44 echo "Uncommited changes detected. Refresh first."
48 # now, find the starting patch
49 sidx
=`wc -l < $applied`
54 for p
in `cat $series`; do
56 [ $idx -lt $sidx ] && continue
57 [ $idx -gt $eidx ] && break
59 echo "Applying patch..$p"
60 if [ ! -f "$GQ_DIR/$branch/$p" ]; then
61 echo "Patch $patch does not exist. Aborting."
68 # mark patch as applied
72 if [ $bail -eq 0 ]; then
75 echo "Patch applied with rejects. Fix it up, and refresh."