On Tue, Jul 06, 2021 at 01:52:12PM -0700, Junio C Hamano wrote: > > This sort of code is much more pleseant to read and work with if you use > > strbuf_split_buf(). This isn't performance sensitive, so a few more > > allocations is fine. > > Please do not encourage use of strbuf_split_buf(). It is a > misdesigned API as it rarely is justifyable to have an array, each > element of which can be independently tweaked by being strbuf. We > are not implementing a text editor after all ;-) Very much agreed on avoiding strbuf_split_buf(). My usual go-to is string_list_split(), which I think would work here for splitting on ":". > A helper function that takes a string and returns a strvec would be > a good fit, though. I was going to second that, but I see we already have one. :) Dscho introduced it in c5aa6db64f (argv_array: offer to split a string by whitespace, 2018-04-25), and then it later became strvec_split(). And indeed, Lénaïc's patches use it elsewhere. I think it doesn't work in this instance because it can't take an arbitrary delimiter. But I wouldn't at all mind seeing it grow that feature (and I suspect it could even share some code with string_list_split(), but didn't look). -Peff