| 162 | } |
| 163 | |
| 164 | static int receive_status(struct repository *r, |
| 165 | struct packet_reader *reader, struct ref *refs) |
| 166 | { |
| 167 | struct ref *hint; |
| 168 | int ret; |
| 169 | struct ref_push_report *report = NULL; |
| 170 | int new_report = 0; |
| 171 | int once = 0; |
| 172 | |
| 173 | trace2_region_enter("send_pack", "receive_status", r); |
| 174 | hint = NULL; |
| 175 | ret = receive_unpack_status(reader); |
| 176 | while (1) { |
| 177 | struct object_id old_oid, new_oid; |
| 178 | char *head; |
| 179 | char *refname; |
| 180 | char *p; |
| 181 | if (packet_reader_read(reader) != PACKET_READ_NORMAL) |
| 182 | break; |
| 183 | head = reader->line; |
| 184 | p = strchr(head, ' '); |
| 185 | if (!p) { |
| 186 | error("invalid status line from remote: %s", reader->line); |
| 187 | ret = -1; |
| 188 | break; |
| 189 | } |
| 190 | *p++ = '\0'; |
| 191 | |
| 192 | if (!strcmp(head, "option")) { |
| 193 | char *key; |
| 194 | const char *val; |
| 195 | |
| 196 | if (!hint || !(report || new_report)) { |
| 197 | if (!once++) |
| 198 | error("'option' without a matching 'ok/ng' directive"); |
| 199 | ret = -1; |
| 200 | continue; |
| 201 | } |
| 202 | if (new_report) { |
| 203 | if (!hint->report) { |
| 204 | CALLOC_ARRAY(hint->report, 1); |
| 205 | report = hint->report; |
| 206 | } else { |
| 207 | report = hint->report; |
| 208 | while (report->next) |
| 209 | report = report->next; |
| 210 | CALLOC_ARRAY(report->next, 1); |
| 211 | report = report->next; |
| 212 | } |
| 213 | new_report = 0; |
| 214 | } |
| 215 | key = p; |
| 216 | p = strchr(key, ' '); |
| 217 | if (p) |
| 218 | *p++ = '\0'; |
| 219 | val = p; |
| 220 | if (!strcmp(key, "refname")) |
| 221 | report->ref_name = xstrdup_or_null(val); |
no test coverage detected