| 303 | } |
| 304 | |
| 305 | static char *grab_blob(struct repository *r, |
| 306 | const struct object_id *oid, unsigned int mode, |
| 307 | unsigned long *size, struct userdiff_driver *textconv, |
| 308 | const char *path) |
| 309 | { |
| 310 | char *blob; |
| 311 | enum object_type type; |
| 312 | |
| 313 | if (S_ISGITLINK(mode)) { |
| 314 | struct strbuf buf = STRBUF_INIT; |
| 315 | strbuf_addf(&buf, "Subproject commit %s\n", oid_to_hex(oid)); |
| 316 | *size = buf.len; |
| 317 | blob = strbuf_detach(&buf, NULL); |
| 318 | } else if (is_null_oid(oid)) { |
| 319 | /* deleted blob */ |
| 320 | *size = 0; |
| 321 | return xcalloc(1, 1); |
| 322 | } else if (textconv) { |
| 323 | struct diff_filespec *df = alloc_filespec(path); |
| 324 | fill_filespec(df, oid, 1, mode); |
| 325 | *size = fill_textconv(r, textconv, df, &blob); |
| 326 | free_filespec(df); |
| 327 | } else { |
| 328 | size_t size_st = 0; |
| 329 | blob = odb_read_object(r->objects, oid, &type, &size_st); |
| 330 | *size = cast_size_t_to_ulong(size_st); |
| 331 | if (!blob) |
| 332 | die(_("unable to read %s"), oid_to_hex(oid)); |
| 333 | if (type != OBJ_BLOB) |
| 334 | die("object '%s' is not a blob!", oid_to_hex(oid)); |
| 335 | } |
| 336 | return blob; |
| 337 | } |
| 338 | |
| 339 | static void append_lost(struct sline *sline, int n, const char *line, int len) |
| 340 | { |
no test coverage detected