MCPcopy Index your code
hub / github.com/git/git / grab_blob

Function grab_blob

combine-diff.c:305–337  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

303}
304
305static 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
339static void append_lost(struct sline *sline, int n, const char *line, int len)
340{

Callers 2

combine_diffFunction · 0.85
show_patch_diffFunction · 0.85

Calls 12

strbuf_addfFunction · 0.85
oid_to_hexFunction · 0.85
strbuf_detachFunction · 0.85
is_null_oidFunction · 0.85
xcallocFunction · 0.85
alloc_filespecFunction · 0.85
fill_filespecFunction · 0.85
fill_textconvFunction · 0.85
free_filespecFunction · 0.85
odb_read_objectFunction · 0.85
cast_size_t_to_ulongFunction · 0.85
dieFunction · 0.70

Tested by

no test coverage detected