forked from jeffpc/guilt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathguilt-guard
executable file
·76 lines (70 loc) · 1.41 KB
/
guilt-guard
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/sh
#
# Copyright (c) Eric Lesh, 2007
#
USAGE="[-l | --list | -n | --none | [<patchname>] [(+|-)<guard>...]]"
if [ -z "$GUILT_VERSION" ]; then
echo "Invoking `basename "$0"` directly is no longer supported." >&2
exit 1
fi
print_guards()
{
guards=`get_guards "$1"`
echo "$1: $guards"
}
_main() {
if [ "$1" = "-l" -o "$1" = "--list" ]; then
get_full_series | while read patch; do
print_guards "$patch"
done
exit 0
elif [ "$1" = "-n" -o "$1" = "--none" ]; then
patch="$2"
if [ -z "$patch" ]; then
patch=`get_top`
fi
unset_guards "$patch" `get_guards "$patch"`
exit 0
fi
case $# in
0)
if [ ! -s "$applied" ]; then
die "No patches applied."
fi
print_guards `get_top`
;;
1)
if [ -z $(printf %s "$1" | grep -e '^[+-]') ]; then
if [ -z $(get_full_series | grep -e "^$1\$") ]; then
die "Patch $1 does not exist."
else
print_guards "$1"
fi
else
patch=`get_top`
if [ -z "$patch" ]; then
die "You must specify a patch."
fi
unset_guards "$patch" `get_guards "$patch"`
set_guards "$patch" "$1"
fi
;;
*)
if [ -z $(printf %s "$1" | grep -e '^[+-]') ]; then
if [ -z $(get_full_series | grep -e "^$1\$") ]; then
die "Patch $1 does not exist."
else
patch="$1"
fi
shift
else
patch=`get_top`
if [ -z "$patch" ]; then
die "You must specify a patch."
fi
fi
unset_guards "$patch" `get_guards "$patch"`
set_guards "$patch" "$@"
;;
esac
}