From: Junio C Hamano Date: Sat, 04 Jan 2025 17:26:45 GMT Subject: Re: [PATCH v2 1/2] object-name: fix resolution of object names containing curly braces Message-ID: In-Reply-To: <13f68bebe90549ba19452f12abb6fea41c2517fb.1735949870.git.gitgitgadget@gmail.com> "Elijah Newren via GitGitGadget" writes: > for (cp = name, bracket_depth = 0; *cp; cp++) { > - if (*cp == '{') > + if (*(cp+1) == '{' && (*cp == '@' || *cp == '^')) { > + cp++; > bracket_depth++; Checking cp[1] before even knowing if cp[0] is the end of the string (hence cp[1] is an out of bounds access) smells fishy. If it were something like ... if (cp[0] && strchr("@^", cp[0]) && cp[1] == '{') ... it may be a bit more palatable, perhaps? At least writing it this way we can easily scale when we find the third character we need to special case, hopefully, but again, I do prefer if we can find a solution that does not have such an intimate knowledge about "@^", which I just failed to do here X-<. Thanks.