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

Function write_archive_entries

archive.c:305–381  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

303};
304
305int write_archive_entries(struct archiver_args *args,
306 write_archive_entry_fn_t write_entry)
307{
308 struct archiver_context context;
309 int err;
310 struct strbuf path_in_archive = STRBUF_INIT;
311 struct strbuf content = STRBUF_INIT;
312 struct object_id fake_oid;
313 int i;
314
315 oidcpy(&fake_oid, null_oid(the_hash_algo));
316
317 if (args->baselen > 0 && args->base[args->baselen - 1] == '/') {
318 size_t len = args->baselen;
319
320 while (len > 1 && args->base[len - 2] == '/')
321 len--;
322 if (args->verbose)
323 fprintf(stderr, "%.*s\n", (int)len, args->base);
324 err = write_entry(args, &args->tree->object.oid, args->base,
325 len, 040777, NULL, 0);
326 if (err)
327 return err;
328 }
329
330 memset(&context, 0, sizeof(context));
331 context.args = args;
332 context.write_entry = write_entry;
333
334 err = read_tree(args->repo, args->tree,
335 &args->pathspec,
336 queue_or_write_archive_entry,
337 &context);
338 if (err == READ_TREE_RECURSIVE)
339 err = 0;
340 while (context.bottom) {
341 struct directory *next = context.bottom->up;
342 free(context.bottom);
343 context.bottom = next;
344 }
345
346 for (i = 0; i < args->extra_files.nr; i++) {
347 struct string_list_item *item = args->extra_files.items + i;
348 char *path = item->string;
349 struct extra_file_info *info = item->util;
350
351 put_be64(fake_oid.hash, i + 1);
352
353 if (!info->content) {
354 strbuf_reset(&path_in_archive);
355 if (info->base)
356 strbuf_addstr(&path_in_archive, info->base);
357 strbuf_addstr(&path_in_archive, basename(path));
358
359 strbuf_reset(&content);
360 if (strbuf_read_file(&content, path, info->stat.st_size) < 0)
361 err = error_errno(_("cannot read '%s'"), path);
362 else

Callers 2

write_zip_archiveFunction · 0.85
write_tar_archiveFunction · 0.85

Calls 10

oidcpyFunction · 0.85
null_oidFunction · 0.85
write_entryFunction · 0.85
read_treeFunction · 0.85
put_be64Function · 0.85
strbuf_addstrFunction · 0.85
strbuf_read_fileFunction · 0.85
error_errnoFunction · 0.85
canon_modeFunction · 0.85
strbuf_releaseFunction · 0.85

Tested by

no test coverage detected