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