[GUILT 2/6] guilt-header: fix patch corruption
[guilt.git] / guilt-series
blobd9b1cc2154152a7f04ffe0985db29e858b243895
1 #!/bin/sh
3 # Copyright (c) Josef "Jeff" Sipek, 2006-2011
6 USAGE="[-v | -g | -e]"
7 if [ -z "$GUILT_VERSION" ]; then
8 echo "Invoking `basename $0` directly is no longer supported." >&2
9 exit 1
12 _main() {
14 while case "$#" in 0) break ;; esac
16 case "$1" in
17 -v)
18 verbose=t ;;
19 -g)
20 gui=t ;;
21 -e)
22 edit=t ;;
24 usage ;;
25 esac
26 shift
27 done
29 if [ ! -z "$edit" ]; then
30 git_editor "$series"
31 elif [ ! -z "$gui" ]; then
32 [ -z "`get_top`" ] && die "No patches applied."
33 bottom=`git rev-parse refs/patches/$branch/$(head_n 1 $applied)`
34 top=`git rev-parse refs/patches/$branch/$(tail -n 1 $applied)`
35 range="$bottom..$top"
37 # FIXME, this doesn't quite work - it's perfectly fine with
38 # "git rev-list", but gitk for whatever reason likes to include the
39 # parent
40 [ "$bottom" = "$top" ] && range="$bottom^..$bottom"
42 gitk $range
43 elif [ -z "$verbose" ]; then
44 get_full_series
45 else
46 prefix="+"
47 top=`get_top`
49 get_full_series |
50 while read patch; do
51 if [ -z "$top" ]; then
52 disp " $patch"
53 else
54 if [ "$patch" = "$top" ]; then
55 disp "= $patch"
56 prefix=" "
57 elif [ $(check_guards "$patch"; echo $?) -eq 1 ]; then
58 echo " $patch"
59 else
60 disp "$prefix $patch"
63 done