| 1358 | } |
| 1359 | |
| 1360 | static int transaction_refname_valid(const char *refname, |
| 1361 | const struct object_id *new_oid, |
| 1362 | unsigned int flags, struct strbuf *err) |
| 1363 | { |
| 1364 | if (flags & REF_SKIP_REFNAME_VERIFICATION) |
| 1365 | return 1; |
| 1366 | |
| 1367 | if (is_pseudo_ref(refname)) { |
| 1368 | const char *refusal_msg; |
| 1369 | if (flags & REF_LOG_ONLY) |
| 1370 | refusal_msg = _("refusing to update reflog for pseudoref '%s'"); |
| 1371 | else |
| 1372 | refusal_msg = _("refusing to update pseudoref '%s'"); |
| 1373 | strbuf_addf(err, refusal_msg, refname); |
| 1374 | return 0; |
| 1375 | } else if ((new_oid && !is_null_oid(new_oid)) ? |
| 1376 | check_refname_format(refname, REFNAME_ALLOW_ONELEVEL) : |
| 1377 | !refname_is_safe(refname)) { |
| 1378 | const char *refusal_msg; |
| 1379 | if (flags & REF_LOG_ONLY) |
| 1380 | refusal_msg = _("refusing to update reflog with bad name '%s'"); |
| 1381 | else |
| 1382 | refusal_msg = _("refusing to update ref with bad name '%s'"); |
| 1383 | strbuf_addf(err, refusal_msg, refname); |
| 1384 | return 0; |
| 1385 | } |
| 1386 | |
| 1387 | return 1; |
| 1388 | } |
| 1389 | |
| 1390 | enum ref_transaction_error ref_transaction_update(struct ref_transaction *transaction, |
| 1391 | const char *refname, |
no test coverage detected