From: Junio C Hamano Date: Fri, 27 Mar 2026 15:55:18 GMT Subject: Re: [PATCH 1/4] revision: make handle_dotdot() interface less confusing Message-ID: In-Reply-To: <20260326231415.GA420281@coredump.intra.peff.net> Jeff King writes: >> And once we accept that it is inevitable to make a copy, everything >> else falls into the right place. > > Yeah, I don't think there is another good option. We can drop the > "const" from the interface, which would be more honest, but then callers > that use string literals have to either make their own copy, or cast > away the constness and pray. > > The only "right" solution that avoids copying is if all of the > lower-level functions learned to work with ptr/len pairs instead of > NUL-terminated strings. But having done that sort of conversion before, > it ends up quite messy and is prone to errors. Somebody is welcome to > try tackling that if they want, but I don't. :) We would need to call out to a library function or system call eventually down the callchain, at which point you'd need to somehow come up with a NUL-terminated equivalent of that pair. So I would avoid going down that path, unless the language itself has already abstracted that difference away, and C is not among those languages.