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

Function stdin_packs_read_input

builtin/pack-objects.c:3984–4069  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3982}
3983
3984static void stdin_packs_read_input(struct rev_info *revs,
3985 enum stdin_packs_mode mode)
3986{
3987 struct strbuf buf = STRBUF_INIT;
3988 struct strmap packs = STRMAP_INIT;
3989 struct packed_git *p;
3990
3991 while (strbuf_getline(&buf, stdin) != EOF) {
3992 struct stdin_pack_info *info;
3993 enum stdin_pack_info_kind kind = STDIN_PACK_INCLUDE;
3994 const char *key = buf.buf;
3995
3996 if (!*key)
3997 continue;
3998 else if (*key == '^')
3999 kind = STDIN_PACK_EXCLUDE_CLOSED;
4000 else if (*key == '!' && mode == STDIN_PACKS_MODE_FOLLOW)
4001 kind = STDIN_PACK_EXCLUDE_OPEN;
4002
4003 if (kind != STDIN_PACK_INCLUDE)
4004 key++;
4005
4006 info = strmap_get(&packs, key);
4007 if (!info) {
4008 CALLOC_ARRAY(info, 1);
4009 strmap_put(&packs, key, info);
4010 }
4011
4012 info->kind |= kind;
4013
4014 strbuf_reset(&buf);
4015 }
4016
4017 repo_for_each_pack(the_repository, p) {
4018 struct stdin_pack_info *info;
4019
4020 info = strmap_get(&packs, pack_basename(p));
4021 if (!info)
4022 continue;
4023
4024 if (info->kind & STDIN_PACK_INCLUDE) {
4025 if (exclude_promisor_objects && p->pack_promisor)
4026 die(_("packfile %s is a promisor but --exclude-promisor-objects was given"), p->pack_name);
4027
4028 /*
4029 * Arguments we got on stdin may not even be
4030 * packs. First check that to avoid segfaulting
4031 * later on in e.g. pack_mtime_cmp(), excluded
4032 * packs are handled below.
4033 */
4034 if (!is_pack_valid(p))
4035 die(_("packfile %s cannot be accessed"), p->pack_name);
4036 }
4037
4038 if (info->kind & STDIN_PACK_EXCLUDE_CLOSED) {
4039 /*
4040 * Marking excluded packs as kept in-core so
4041 * that later calls to add_object_entry()

Callers 1

read_stdin_packsFunction · 0.85

Calls 9

strbuf_getlineFunction · 0.85
strmap_getFunction · 0.85
strmap_putFunction · 0.85
pack_basenameFunction · 0.85
is_pack_validFunction · 0.85
strbuf_releaseFunction · 0.85
strmap_clearFunction · 0.85
dieFunction · 0.50

Tested by

no test coverage detected