On 09/02/22 00:00, Eric Blake wrote:
> On Thu, Sep 01, 2022 at 05:25:55PM +0100, Richard W.M. Jones wrote:
>>>
>>> Can we introduce some xfuncname pattern for these "state machine" C
>>> files? The STATE_MACHINE hunk header is totally useless. I'd like
>>> "NEWSTYLE.OPT_META_CONTEXT.START". :)
>>
>> It took me a while to work out what this means, but yes I agree.
>> It seems the following should work but does not for me:
>>
>>   .git/config add:
>>   [diff "nbdstate"]
>>         xfuncname = "^ [A-Z.]*:$"
> 
> Probably also want _0-9 in that [].
> 
>>
>>   .git/info/attributes:
>>   generator/states-*.c diff=nbdstate
> 
> We could also put it in .gitattributes (we've already done it for *.ml
> files, where we give the user the 'git config' command to run to take
> advantage of it).  It's a shame it's not quite automatic from a fresh
> git checkout, but the idea should work if done right.
> 
> Here's what I tested. In .gitattributes:
> 
> # Use the following one-time config to get nicer diffs of generator state 
> files:
> #   git config diff.states.xfuncname '^([a-zA-Z_]| [A-Z._0-9]*:$)'
> generator/states-*.c diff=states
> 
> then run that git config, then looking at 'git log -p
> generator/states-*.c', the diff for 30ee21f6 is a lot more legible,
> with lines like:
> 
> +++ b/generator/states-reply-structured.c
> @@ -89,13 +89,8 @@  REPLY.STRUCTURED_REPLY.CHECK:
>    }
> 
>    /* Skip an unexpected structured reply, including to an unknown cookie. */
> -  if (cmd == NULL || !h->structured_replies) {
> 
> where the @@ line points to the right sub-state.
> 

So that's commit 32f02567d50c009e835a3a167cf5e1a996257729 now; thanks!
Laszlo
_______________________________________________
Libguestfs mailing list
Libguestfs@redhat.com
https://listman.redhat.com/mailman/listinfo/libguestfs

Reply via email to