Re: [PATCH v3 4/7] string-list: optionally trim string pieces split by string_list_split*()
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Aug 2, 2025, 16:38 UTC
- Message-ID
- <xmqqzfchispv.fsf@gitster.g>
- In-Reply-To
- <20250802082659.GB3711639@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 19 quoted lines
> On Fri, Aug 01, 2025 at 03:04:20PM -0700, Junio C Hamano wrote:
>
>> +/* flag bits for split_f and split_in_place_f functions */
>> +enum {
>> + /* trim() resulting string piece before adding it to the list */
>> + STRING_LIST_SPLIT_TRIM = (1 << 0),
>> +};
>
> It might be worth defining here what "trim" means. I can think of two
> obvious definitions:
>
> 1. trim whitespace from each split piece
>
> 2. trim excess delimiters from each split piece (which in turn depends
> on how we handle multiple delimiters; do we make empty pieces, or
> do we collapse them? I think the former, which would make this type
> of trimming impossible?).
>
> It looks like the patch does (1).True. "nm git | grep trim" tells us that we most of the time use the word to mean removing whitespaces, but there are exceptions.
It certainly is a good idea to rewrite "trim()" in that comment to "trim whitespaces around" or something like that.
Thanks.