get_fetch_map(): tighten checks on dest refs

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>

Junio C Hamano committed May 4, 2012 at 15:35 UTC 5c08c1f23ad512fbcd06f4ee9bcf8818e17a2627
1 file changed +2 -2
remote.c
+2 -2
@@ -1402,8 +1402,8 @@ int get_fetch_map(const struct ref *remote_refs,
1402
1403 for (rmp = &ref_map; *rmp; ) {
1404 if ((*rmp)->peer_ref) {
1405 - if (check_refname_format((*rmp)->peer_ref->name + 5,
1406 - REFNAME_ALLOW_ONELEVEL)) {
1405 + if (prefixcmp((*rmp)->peer_ref->name, "refs/") ||
1406 + check_refname_format((*rmp)->peer_ref->name, 0)) {
1407 struct ref *ignore = *rmp;
1408 error("* Ignoring funny ref '%s' locally",
1409 (*rmp)->peer_ref->name);