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

Function parse_next_arg

builtin/update-ref.c:117–149  ·  view source on GitHub ↗

* Wrapper around parse_arg which skips the next delimiter. */

Source from the content-addressed store, hash-verified

115 * Wrapper around parse_arg which skips the next delimiter.
116 */
117static char *parse_next_arg(const char **next)
118{
119 struct strbuf arg = STRBUF_INIT;
120
121 if (line_termination) {
122 /* Without -z, consume SP and use next argument */
123 if (!**next || **next == line_termination)
124 return NULL;
125 if (**next != ' ')
126 die("expected SP but got: %s", *next);
127 } else {
128 /* With -z, read the next NUL-terminated line */
129 if (**next)
130 return NULL;
131 }
132 /* Skip the delimiter */
133 (*next)++;
134
135 if (line_termination) {
136 /* Without -z, use the next argument */
137 *next = parse_arg(*next, &arg);
138 } else {
139 /* With -z, use everything up to the next NUL */
140 strbuf_addstr(&arg, *next);
141 *next += arg.len;
142 }
143
144 if (arg.len)
145 return strbuf_detach(&arg, NULL);
146
147 strbuf_release(&arg);
148 return NULL;
149}
150
151/*
152 * The value being parsed is <old-oid> (as opposed to <new-oid>; the

Callers 1

parse_cmd_symref_updateFunction · 0.85

Calls 5

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

Tested by

no test coverage detected