guilt-fold: merge headers of the 2 patches
[guilt.git] / guilt-select
blobd4307d9cb6eead6d9f5f89c7bc18acfa7b774a2e
1 #!/bin/sh
3 # Copyright (c) Eric Lesh, 2007
6 USAGE="[ -n | --none | -s | --series | [--pop|--reapply] <guards...> ]"
7 . `dirname $0`/guilt
9 select_guards()
11 for x in "$@"; do
12 if [ $(printf %s "$x" | grep -e "^[+-]") ]; then
13 die "'$x' cannot begin with + or -."
15 done
16 echo "$@" | sed -e 's/ /\n/g' | sort | uniq > "$guards_file"
19 if [ $# == 0 ]; then
20 if [ -s "$guards_file" ]; then
21 cat "$guards_file"
22 else
23 echo >&2 "No guards applied"
25 exit 0
28 case $1 in
29 -n|--none)
30 rm -f "$guards_file"
32 --pop)
33 guilt-pop -a
34 shift
35 select_guards "$@"
37 --reapply)
38 top=`get_top`
39 guilt-pop -a
40 shift
41 select_guards "$@"
42 guilt-push "$top"
44 -s|--series)
45 (get_full_series | while read patch; do
46 get_guards "$patch"
47 done) | sed -e 's/ /\n/g' | sort | uniq
50 select_guards "$@"
52 esac