* Validates and send requested info back to the client. Any errors detected * are returned as they are detected. */
| 35 | * are returned as they are detected. |
| 36 | */ |
| 37 | static void send_info(struct repository *r, struct packet_writer *writer, |
| 38 | struct string_list *oid_str_list, |
| 39 | struct requested_info *info) |
| 40 | { |
| 41 | struct string_list_item *item; |
| 42 | struct strbuf send_buffer = STRBUF_INIT; |
| 43 | |
| 44 | if (!oid_str_list->nr) |
| 45 | return; |
| 46 | |
| 47 | if (info->size) |
| 48 | packet_writer_write(writer, "size"); |
| 49 | |
| 50 | for_each_string_list_item (item, oid_str_list) { |
| 51 | const char *oid_str = item->string; |
| 52 | struct object_id oid; |
| 53 | size_t object_size; |
| 54 | |
| 55 | if (get_oid_hex_algop(oid_str, &oid, r->hash_algo) < 0) { |
| 56 | packet_writer_error( |
| 57 | writer, |
| 58 | "object-info: protocol error, expected to get oid, not '%s'", |
| 59 | oid_str); |
| 60 | continue; |
| 61 | } |
| 62 | |
| 63 | strbuf_addstr(&send_buffer, oid_str); |
| 64 | |
| 65 | if (info->size) { |
| 66 | if (odb_read_object_info(r->objects, &oid, &object_size) < 0) { |
| 67 | strbuf_addstr(&send_buffer, " "); |
| 68 | } else { |
| 69 | strbuf_addf(&send_buffer, " %"PRIuMAX, |
| 70 | (uintmax_t)object_size); |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | packet_writer_write(writer, "%s", send_buffer.buf); |
| 75 | strbuf_reset(&send_buffer); |
| 76 | } |
| 77 | strbuf_release(&send_buffer); |
| 78 | } |
| 79 | |
| 80 | int cap_object_info(struct repository *r, struct packet_reader *request) |
| 81 | { |
no test coverage detected