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

Function parse_refname

builtin/update-ref.c:68–90  ·  view source on GitHub ↗

* Parse the reference name immediately after "command SP". If not * -z, then handle C-quoting. Return a pointer to a newly allocated * string containing the name of the reference, or NULL if there was * an error. Update *next to point at the character that terminates * the argument. Die if C-quoting is malformed or the reference name * is invalid. */

Source from the content-addressed store, hash-verified

66 * is invalid.
67 */
68static char *parse_refname(const char **next)
69{
70 struct strbuf ref = STRBUF_INIT;
71
72 if (line_termination) {
73 /* Without -z, use the next argument */
74 *next = parse_arg(*next, &ref);
75 } else {
76 /* With -z, use everything up to the next NUL */
77 strbuf_addstr(&ref, *next);
78 *next += ref.len;
79 }
80
81 if (!ref.len) {
82 strbuf_release(&ref);
83 return NULL;
84 }
85
86 if (check_refname_format(ref.buf, REFNAME_ALLOW_ONELEVEL))
87 die("invalid ref format: %s", ref.buf);
88
89 return strbuf_detach(&ref, NULL);
90}
91
92/*
93 * Wrapper around parse_refname which skips the next delimiter.

Callers 9

parse_next_refnameFunction · 0.85
parse_cmd_updateFunction · 0.85
parse_cmd_symref_updateFunction · 0.85
parse_cmd_createFunction · 0.85
parse_cmd_symref_createFunction · 0.85
parse_cmd_deleteFunction · 0.85
parse_cmd_symref_deleteFunction · 0.85
parse_cmd_verifyFunction · 0.85
parse_cmd_symref_verifyFunction · 0.85

Calls 6

parse_argFunction · 0.85
strbuf_addstrFunction · 0.85
strbuf_releaseFunction · 0.85
check_refname_formatFunction · 0.85
strbuf_detachFunction · 0.85
dieFunction · 0.50

Tested by

no test coverage detected