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 pop all patches
20 sidx
=`wc -l < $applied`
23 elif [ -z "$patch" ]; then
24 # we are supposed to pop only the current patch on the stack
26 sidx
=`wc -l < $applied`
30 # we're supposed to pop only up to a patch, make sure the patch is
33 eidx
=`cat $applied | grep -ne "^$patch\$" | cut -d: -f1`
34 if [ -z "$eidx" ]; then
35 echo "Patch $patch is not in the series/is not applied"
40 sidx
=`wc -l < $applied`
44 # make sure that there are no unapplied changes
45 if ! must_commit_first
; then
46 echo "Uncommited changes detected. Refresh first."
51 for p
in `cat $series | tac`; do
53 [ $idx -gt $sidx ] && continue
54 [ $idx -lt $eidx ] && break
56 echo "Popping patch...$p"
62 [ ! -z "$p" ] && echo "Now at $p." ||
echo "All patches popped."