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

Function format_commit_one

pretty.c:1437–1800  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1435}
1436
1437static size_t format_commit_one(struct strbuf *sb, /* in UTF-8 */
1438 const char *placeholder,
1439 void *context)
1440{
1441 struct format_commit_context *c = context;
1442 const struct commit *commit = c->commit;
1443 const char *msg = c->message;
1444 struct commit_list *p;
1445 const char *arg, *eol;
1446 size_t res;
1447 char **slot;
1448
1449 /* these are independent of the commit */
1450 res = strbuf_expand_literal(sb, placeholder);
1451 if (res)
1452 return res;
1453
1454 switch (placeholder[0]) {
1455 case 'C':
1456 if (starts_with(placeholder + 1, "(auto)")) {
1457 c->auto_color = c->pretty_ctx->color;
1458 if (want_color(c->auto_color) && sb->len)
1459 strbuf_addstr(sb, GIT_COLOR_RESET);
1460 return 7; /* consumed 7 bytes, "C(auto)" */
1461 } else {
1462 int ret = parse_color(sb, placeholder, c);
1463 if (ret)
1464 c->auto_color = GIT_COLOR_NEVER;
1465 /*
1466 * Otherwise, we decided to treat %C<unknown>
1467 * as a literal string, and the previous
1468 * %C(auto) is still valid.
1469 */
1470 return ret;
1471 }
1472 case 'w':
1473 if (placeholder[1] == '(') {
1474 unsigned long width = 0, indent1 = 0, indent2 = 0;
1475 char *next;
1476 const char *start = placeholder + 2;
1477 const char *end = strchr(start, ')');
1478 if (!end)
1479 return 0;
1480 if (end > start) {
1481 width = strtoul(start, &next, 10);
1482 if (*next == ',') {
1483 indent1 = strtoul(next + 1, &next, 10);
1484 if (*next == ',') {
1485 indent2 = strtoul(next + 1,
1486 &next, 10);
1487 }
1488 }
1489 if (*next != ')')
1490 return 0;
1491 }
1492
1493 /*
1494 * We need to limit the format here as it allows the

Callers 2

format_and_pad_commitFunction · 0.85
format_commit_itemFunction · 0.85

Calls 15

strbuf_expand_literalFunction · 0.85
starts_withFunction · 0.85
strbuf_addstrFunction · 0.85
rewrap_message_tailFunction · 0.85
strvec_pushFunction · 0.85
parse_describe_argsFunction · 0.85
child_process_clearFunction · 0.85
oid_to_hexFunction · 0.85
pipe_commandFunction · 0.85
strbuf_rtrimFunction · 0.85
strbuf_addbufFunction · 0.85

Tested by

no test coverage detected