From: Eric Lesh <eclesh@ucla.edu>
To: Josef Sipek <jsipek@fsl.cs.sunysb.edu>
Cc: jsipek@cs.sunysb.edu, git@vger.kernel.org
Subject: Re: [GUILT PATCH 2/4] guilt-guard: Assign guards to patches in series
Date: Sun, 29 Jul 2007 23:41:52 -0700 [thread overview]
Message-ID: <87k5sics0f.fsf@hubert.paunchy.net> (raw)
In-Reply-To: <20070730040610.GD22017@filer.fsl.cs.sunysb.edu> (Josef Sipek's message of "Mon\, 30 Jul 2007 00\:06\:10 -0400")
Josef Sipek <jsipek@fsl.cs.sunysb.edu> writes:
[...]
>> +get_guarded_series()
>> +{
>> + get_series | while read p
>> + do
>> + [ -z `check_guards $p` ] && echo "$p"
>
> Having check_guards return 0 or 1 makes things cleaner:
>
> check_guards "$p" && echo "$p"
>
>> + done
>> +}
>> +
>> +# usage: check_guards <patch>
>> +# Returns t if the patch should be skipped
>> +check_guards()
>> +{
>> + get_guards "$1" | while read guard
>> + do
>> + pos=`echo $guard | grep -e "^+"`
>> + guard=`echo $guard | sed -e 's/[+-]//'`
>> + if [ $pos ]; then
>> + # Push +guard *only if* guard selected
>> + push=`grep -e "^$guard\$" "$guards_file" > /dev/null; echo $?`
>> + [ $push -ne 0 ] && echo t
>
> [ $push -ne 0 ] && return 1
>
This returns from the subshell created by the pipe and the while loop,
right?
So I'm using:
check_guards()
{
get_guards "$1" | while read guard
do
pos=`echo $guard | grep -e "^+"`
guard=`echo $guard | sed -e 's/^[+-]//'`
if [ $pos ]; then
# Push +guard *only if* guard selected
push=`grep -e "^$guard\$" "$guards_file" > /dev/null; echo $?`
[ $push -ne 0 ] && return 1
else
# Push -guard *unless* guard selected
push=`grep -e "^$guard\$" "$guards_file" > /dev/null; echo $?`
[ $push -eq 0 ] && return 1
fi
return 0
done
return $?
}
where 1 means push.
>> +# usage: get_guards <patch>
>> +get_guards()
>> +{
>> + grep -e "^$1[[:space:]]*#" < "$series" | sed -e "s/^$1 //" -e 's/#[^+-]*//g'
>> +}
Should this also be one sed script instead of a grep + sed?
>> +
>> +# usage: set_guards <patch> <guards>
>
> I'd try to make it clearer that multiple guards can be specified.
>
Done with <guards...> now.
>> +set_guards()
>> +{
>> + p="$1"
>> + shift
>> + for x in "$@"; do
>> + if [ -z $(echo "$x" | grep -e "^[+-]") ]; then
>
> Is that the only restriction on the guard name?
>
Yes. On patches, you put a '+guard' or '-guard'. When selecting with
guilt-select, it's just 'guard'. The + or - just means 'apply when
selected' or 'apply unless selected'. You can edit things manually to
make guards with a space in the name, but the mechanism will work even
in that case.
>> + echo "'$x' is not a valid guard name"
>> + else
>> + sed -i -e "s/^\($p[[:space:]]*.*\)$/\1 #$x/" "$series"
>> + fi
>> + done
>> +}
>> +
>> +# usage: unset_guards <patch> <guards>
>
[...]
The rest I'll do. Thanks for the review.
Eric
next prev parent reply other threads:[~2007-07-30 6:42 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-29 7:50 [GUILT PATCH 0/4] Add guards to guilt Eric Lesh
2007-07-29 7:50 ` [GUILT PATCH 1/4] get_series: Remove comments from end of series lines Eric Lesh
2007-07-30 3:54 ` Josef Sipek
2007-07-30 5:15 ` Eric Lesh
2007-07-30 5:26 ` Josef Sipek
2007-07-30 7:07 ` Eric Lesh
2007-07-29 7:50 ` [GUILT PATCH 2/4] guilt-guard: Assign guards to patches in series Eric Lesh
2007-07-30 4:06 ` Josef Sipek
2007-07-30 6:41 ` Eric Lesh [this message]
2007-07-30 19:28 ` Josef Sipek
2007-07-29 7:50 ` [GUILT PATCH 3/4] guilt-select: Select guards to apply when pushing patches Eric Lesh
2007-07-30 4:12 ` Josef Sipek
2007-07-30 7:02 ` Eric Lesh
2007-07-30 19:34 ` Josef Sipek
2007-07-29 7:50 ` [GUILT PATCH 4/4] Use guards information and functions Eric Lesh
2007-07-30 4:15 ` Josef Sipek
2007-07-30 7:06 ` Eric Lesh
2007-07-30 3:54 ` [GUILT PATCH 0/4] Add guards to guilt Josef Sipek
2007-07-30 8:32 ` Eric Lesh
2007-07-30 19:20 ` Josef Sipek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87k5sics0f.fsf@hubert.paunchy.net \
--to=eclesh@ucla.edu \
--cc=git@vger.kernel.org \
--cc=jsipek@cs.sunysb.edu \
--cc=jsipek@fsl.cs.sunysb.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.