From: Junio C Hamano Date: Thu, 02 Jun 2011 23:29:00 GMT Subject: Re: [PATCHv4 1/4] Refactor for_each_ref variants to use for_each_ref_in and avoid magic numbers Message-ID: <7v4o47dd8j.fsf@alter.siamese.dyndns.org> In-Reply-To: <20110602205747.GA2022@leaf> Josh Triplett writes: >> Shouldn't you be passing prefix and trim the same way as we have always >> done, but just fixing the strncmp() at the beginning of do_one_ref()? > > I still think prefixcmp makes the most sense; if you pass a given base, Using prefixcmp() instead of strncmp() there is what I meant by "fixing the strncmp() at the beginning of do_one_ref()", so we are in agreement on that point. What I found questionable was the removal of the trim value. IOW, I would have expected the patch to be something like: if (prefixcmp(base, entry->name)) return 0; /* outside of our area -- ignore */ ... some other logic ... /* feed the callback, stripping the prefix */ return fn(entry->name + trim, entry->sha1, entry->flag, cb_data);