• J
    Fix prefix handling in ref iteration functions · b3cfc406
    Josh Triplett 提交于
    The do_for_each_ref iteration function accepts a prefix and a trim, and
    checks for the prefix on each ref before passing in that ref; it also
    supports trimming off part of the ref before passing it.  However,
    do_for_each_ref used trim as the length of the prefix to check, ignoring
    the actual length of the prefix.  Switch to using prefixcmp, checking
    the entire length of the prefix string, to properly support a trim value
    different than the length of the prefix.
    
    Several callers passed a prefix of "refs/" to filter out everything
    outside of refs/, but a trim of 0 to avoid trimming off the "refs/"; the
    trim of 0 meant that the filter of "refs/" no longer applied.  Change
    these callers to pass an empty prefix instead, to avoid changing the
    existing behavior.  Various callers count on this lack of filtering,
    such as receive-pack which uses add_extra_ref to add alternates as refs
    named ".have"; adding filtering would break that, causing
    t5501-fetch-push-alternates.sh to fail.  That lack of filtering doesn't
    currently have any other effect, since the loose ref functions can never
    supply refs outside of "refs/", and packed-refs will not normally
    include such refs unless manually edited.
    Signed-off-by: NJosh Triplett <josh@joshtriplett.org>
    Signed-off-by: NJamey Sharp <jamey@minilop.net>
    Signed-off-by: NJunio C Hamano <gitster@pobox.com>
    b3cfc406
refs.c 46.4 KB