MCPcopy Index your code
hub / github.com/git/git / interpret_branch_mark

Function interpret_branch_mark

object-name.c:1428–1470  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1426}
1427
1428static 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
1472int repo_interpret_branch_name(struct repository *r,
1473 const char *name, int namelen,

Callers 1

Calls 7

xmemdupzFunction · 0.85
branch_getFunction · 0.85
get_dataFunction · 0.85
strbuf_releaseFunction · 0.85
branch_interpret_allowedFunction · 0.85
set_shortened_refFunction · 0.85
dieFunction · 0.70

Tested by

no test coverage detected