Re: [PATCH v2 2/2] templates: detect commit messages containing diffs
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Feb 14, 2026, 15:42 UTC
- Message-ID
- <xmqqh5rjgwld.fsf@gitster.g>
- In-Reply-To
- <20ed1f26-f60b-4e30-a0a5-8bd01dee19d1@gmail.com>
Phillip Wood <phillip.wood123@gmail.com> writes:
Show 18 quoted lines
>>> 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.