regression: fix output mismatch with git 1.6.2
[guilt.git] / guilt-commit
blobf8ed9100c6b5110530fd8e17e46eb0635a267302
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"