* 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. */
| 66 | * is invalid. |
| 67 | */ |
| 68 | static 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. |
no test coverage detected