Ignore *.html, *.1 and *.7 in Documentation/
[guilt.git] / guilt-push
blobc7d8355d357ca61a675a4294b626b3136f43fe3c
1 #!/bin/bash
3 # Copyright (c) Josef "Jeff" Sipek, 2006, 2007
6 USAGE="[ -f ] [-a | --all | <patchname>]"
7 . guilt
9 abort_flag="abort"
12 if [ "$1" == "-f" ]; then
13 abort_flag=""
14 shift
17 if [ $# -gt 1 ]; then
18 usage
21 patch="$1"
23 if [ "$patch" = "--all" -o "$patch" = "-a" ]; then
24 # we are supposed to push all patches, get the last one out of
25 # series
27 eidx=`get_series | wc -l`
28 if [ $eidx -eq 0 ]; then
29 die "There are no patches to push"
31 elif [ -z "$patch" ]; then
32 # we are supposed to push only the next patch onto the stack
34 eidx=`wc -l < $applied`
35 eidx=`expr $eidx + 1`
36 else
37 # we're supposed to push only up to a patch, make sure the patch is
38 # in the series
40 eidx=`get_series | grep -ne "^$patch\$" | cut -d: -f1`
41 if [ -z "$eidx" ]; then
42 die "Patch $patch is not in the series"
46 # make sure that there are no unapplied changes
47 if ! must_commit_first; then
48 die "Uncommited changes detected. Refresh first."
51 # now, find the starting patch
52 sidx=`wc -l < $applied`
53 sidx=`expr $sidx + 1`
55 idx=0
56 for p in `get_series`; do
57 idx=`expr $idx + 1`
58 [ $idx -lt $sidx ] && continue
59 [ $idx -gt $eidx ] && break
61 echo "Applying patch..$p"
62 if [ ! -f "$GUILT_DIR/$branch/$p" ]; then
63 die "Patch $patch does not exist. Aborting."
66 push_patch $p $abort_flag
68 # bail if necessary
69 if [ $? -eq 0 ]; then
70 echo "Patch applied."
71 elif [ -z "$abort_flag" ]; then
72 die "Patch applied with rejects. Fix it up, and refresh."
73 else
74 die "To force apply this patch, use 'guilt push -f'"
76 done