diff options
Diffstat (limited to 'fetch-pack.c')
-rw-r--r-- | fetch-pack.c | 64 |
1 files changed, 41 insertions, 23 deletions
diff --git a/fetch-pack.c b/fetch-pack.c index 42c62fc..e450377 100644 --- a/fetch-pack.c +++ b/fetch-pack.c @@ -116,11 +116,12 @@ static void for_each_cached_alternate(struct fetch_negotiator *negotiator, cb(negotiator, cache.items[i]); } -static struct commit *deref_without_lazy_fetch(const struct object_id *oid, - int mark_tags_complete) +static struct commit *deref_without_lazy_fetch_extended(const struct object_id *oid, + int mark_tags_complete, + enum object_type *type, + unsigned int oi_flags) { - enum object_type type; - struct object_info info = { .typep = &type }; + struct object_info info = { .typep = type }; struct commit *commit; commit = lookup_commit_in_graph(the_repository, oid); @@ -129,9 +130,9 @@ static struct commit *deref_without_lazy_fetch(const struct object_id *oid, while (1) { if (oid_object_info_extended(the_repository, oid, &info, - OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_QUICK)) + oi_flags)) return NULL; - if (type == OBJ_TAG) { + if (*type == OBJ_TAG) { struct tag *tag = (struct tag *) parse_object(the_repository, oid); @@ -145,7 +146,7 @@ static struct commit *deref_without_lazy_fetch(const struct object_id *oid, } } - if (type == OBJ_COMMIT) { + if (*type == OBJ_COMMIT) { struct commit *commit = lookup_commit(the_repository, oid); if (!commit || repo_parse_commit(the_repository, commit)) return NULL; @@ -155,6 +156,16 @@ static struct commit *deref_without_lazy_fetch(const struct object_id *oid, return NULL; } + +static struct commit *deref_without_lazy_fetch(const struct object_id *oid, + int mark_tags_complete) +{ + enum object_type type; + unsigned flags = OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_QUICK; + return deref_without_lazy_fetch_extended(oid, mark_tags_complete, + &type, flags); +} + static int rev_list_insert_ref(struct fetch_negotiator *negotiator, const struct object_id *oid) { @@ -837,6 +848,16 @@ static void parse_gitmodules_oids(int fd, struct oidset *gitmodules_oids) } while (1); } +static void add_index_pack_keep_option(struct strvec *args) +{ + char hostname[HOST_NAME_MAX + 1]; + + if (xgethostname(hostname, sizeof(hostname))) + xsnprintf(hostname, sizeof(hostname), "localhost"); + strvec_pushf(args, "--keep=fetch-pack %"PRIuMAX " on %s", + (uintmax_t)getpid(), hostname); +} + /* * If packfile URIs were provided, pass a non-NULL pointer to index_pack_args. * The strings to pass as the --index-pack-arg arguments to http-fetch will be @@ -906,14 +927,8 @@ static int get_pack(struct fetch_pack_args *args, strvec_push(&cmd.args, "-v"); if (args->use_thin_pack) strvec_push(&cmd.args, "--fix-thin"); - if ((do_keep || index_pack_args) && (args->lock_pack || unpack_limit)) { - char hostname[HOST_NAME_MAX + 1]; - if (xgethostname(hostname, sizeof(hostname))) - xsnprintf(hostname, sizeof(hostname), "localhost"); - strvec_pushf(&cmd.args, - "--keep=fetch-pack %"PRIuMAX " on %s", - (uintmax_t)getpid(), hostname); - } + if ((do_keep || index_pack_args) && (args->lock_pack || unpack_limit)) + add_index_pack_keep_option(&cmd.args); if (!index_pack_args && args->check_self_contained_and_connected) strvec_push(&cmd.args, "--check-self-contained-and-connected"); else @@ -1378,17 +1393,20 @@ static int send_fetch_request(struct fetch_negotiator *negotiator, int fd_out, static int process_section_header(struct packet_reader *reader, const char *section, int peek) { - int ret; - - if (packet_reader_peek(reader) != PACKET_READ_NORMAL) - die(_("error reading section header '%s'"), section); + int ret = 0; - ret = !strcmp(reader->line, section); + if (packet_reader_peek(reader) == PACKET_READ_NORMAL && + !strcmp(reader->line, section)) + ret = 1; if (!peek) { - if (!ret) - die(_("expected '%s', received '%s'"), - section, reader->line); + if (!ret) { + if (reader->line) + die(_("expected '%s', received '%s'"), + section, reader->line); + else + die(_("expected '%s'"), section); + } packet_reader_read(reader); } |