MCPcopy Create free account
hub / github.com/git/git / export_blob

Function export_blob

builtin/fast-export.c:297–351  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

295}
296
297static void export_blob(const struct object_id *oid)
298{
299 unsigned long size;
300 enum object_type type;
301 char *buf;
302 struct object *object;
303 int eaten;
304
305 if (no_data)
306 return;
307
308 if (is_null_oid(oid))
309 return;
310
311 object = lookup_object(the_repository, oid);
312 if (object && object->flags & SHOWN)
313 return;
314
315 if (anonymize) {
316 buf = anonymize_blob(&size);
317 object = (struct object *)lookup_blob(the_repository, oid);
318 eaten = 0;
319 } else {
320 size_t size_st = 0;
321 buf = odb_read_object(the_repository->objects, oid, &type,
322 &size_st);
323 size = cast_size_t_to_ulong(size_st);
324 if (!buf)
325 die(_("could not read blob %s"), oid_to_hex(oid));
326 if (check_object_signature(the_repository, oid, buf, size,
327 type) < 0)
328 die(_("oid mismatch in blob %s"), oid_to_hex(oid));
329 object = parse_object_buffer(the_repository, oid, type,
330 size, buf, &eaten);
331 }
332
333 if (!object)
334 die(_("could not read blob %s"), oid_to_hex(oid));
335
336 mark_next_object(object);
337
338 printf("blob\nmark :%"PRIu32"\n", last_idnum);
339 if (show_original_ids)
340 printf("original-oid %s\n", oid_to_hex(oid));
341 printf("data %"PRIuMAX"\n", (uintmax_t)size);
342 if (size && fwrite(buf, size, 1, stdout) != 1)
343 die_errno(_("could not write blob '%s'"), oid_to_hex(oid));
344 printf("\n");
345
346 show_progress();
347
348 object->flags |= SHOWN;
349 if (!eaten)
350 free(buf);
351}
352
353static int depth_first(const void *a_, const void *b_)
354{

Callers 2

handle_commitFunction · 0.85
get_tags_and_duplicatesFunction · 0.85

Calls 13

is_null_oidFunction · 0.85
lookup_objectFunction · 0.85
anonymize_blobFunction · 0.85
lookup_blobFunction · 0.85
odb_read_objectFunction · 0.85
cast_size_t_to_ulongFunction · 0.85
oid_to_hexFunction · 0.85
check_object_signatureFunction · 0.85
parse_object_bufferFunction · 0.85
mark_next_objectFunction · 0.85
die_errnoFunction · 0.85
show_progressFunction · 0.85

Tested by

no test coverage detected