Move refspec pattern matching to match_refs().