Subject: Re: [PATCH 1/4] ref-filter: factor out refname component counting

From: Junio C Hamano <[email-masked]>
Date: Thu, 19 Feb 2026 10:56:53 -0800

Jeff King <[email-masked]> writes:

>> And then p moves to the right until p[i] points at the end of the
>> string.  It does count the number of slashes in 'i', but there is no
>> satisfying simple answer to this question: "what does p mean while
>> this loop runs?".
>> ...
> Which made me wonder if I am missing some corner case, and it is not
> just counting slashes. But it must be, because "i" is never incremented
> except when we see a slash.
>
> +cc Karthik, the original author, for any wisdom, but the commit is now
> almost 10 years old.
>
> Is it worth rewriting to the "slashes" form above for clarity? I was
> afraid to touch it just to shut up Coverity, but now we have two
> confused people.

Yup, I think the answer to my "what does p mean?" question is "by
itself p has *no* meaning, but (p-refname) is maintained to be the
number of non-slash bytes we scanned so far, while i is the number
of slashes."

And from that point of view, your "count slashes in the most stupid
way that even 5 year old understands" certainly does make the result
far easier to read.

Thanks.