MCPcopy Create free account
hub / github.com/git/git / fmt_ident

Function fmt_ident

ident.c:456–542  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

454}
455
456const char *fmt_ident(const char *name, const char *email,
457 enum want_ident whose_ident, const char *date_str, int flag)
458{
459 static int index;
460 static struct strbuf ident_pool[2] = { STRBUF_INIT, STRBUF_INIT };
461 int strict = (flag & IDENT_STRICT);
462 int want_date = !(flag & IDENT_NO_DATE);
463 int want_name = !(flag & IDENT_NO_NAME);
464
465 struct strbuf *ident = &ident_pool[index];
466 index = (index + 1) % ARRAY_SIZE(ident_pool);
467
468 if (!email) {
469 if (whose_ident == WANT_AUTHOR_IDENT && git_author_email.len)
470 email = git_author_email.buf;
471 else if (whose_ident == WANT_COMMITTER_IDENT && git_committer_email.len)
472 email = git_committer_email.buf;
473 }
474 if (!email) {
475 if (strict && ident_use_config_only
476 && !(ident_config_given & IDENT_MAIL_GIVEN)) {
477 ident_env_hint(whose_ident);
478 die(_("no email was given and auto-detection is disabled"));
479 }
480 email = ident_default_email();
481 if (strict && default_email_is_bogus) {
482 ident_env_hint(whose_ident);
483 die(_("unable to auto-detect email address (got '%s')"), email);
484 }
485 }
486
487 if (want_name) {
488 int using_default = 0;
489 if (!name) {
490 if (whose_ident == WANT_AUTHOR_IDENT && git_author_name.len)
491 name = git_author_name.buf;
492 else if (whose_ident == WANT_COMMITTER_IDENT &&
493 git_committer_name.len)
494 name = git_committer_name.buf;
495 }
496 if (!name) {
497 if (strict && ident_use_config_only
498 && !(ident_config_given & IDENT_NAME_GIVEN)) {
499 ident_env_hint(whose_ident);
500 die(_("no name was given and auto-detection is disabled"));
501 }
502 name = ident_default_name();
503 using_default = 1;
504 if (strict && default_name_is_bogus) {
505 ident_env_hint(whose_ident);
506 die(_("unable to auto-detect name (got '%s')"), name);
507 }
508 }
509 if (!*name) {
510 struct passwd *pw;
511 if (strict) {
512 if (using_default)
513 ident_env_hint(whose_ident);

Callers 11

fake_working_tree_commitFunction · 0.85
fmt_nameFunction · 0.85
git_author_infoFunction · 0.85
git_committer_infoFunction · 0.85
try_to_commitFunction · 0.85
migrate_one_reflog_entryFunction · 0.85
yield_log_recordFunction · 0.85
do_commitFunction · 0.85
do_export_stashFunction · 0.85
rename_one_reflog_entryFunction · 0.85
determine_author_infoFunction · 0.85

Calls 11

ident_env_hintFunction · 0.85
ident_default_emailFunction · 0.85
ident_default_nameFunction · 0.85
xgetpwuid_selfFunction · 0.85
has_non_crudFunction · 0.85
strbuf_addstrFunction · 0.85
strbuf_addchFunction · 0.85
parse_dateFunction · 0.85
ident_default_dateFunction · 0.85
dieFunction · 0.70

Tested by

no test coverage detected