3 # Copyright (c) Josef "Jeff" Sipek, 2006, 2007
6 source "`dirname $0`/guilt"
8 USAGE
="$USAGE [-a | --all | <patchname>]"
17 if [ "$patch" = "--all" -o "$patch" = "-a" ]; then
18 # we are supposed to pop all patches
20 sidx
=`wc -l < $applied`
22 elif [ -z "$patch" ]; then
23 # we are supposed to pop only the current patch on the stack
25 sidx
=`wc -l < $applied`
28 # we're supposed to pop only up to a patch, make sure the patch is
31 eidx
=`cat $applied | grep -ne "^[0-9a-f]\{40\}:$patch\$" | cut -d: -f 1`
32 if [ -z "$eidx" ]; then
33 echo "Patch $patch is not in the series/is not applied" >&2
38 sidx
=`wc -l < $applied`
41 # make sure that there are no unapplied changes
42 if ! must_commit_first
; then
43 echo "Uncommited changes detected. Refresh first." >&2
47 l
=`awk "BEGIN{n=0}(n==$eidx){print \\$0; exit}{n=n+1}END{}" < $applied`
49 pop_many_patches
`echo $l | cut -d: -f1`^
`expr $sidx - $eidx`
52 [ ! -z "$p" ] && echo "Now at $p." ||
echo "All patches popped."