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

Function parse_ident

builtin/fast-import.c:2001–2047  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1999}
2000
2001static char *parse_ident(const char *buf)
2002{
2003 const char *ltgt;
2004 size_t name_len;
2005 struct strbuf ident = STRBUF_INIT;
2006
2007 /* ensure there is a space delimiter even if there is no name */
2008 if (*buf == '<')
2009 --buf;
2010
2011 ltgt = buf + strcspn(buf, "<>");
2012 if (*ltgt != '<')
2013 die(_("missing < in ident string: %s"), buf);
2014 if (ltgt != buf && ltgt[-1] != ' ')
2015 die(_("missing space before < in ident string: %s"), buf);
2016 ltgt = ltgt + 1 + strcspn(ltgt + 1, "<>");
2017 if (*ltgt != '>')
2018 die(_("missing > in ident string: %s"), buf);
2019 ltgt++;
2020 if (*ltgt != ' ')
2021 die(_("missing space after > in ident string: %s"), buf);
2022 ltgt++;
2023 name_len = ltgt - buf;
2024 strbuf_add(&ident, buf, name_len);
2025
2026 switch (whenspec) {
2027 case WHENSPEC_RAW:
2028 if (validate_raw_date(ltgt, &ident, 1) < 0)
2029 die(_("invalid raw date \"%s\" in ident: %s"), ltgt, buf);
2030 break;
2031 case WHENSPEC_RAW_PERMISSIVE:
2032 if (validate_raw_date(ltgt, &ident, 0) < 0)
2033 die(_("invalid raw date \"%s\" in ident: %s"), ltgt, buf);
2034 break;
2035 case WHENSPEC_RFC2822:
2036 if (parse_date(ltgt, &ident) < 0)
2037 die(_("invalid rfc2822 date \"%s\" in ident: %s"), ltgt, buf);
2038 break;
2039 case WHENSPEC_NOW:
2040 if (strcmp("now", ltgt))
2041 die(_("date in ident must be 'now': %s"), buf);
2042 datestamp(&ident);
2043 break;
2044 }
2045
2046 return strbuf_detach(&ident, NULL);
2047}
2048
2049static void parse_and_store_blob(
2050 struct last_object *last,

Callers 2

parse_new_commitFunction · 0.70
parse_new_tagFunction · 0.70

Calls 6

strbuf_addFunction · 0.85
validate_raw_dateFunction · 0.85
parse_dateFunction · 0.85
datestampFunction · 0.85
strbuf_detachFunction · 0.85
dieFunction · 0.50

Tested by

no test coverage detected