git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [GUILT PATCH 2/4] guilt-guard: Assign guards to patches in series

From
ELEric Lesh <eclesh@ucla.edu>
Date
Jul 30, 2007, 06:41 UTC
Message-ID
<87k5sics0f.fsf@hubert.paunchy.net>
In-Reply-To
<20070730040610.GD22017@filer.fsl.cs.sunysb.edu>
Josef Sipek <jsipek@fsl.cs.sunysb.edu> writes:
[...]
Show 28 quoted lines
>> +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.
Show 5 quoted lines
>> +# 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?
Show 5 quoted lines
>> +
>> +# usage: set_guards <patch> <guards>
>
> I'd try to make it clearer that multiple guards can be specified.
>
Done with <guards...> now.
Show 9 quoted lines
>> +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.

Show 9 quoted lines
>> +			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
Previous: Josef SipekNext: Josef Sipek
Message 9 of 20 in “Add guards to guilt”
  1. 0/4 Add guards to guiltEric Lesh, Jul 29, 2007
  2. 1/4 get_series: Remove comments from end of series linesEric Lesh, Jul 29, 2007
  3. Josef SipekJul 30, 2007
  4. Eric LeshJul 30, 2007
  5. Josef SipekJul 30, 2007
  6. Eric LeshJul 30, 2007
  7. 2/4 guilt-guard: Assign guards to patches in seriesEric Lesh, Jul 29, 2007
  8. Josef SipekJul 30, 2007
  9. Eric LeshJul 30, 2007
  10. Josef SipekJul 30, 2007
  11. 3/4 guilt-select: Select guards to apply when pushing patchesEric Lesh, Jul 29, 2007
  12. Josef SipekJul 30, 2007
  13. Eric LeshJul 30, 2007
  14. Josef SipekJul 30, 2007
  15. 4/4 Use guards information and functionsEric Lesh, Jul 29, 2007
  16. Josef SipekJul 30, 2007
  17. Eric LeshJul 30, 2007
  18. Josef SipekJul 30, 2007
  19. Eric LeshJul 30, 2007
  20. Josef SipekJul 30, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.