From: Junio C Hamano Date: Tue, 24 Jul 2018 21:50:47 +0000 (-0700) Subject: Merge branch 'jt/partial-clone-fsck-connectivity' X-Git-Tag: v2.19.0-rc0~128 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/8fa8a4f1ec088ab937d1c460f3eb1701e51b8ffc?hp=-c Merge branch 'jt/partial-clone-fsck-connectivity' Partial clone support of "git clone" has been updated to correctly validate the objects it receives from the other side. The server side has been corrected to send objects that are directly requested, even if they may match the filtering criteria (e.g. when doing a "lazy blob" partial clone). * jt/partial-clone-fsck-connectivity: clone: check connectivity even if clone is partial upload-pack: send refs' objects despite "filter" --- 8fa8a4f1ec088ab937d1c460f3eb1701e51b8ffc diff --combined builtin/clone.c index 2f84717e11,fa53550758..5c439f1394 --- a/builtin/clone.c +++ b/builtin/clone.c @@@ -15,7 -15,6 +15,7 @@@ #include "fetch-pack.h" #include "refs.h" #include "refspec.h" +#include "object-store.h" #include "tree.h" #include "tree-walk.h" #include "unpack-trees.h" @@@ -1078,7 -1077,7 +1078,7 @@@ int cmd_clone(int argc, const char **ar if (option_required_reference.nr || option_optional_reference.nr) setup_reference(); - refspec_item_init(&refspec, value.buf, REFSPEC_FETCH); + refspec_item_init_or_die(&refspec, value.buf, REFSPEC_FETCH); strbuf_reset(&value); @@@ -1202,7 -1201,7 +1202,7 @@@ update_remote_refs(refs, mapped_refs, remote_head_points_at, branch_top.buf, reflog_msg.buf, transport, - !is_local && !filter_options.choice); + !is_local); update_head(our_head_points_at, remote_head, reflog_msg.buf); diff --combined list-objects.c index 3e5e1992eb,be4118889a..b1f2138c29 --- a/list-objects.c +++ b/list-objects.c @@@ -10,7 -10,6 +10,7 @@@ #include "list-objects-filter.h" #include "list-objects-filter-options.h" #include "packfile.h" +#include "object-store.h" static void process_blob(struct rev_info *revs, struct blob *blob, @@@ -48,7 -47,7 +48,7 @@@ pathlen = path->len; strbuf_addstr(path, name); - if (filter_fn) + if (!(obj->flags & USER_GIVEN) && filter_fn) r = filter_fn(LOFS_BLOB, obj, path->buf, &path->buf[pathlen], filter_data); @@@ -133,7 -132,7 +133,7 @@@ static void process_tree(struct rev_inf } strbuf_addstr(base, name); - if (filter_fn) + if (!(obj->flags & USER_GIVEN) && filter_fn) r = filter_fn(LOFS_BEGIN_TREE, obj, base->buf, &base->buf[baselen], filter_data); @@@ -172,7 -171,7 +172,7 @@@ cb_data, filter_fn, filter_data); } - if (filter_fn) { + if (!(obj->flags & USER_GIVEN) && filter_fn) { r = filter_fn(LOFS_END_TREE, obj, base->buf, &base->buf[baselen], filter_data); diff --combined object.h index 1b96073601,cf8da6ba83..3afd123d73 --- a/object.h +++ b/object.h @@@ -1,32 -1,6 +1,32 @@@ #ifndef OBJECT_H #define OBJECT_H +struct parsed_object_pool { + struct object **obj_hash; + int nr_objs, obj_hash_size; + + /* TODO: migrate alloc_states to mem-pool? */ + struct alloc_state *blob_state; + struct alloc_state *tree_state; + struct alloc_state *commit_state; + struct alloc_state *tag_state; + struct alloc_state *object_state; + unsigned commit_count; + + /* parent substitutions from .git/info/grafts and .git/shallow */ + struct commit_graft **grafts; + int grafts_alloc, grafts_nr; + + int is_shallow; + struct stat_validity *shallow_stat; + char *alternate_shallow_file; + + int commit_graft_prepared; +}; + +struct parsed_object_pool *parsed_object_pool_new(void); +void parsed_object_pool_clear(struct parsed_object_pool *o); + struct object_list { struct object *item; struct object_list *next; @@@ -53,7 -27,7 +53,7 @@@ struct object_array /* * object flag allocation: - * revision.h: 0---------10 26 + * revision.h: 0---------10 2526 * fetch-pack.c: 0----5 * walker.c: 0-2 * upload-pack.c: 4 11----------------19 @@@ -68,7 -42,6 +68,7 @@@ * builtin/index-pack.c: 2021 * builtin/pack-objects.c: 20 * builtin/reflog.c: 10--12 + * builtin/show-branch.c: 0-------------------------------------------26 * builtin/unpack-objects.c: 2021 */ #define FLAG_BITS 27 @@@ -111,7 -84,7 +111,7 @@@ extern struct object *get_indexed_objec */ struct object *lookup_object(const unsigned char *sha1); -extern void *create_object(const unsigned char *sha1, void *obj); +extern void *create_object(struct repository *r, const unsigned char *sha1, void *obj); void *object_as_type(struct object *obj, enum object_type type, int quiet); diff --combined revision.c index 72abe235e4,1b37da988d..a2570397b6 --- a/revision.c +++ b/revision.c @@@ -1,5 -1,4 +1,5 @@@ #include "cache.h" +#include "object-store.h" #include "tag.h" #include "blob.h" #include "tree.h" @@@ -30,8 -29,6 +30,8 @@@ volatile show_early_output_fn_t show_ea static const char *term_bad; static const char *term_good; +implement_shared_commit_slab(revision_sources, char *); + void show_object_with_name(FILE *out, struct object *obj, const char *name) { const char *p; @@@ -175,6 -172,7 +175,7 @@@ static void add_pending_object_with_pat strbuf_release(&buf); return; /* do not add the commit itself */ } + obj->flags |= USER_GIVEN; add_object_array_with_path(obj, name, &revs->pending, mode, path); } @@@ -268,19 -266,14 +269,19 @@@ static struct commit *handle_commit(str */ if (object->type == OBJ_COMMIT) { struct commit *commit = (struct commit *)object; + if (parse_commit(commit) < 0) die("unable to parse commit %s", name); if (flags & UNINTERESTING) { mark_parents_uninteresting(commit); revs->limited = 1; } - if (revs->show_source && !commit->util) - commit->util = xstrdup(name); + if (revs->sources) { + char **slot = revision_sources_at(revs->sources, commit); + + if (!*slot) + *slot = xstrdup(name); + } return commit; } @@@ -832,12 -825,8 +833,12 @@@ static int add_parents_to_list(struct r } return -1; } - if (revs->show_source && !p->util) - p->util = commit->util; + if (revs->sources) { + char **slot = revision_sources_at(revs->sources, p); + + if (!*slot) + *slot = *revision_sources_at(revs->sources, commit); + } p->object.flags |= left_flag; if (!(p->object.flags & SEEN)) { p->object.flags |= SEEN; diff --combined revision.h index bf2239f876,dc8f96366e..c599c34da9 --- a/revision.h +++ b/revision.h @@@ -6,7 -6,6 +6,7 @@@ #include "notes.h" #include "pretty.h" #include "diff.h" +#include "commit-slab-decl.h" /* Remember to update object flag allocation in object.h */ #define SEEN (1u<<0) @@@ -20,8 -19,9 +20,9 @@@ #define SYMMETRIC_LEFT (1u<<8) #define PATCHSAME (1u<<9) #define BOTTOM (1u<<10) + #define USER_GIVEN (1u<<25) /* given directly by the user */ #define TRACK_LINEAR (1u<<26) - #define ALL_REV_FLAGS (((1u<<11)-1) | TRACK_LINEAR) + #define ALL_REV_FLAGS (((1u<<11)-1) | USER_GIVEN | TRACK_LINEAR) #define DECORATE_SHORT_REFS 1 #define DECORATE_FULL_REFS 2 @@@ -30,7 -30,6 +31,7 @@@ struct rev_info struct log_info; struct string_list; struct saved_parents; +define_shared_commit_slab(revision_sources, char *); struct rev_cmdline_info { unsigned int nr; @@@ -113,6 -112,7 +114,6 @@@ struct rev_info right_only:1, rewrite_parents:1, print_parents:1, - show_source:1, show_decorations:1, reverse:1, reverse_output_stage:1, @@@ -225,8 -225,6 +226,8 @@@ struct commit_list *previous_parents; const char *break_bar; + + struct revision_sources *sources; }; extern int ref_excluded(struct string_list *, const char *path);