get_fetch_map(): tighten checks on dest refs
authorJunio C Hamano <gitster@pobox.com>
Fri, 4 May 2012 22:35:18 +0000 (15:35 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 19 Oct 2012 23:12:45 +0000 (16:12 -0700)
The code to check the refname we store the fetched result locally did not
bother checking the first 5 bytes of it, presumably assuming that it
always begin with "refs/".  For a fetch refspec (or the result of applying
wildcard on one), we always want the RHS to map to something inside
"refs/" hierarchy, so let's spell that rule out in a more explicit way.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
remote.c

index e2ef99114478c49863809ea5cef46392a5a8c0e9..044f22992900ff97ecadff2a1951dbe0e188e87f 100644 (file)
--- a/remote.c
+++ b/remote.c
@@ -1402,8 +1402,8 @@ int get_fetch_map(const struct ref *remote_refs,
 
        for (rmp = &ref_map; *rmp; ) {
                if ((*rmp)->peer_ref) {
-                       if (check_refname_format((*rmp)->peer_ref->name + 5,
-                               REFNAME_ALLOW_ONELEVEL)) {
+                       if (prefixcmp((*rmp)->peer_ref->name, "refs/") ||
+                           check_refname_format((*rmp)->peer_ref->name, 0)) {
                                struct ref *ignore = *rmp;
                                error("* Ignoring funny ref '%s' locally",
                                      (*rmp)->peer_ref->name);