Subject: Re: [PATCH v2 2/2] templates: detect commit messages containing diffs

From: Junio C Hamano <[email-masked]>
Date: Sat, 14 Feb 2026 07:42:54 -0800

Phillip Wood <[email-masked]> writes:

>>> The trailing ".*" when matching commented lines
>>> ensures that if the comment string ends with a "$" it is not treated
>>> as an anchor.
>> 
>> I am not sure what this means.  Wouldn't these three
>> 
>> 	sed -e '/^#/d'
>> 	sed -e '/^#.*/d'
>> 	sed -e '/^#.*$/d'
>> 
>> work exactly the same way?
>
> They do, but if the comment string is '$' then these two
>
> 	sed -e '/^$/d'
> 	sed -e '/^$.*/d'
>
> have different meanings

Ahh, that is what you meant.

Having to write "/^\$/" is inconvenient, because others characters
do not generally need the backslash (e.g., "/^\#/" and "/^#/" are
the same) and some characters even may become nonsensical if we
blindly add backslash to everybody (e.g., "/^\1/").

Nobody would use "[" as a commentchar, I hope, as "/^[/d" would not
work, and neither "/^[.*/d" does.

Thanks.