guilt-fold: merge headers of the 2 patches
[guilt.git] / guilt-guard
blob15bcf0ebf1dec2bf3c6b1660101d89c325021057
1 #!/bin/sh
3 # Copyright (c) Eric Lesh, 2007
6 USAGE="[-l | --list | -n | --none | [<patchname>] [(+|-)<guard>...]]"
7 . `dirname $0`/guilt
9 print_guards()
11 guards=`get_guards "$1"`
12 echo "$1: $guards"
15 if [ "$1" == "-l" ] || [ "$1" == "--list" ]; then
16 get_full_series | while read patch; do
17 print_guards "$patch"
18 done
19 exit 0
20 elif [ "$1" == "-n" ] || [ "$1" == "--none" ]; then
21 patch="$2"
22 if [ -z "$patch" ]; then
23 patch=`get_top`
25 unset_guards "$patch" `get_guards "$patch"`
26 exit 0
29 case $# in
31 if [ ! -s "$applied" ]; then
32 die "No patches applied."
34 print_guards `get_top`
37 if [ -z $(printf %s "$1" | grep -e '^[+-]') ]; then
38 if [ -z $(get_full_series | grep -e "^$1\$") ]; then
39 die "Patch $1 does not exist."
40 else
41 print_guards "$1"
43 else
44 patch=`get_top`
45 if [ -z "$patch" ]; then
46 die "You must specify a patch."
48 unset_guards "$patch" `get_guards "$patch"`
49 set_guards "$patch" "$1"
53 if [ -z $(printf %s "$1" | grep -e '^[+-]') ]; then
54 if [ -z $(get_full_series | grep -e "^$1\$") ]; then
55 die "Patch $1 does not exist."
56 else
57 patch="$1"
59 shift
60 else
61 patch=`get_top`
62 if [ -z "$patch" ]; then
63 die "You must specify a patch."
66 unset_guards "$patch" `get_guards "$patch"`
67 set_guards "$patch" "$@"
69 esac