| 1248 | } |
| 1249 | |
| 1250 | static int match_explicit(struct ref *src, struct ref *dst, |
| 1251 | struct ref ***dst_tail, |
| 1252 | struct refspec_item *rs) |
| 1253 | { |
| 1254 | struct ref *matched_src = NULL, *matched_dst = NULL; |
| 1255 | int allocated_src = 0, ret; |
| 1256 | |
| 1257 | const char *dst_value = rs->dst; |
| 1258 | char *dst_guess; |
| 1259 | |
| 1260 | if (rs->pattern || rs->matching || rs->negative) { |
| 1261 | ret = 0; |
| 1262 | goto out; |
| 1263 | } |
| 1264 | |
| 1265 | if (match_explicit_lhs(src, rs, &matched_src, &allocated_src) < 0) { |
| 1266 | ret = -1; |
| 1267 | goto out; |
| 1268 | } |
| 1269 | |
| 1270 | if (!dst_value) { |
| 1271 | int flag; |
| 1272 | |
| 1273 | dst_value = refs_resolve_ref_unsafe(get_main_ref_store(the_repository), |
| 1274 | matched_src->name, |
| 1275 | RESOLVE_REF_READING, |
| 1276 | NULL, &flag); |
| 1277 | if (!dst_value || |
| 1278 | ((flag & REF_ISSYMREF) && |
| 1279 | !starts_with(dst_value, "refs/heads/"))) |
| 1280 | die(_("%s cannot be resolved to branch"), |
| 1281 | matched_src->name); |
| 1282 | } |
| 1283 | |
| 1284 | switch (count_refspec_match(dst_value, dst, &matched_dst)) { |
| 1285 | case 1: |
| 1286 | break; |
| 1287 | case 0: |
| 1288 | if (starts_with(dst_value, "refs/")) { |
| 1289 | matched_dst = make_linked_ref(dst_value, dst_tail); |
| 1290 | } else if (is_null_oid(&matched_src->new_oid)) { |
| 1291 | error(_("unable to delete '%s': remote ref does not exist"), |
| 1292 | dst_value); |
| 1293 | } else if ((dst_guess = guess_ref(dst_value, matched_src))) { |
| 1294 | matched_dst = make_linked_ref(dst_guess, dst_tail); |
| 1295 | free(dst_guess); |
| 1296 | } else { |
| 1297 | show_push_unqualified_ref_name_error(dst_value, |
| 1298 | matched_src->name); |
| 1299 | } |
| 1300 | break; |
| 1301 | default: |
| 1302 | matched_dst = NULL; |
| 1303 | error(_("dst refspec %s matches more than one"), |
| 1304 | dst_value); |
| 1305 | break; |
| 1306 | } |
| 1307 |
no test coverage detected