* Wrapper around parse_arg which skips the next delimiter. */
| 115 | * Wrapper around parse_arg which skips the next delimiter. |
| 116 | */ |
| 117 | static 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 |
no test coverage detected