| 1426 | } |
| 1427 | |
| 1428 | static int interpret_branch_mark(struct repository *r, |
| 1429 | const char *name, int namelen, |
| 1430 | int at, struct strbuf *buf, |
| 1431 | int (*get_mark)(const char *, int), |
| 1432 | const char *(*get_data)(struct branch *, |
| 1433 | struct strbuf *), |
| 1434 | const struct interpret_branch_name_options *options) |
| 1435 | { |
| 1436 | int len; |
| 1437 | struct branch *branch; |
| 1438 | struct strbuf err = STRBUF_INIT; |
| 1439 | const char *value; |
| 1440 | |
| 1441 | len = get_mark(name + at, namelen - at); |
| 1442 | if (!len) |
| 1443 | return -1; |
| 1444 | |
| 1445 | if (memchr(name, ':', at)) |
| 1446 | return -1; |
| 1447 | |
| 1448 | if (at) { |
| 1449 | char *name_str = xmemdupz(name, at); |
| 1450 | branch = branch_get(name_str); |
| 1451 | free(name_str); |
| 1452 | } else |
| 1453 | branch = branch_get(NULL); |
| 1454 | |
| 1455 | value = get_data(branch, &err); |
| 1456 | if (!value) { |
| 1457 | if (options->nonfatal_dangling_mark) { |
| 1458 | strbuf_release(&err); |
| 1459 | return -1; |
| 1460 | } else { |
| 1461 | die("%s", err.buf); |
| 1462 | } |
| 1463 | } |
| 1464 | |
| 1465 | if (!branch_interpret_allowed(value, options->allowed)) |
| 1466 | return -1; |
| 1467 | |
| 1468 | set_shortened_ref(r, buf, value); |
| 1469 | return len + at; |
| 1470 | } |
| 1471 | |
| 1472 | int repo_interpret_branch_name(struct repository *r, |
| 1473 | const char *name, int namelen, |
no test coverage detected