3 # Copyright (c) Josef "Jeff" Sipek, 2008-2013
6 USAGE
="-n <num> | -a | --all"
7 if [ -z "$GUILT_VERSION" ]; then
8 echo "Invoking `basename "$0"` directly is no longer supported." >&2
22 [ "$2" -lt 0 ] && die
"Must specify a number of patches to commit"
23 [ "$2" -eq 0 ] && exit 0
26 pat_keep
="`expr "$2" + 1`,\$p"
33 # if nothing's applied, exit
34 [ `wc -l < "$applied"` -eq 0 ] && exit 0
36 # remove patch refs for what's being committed, and update series
37 sed -n -e "${pat_commit}" "$applied" |
while read pname
; do
38 # update the base branch to the last committed patch
39 $old_style_prefix || git update-ref refs
/heads
/$branch \
40 refs
/patches
/$branch/$pname
42 series_remove_patch
"$pname"
43 echo "$pname" | remove_patch_refs
46 # update $applied to include only the patches we're keeping
47 sed -n -e "${pat_keep}" "$applied" > "$applied.tmp"
48 mv "$applied.tmp" "$applied"
50 # if we removed the last patch, switch back to the base branch
51 if [ `wc -l < "$applied"` -eq 0 ] && [ "`git symbolic-ref HEAD`" = "refs/heads/$GUILT_PREFIX$branch" ] && ! $old_style_prefix
53 git update-ref refs
/heads
/$branch refs
/heads
/$GUILT_PREFIX$branch
54 git symbolic-ref HEAD refs
/heads
/$branch
55 git update-ref
-d refs
/heads
/$GUILT_PREFIX$branch