guilt: remove a useless cat
[guilt.git] / guilt-commit
blob4ef66050ad579d3e9799d24f8457e511feeade19
1 #!/bin/sh
3 # Copyright (c) Josef "Jeff" Sipek, 2008-2011
6 USAGE="-n <num> | -a | --all"
7 if [ -z "$GUILT_VERSION" ]; then
8 echo "Invoking $GUILT directly is no longer supported." >&2
9 exit 1
12 _main() {
14 case "$1" in
15 -a|--all)
16 [ $# -gt 1 ] && usage
17 pat_commit="1,\$p"
18 pat_keep=""
20 -n)
21 [ $# -gt 2 ] && usage
22 [ "$2" -lt 0 ] && die "Must specify a number of patches to commit"
23 [ "$2" -eq 0 ] && exit 0
25 pat_commit="1,$2p"
26 pat_keep="`expr "$2" + 1`,\$p"
29 usage
31 esac
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 series_remove_patch "$pname"
39 echo "$pname" | remove_patch_refs
40 done
42 # update $applied to include only the patches we're keeping
43 sed -n -e "${pat_keep}" "$applied" > "$applied.tmp"
44 mv "$applied.tmp" "$applied"