regression: 011 should test guilt-commit as well
[guilt.git] / guilt-commit
blob82aa22e2573affb997cd667a3b1b545c93343354
1 #!/bin/sh
3 # Copyright (c) Josef "Jeff" Sipek, 2008
6 USAGE="-n <num> | -a | --all"
7 . `dirname $0`/guilt
9 case "$1" in
10 -a|--all)
11 [ $# -gt 1 ] && usage
12 pat_commit="1,\$p"
13 pat_keep=""
15 -n)
16 [ $# -gt 2 ] && usage
17 [ "$2" -lt 0 ] && die "Must specify a number of patches to commit"
18 [ "$2" -eq 0 ] && exit 0
20 pat_commit="1,$2p"
21 pat_keep="`expr "$2" + 1`,\$p"
24 usage
26 esac
28 # if nothing's applied, exit
29 [ `wc -l < "$applied"` -eq 0 ] && exit 0
31 # remove patch refs for what's being committed, and update series
32 sed -n -e "${pat_commit}" "$applied" | while read pname; do
33 series_remove_patch "$pname"
34 echo "$pname" | remove_patch_refs
35 done
37 # update $applied to include only the patches we're keeping
38 sed -n -e "${pat_keep}" "$applied" > "$applied.tmp"
39 mv "$applied.tmp" "$applied"
41 # update references to top, bottom, and base
42 update_stack_tags