object-store: lookup_commit
v3 cover object-store: lookup_commit
This continues the elimination of global variables in the object store and teaches lookup_commit[_reference] and alike to handle a_repository.
This is also available as
https://github.com/stefanbeller/git/tree/object-store-lookup-commit
or applies on top of 02f70d63027 (Merge branch 'sb/object-store-grafts' into next, 2018-06-28).
Picking a base for this one is really hard, as nearly all series currently cooking or in flight collide with it on one or two lines. (lookup_* is used heavily, who would have thought?); I really needed 'sb/object-store-grafts' to build on; and there is only one other series before that in current next, which this series would have conflicted with, if not based on top of it.
In "The state of the object store series" [1], this was tentatively named "sb/object-store-lookup".
Thanks,
Stefan
[1] https://public-inbox.org/git/CAGZ79kZtEZA1rvgfSCS+m4dsrB86Cf-XiePWQmeU-kCNxP_NLQ@mail.gmail.com/
v2 https://public-inbox.org/git/[email protected]/
* removed mentions of cooci patches
* added forward declaration of commit buffer slabs.
* dropped 3 patches that add the repository to lookup_unkonwn_object, parse_commit and parse_commit_gently, but were not converting those functions. We'll convert these in the next series, as this series is growing big already.
* This series can be found as branch 'object-store-lookup-commit' on github, it applies on top of nd/commit-util-to-slab merged with sb/object-store-grafts
v1, https://public-inbox.org/git/[email protected]/
This applies on the merge of nd/commit-util-to-slab and sb/object-store-grafts, and is available at http://github.com/stefanbeller/ as branch object-store-lookup-commit as the merge has some merge conflicts as well as syntactical conflicts (upload-pack.c and fetch-pack.c introduce new calls of functions that would want to take a repository struct in the object-store-grafts series)
As layed out in https://public-inbox.org/git/[email protected]/
this is getting close to finishing the set of object store series though the last unfinished part of this RFC hints at new work on the plate:
* To give this series a nice polish, we'd want to convert parse_commit, too. But that requires the conversion of the new commit graph. Maybe we need to split this series into 2.
* Once this is in good shape we can talk about converting parts of the revision walking code,
* which then can be used by the submodule code as the end goal for the object store series.
Thanks,
Stefan
Stefan Beller (32):
object: add repository argument to parse_object
object: add repository argument to lookup_object
object: add repository argument to parse_object_buffer
object: add repository argument to object_as_type
blob: add repository argument to lookup_blob
tree: add repository argument to lookup_tree
commit: add repository argument to lookup_commit_reference_gently
commit: add repository argument to lookup_commit_reference
commit: add repository argument to lookup_commit
commit: add repository argument to parse_commit_buffer
commit: add repository argument to set_commit_buffer
commit: add repository argument to get_cached_commit_buffer
tag: add repository argument to lookup_tag
tag: add repository argument to parse_tag_buffer
tag: add repository argument to deref_tag
object: allow object_as_type to handle arbitrary repositories
object: allow lookup_object to handle arbitrary repositories
blob: allow lookup_blob to handle arbitrary repositories
tree: allow lookup_tree to handle arbitrary repositories
commit: allow lookup_commit to handle arbitrary repositories
tag: allow lookup_tag to handle arbitrary repositories
tag: allow parse_tag_buffer to handle arbitrary repositories commit.c: allow parse_commit_buffer to handle arbitrary repositories
commit-slabs: remove realloc counter outside of slab struct commit.c: migrate the commit buffer to the parsed object store commit.c: allow set_commit_buffer to handle arbitrary repositories commit.c: allow get_cached_commit_buffer to handle arbitrary
repositories
object.c: allow parse_object_buffer to handle arbitrary repositories object.c: allow parse_object to handle arbitrary repositories tag.c: allow deref_tag to handle arbitrary repositories commit.c: allow lookup_commit_reference_gently to handle arbitrary
repositories
commit.c: allow lookup_commit_reference to handle arbitrary
repositories
archive.c | 2 +- bisect.c | 2 +- blame.c | 13 ++++--- blob.c | 10 ++--- blob.h | 2 +- branch.c | 2 +- builtin/am.c | 9 +++-- builtin/branch.c | 7 ++-- builtin/checkout.c | 6 +-- builtin/clone.c | 3 +- builtin/commit-tree.c | 4 +- builtin/describe.c | 13 ++++--- builtin/diff-tree.c | 9 +++-- builtin/diff.c | 7 ++-- builtin/fast-export.c | 14 ++++--- builtin/fetch.c | 9 +++-- builtin/fmt-merge-msg.c | 9 +++-- builtin/fsck.c | 21 +++++++---- builtin/grep.c | 3 +- builtin/index-pack.c | 5 ++- builtin/log.c | 10 +++-- builtin/merge-base.c | 7 ++-- builtin/merge-tree.c | 3 +- builtin/name-rev.c | 13 ++++--- builtin/notes.c | 3 +- builtin/pack-objects.c | 2 +- builtin/prune.c | 2 +- builtin/pull.c | 15 +++++--- builtin/receive-pack.c | 6 +-- builtin/reflog.c | 15 +++++--- builtin/replace.c | 8 ++-- builtin/reset.c | 4 +- builtin/rev-list.c | 2 +- builtin/rev-parse.c | 6 +-- builtin/show-branch.c | 5 ++- builtin/tag.c | 2 +- builtin/unpack-objects.c | 7 ++-- builtin/verify-commit.c | 4 +- bundle.c | 10 +++-- cache-tree.c | 3 +- commit-graph.c | 14 +++---- commit-slab-impl.h | 3 -- commit.c | 80 +++++++++++++++++++++++++--------------- commit.h | 18 ++++++--- fast-import.c | 6 ++- fetch-pack.c | 39 ++++++++++++-------- fsck.c | 9 +++-- http-backend.c | 4 +- http-push.c | 16 +++++--- line-log.c | 2 +- list-objects.c | 4 +- log-tree.c | 13 ++++--- merge-recursive.c | 17 +++++---- notes-cache.c | 3 +- notes-merge.c | 5 ++- notes-utils.c | 4 +- object.c | 61 ++++++++++++++++-------------- object.h | 12 ++++-- packfile.c | 2 +- parse-options-cb.c | 2 +- pretty.c | 4 +- reachable.c | 8 ++-- ref-filter.c | 12 ++++-- reflog-walk.c | 3 +- refs.c | 2 +- refs/files-backend.c | 2 +- remote.c | 19 ++++++---- revision.c | 26 ++++++------- sequencer.c | 14 +++---- server-info.c | 4 +- sha1-file.c | 4 +- sha1-name.c | 33 +++++++++-------- shallow.c | 30 +++++++++------ submodule.c | 4 +- tag.c | 28 +++++++------- tag.h | 7 ++-- tree.c | 19 +++++----- tree.h | 2 +- upload-pack.c | 17 +++++---- walker.c | 12 ++++-- wt-status.c | 2 +- 81 files changed, 485 insertions(+), 358 deletions(-)
Signature · 1 line
2.18.0.399.gad0ab374a1-goog
PATCH v3 2/32 object: add repository argument to lookup_object
Add a repository argument to allow callers of lookup_object to be more specific about which repository to handle. This is a small mechanical change; it doesn't change the implementation to handle repositories other than the_repository yet.
As with the previous commits, use a macro to catch callers passing a repository other than the_repository at compile time.
--- blob.c | 2 +- builtin/fast-export.c | 5 +++-- builtin/fsck.c | 5 +++-- builtin/name-rev.c | 3 ++- builtin/prune.c | 2 +- builtin/unpack-objects.c | 2 +- commit.c | 2 +- fetch-pack.c | 13 +++++++------ http-push.c | 2 +- object.c | 8 ++++---- object.h | 3 ++- reachable.c | 4 ++-- tag.c | 2 +- tree.c | 2 +- upload-pack.c | 2 +- 15 files changed, 31 insertions(+), 26 deletions(-)
blob.c +1 -1
@@ -7,7 +7,7 @@ const char *blob_type = "blob";struct blob *lookup_blob (const struct object_id *oid) { -struct object *obj =lookup_object (oid->hash); +struct object *obj =lookup_object (the_repository, oid->hash);if (!obj)return create_object (the_repository, oid->hash,alloc_blob_node (the_repository));
builtin/fast-export.c +3 -2
@@ -230,7 +230,7 @@ static void export_blob(const struct object_id *oid)if (is_null_oid (oid))return ; - object =lookup_object (oid->hash); + object =lookup_object (the_repository, oid->hash);if (object && object->flags &SHOWN )return ;
@@ -402,7 +402,8 @@ static void show_filemodify(struct diff_queue_struct *q, anonymize_sha1(&spec->oid) : spec->oid.hash)); else { -struct object *object =lookup_object (spec->oid.hash); +struct object *object =lookup_object (the_repository, + spec->oid.hash);printf ("M %06o :%d " , spec->mode,get_object_mark (object)); }
builtin/fsck.c +3 -2
@@ -410,7 +410,7 @@ static void fsck_handle_reflog_oid(const char *refname, struct object_id *oid,struct object *obj;if (!is_null_oid (oid)) { - obj =lookup_object (oid->hash); + obj =lookup_object (the_repository, oid->hash);if (obj && (obj->flags &HAS_OBJ )) {if (timestamp && name_objects) add_decoration(fsck_walk_options.object_names,
@@ -763,7 +763,8 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)const char *arg = argv[i];struct object_id oid;if (!get_oid (arg, &oid)) { -struct object *obj =lookup_object (oid.hash); +struct object *obj =lookup_object (the_repository, + oid.hash);if (!obj || !(obj->flags &HAS_OBJ )) {if (is_promisor_object (&oid))
builtin/name-rev.c +2 -1
@@ -379,7 +379,8 @@ static void name_rev_line(char *p, struct name_ref_data *data) *(p+1 ) =0 ;if (!get_oid (p - (GIT_SHA1_HEXSZ -1 ), &oid)) {struct object *o = -lookup_object (oid.hash); +lookup_object (the_repository, + oid.hash);if (o) name =get_rev_name (o, &buf); }
builtin/prune.c +1 -1
@@ -40,7 +40,7 @@ static int prune_object(const struct object_id *oid, const char *fullpath,* Do we know about this object? * It must have been reachable */ -if (lookup_object (oid->hash)) +if (lookup_object (the_repository, oid->hash))return 0 ;if (lstat (fullpath, &st)) {
builtin/unpack-objects.c +1 -1
@@ -331,7 +331,7 @@ static int resolve_against_held(unsigned nr, const struct object_id *base, {struct object *obj;struct obj_buffer *obj_buffer; - obj =lookup_object (base->hash); + obj =lookup_object (the_repository, base->hash);if (!obj)return 0 ; obj_buffer =lookup_object_buffer (obj);
commit.c +1 -1
@@ -54,7 +54,7 @@ struct commit *lookup_commit_or_die(const struct object_id *oid, const char *refstruct commit *lookup_commit (const struct object_id *oid) { -struct object *obj =lookup_object (oid->hash); +struct object *obj =lookup_object (the_repository, oid->hash);if (!obj)return create_object (the_repository, oid->hash,alloc_commit_node (the_repository));
fetch-pack.c +7 -6
@@ -362,7 +362,7 @@ static int find_common(struct fetch_pack_args *args,* interested in the case we *know* the object is * reachable and we have already scanned it. */ -if (((o =lookup_object (remote->hash)) !=NULL ) && +if (((o =lookup_object (the_repository, remote->hash)) !=NULL ) && (o->flags &COMPLETE )) {continue ; }
@@ -436,7 +436,7 @@ static int find_common(struct fetch_pack_args *args,if (skip_prefix (line,"unshallow " , &arg)) {if (get_oid_hex (arg, &oid))die (_ ("invalid unshallow line: %s" ), line); -if (!lookup_object (oid.hash)) +if (!lookup_object (the_repository, oid.hash))die (_ ("object not found: %s" ), line);/* make sure that it is parsed as shallow */ if (!parse_object (the_repository, &oid))
@@ -801,7 +801,8 @@ static int everything_local(struct fetch_pack_args *args,* Don't mark them common yet; the server has to be told so first. */ for (ref = *refs; ref; ref = ref->next) { -struct object *o =deref_tag (lookup_object (ref->old_oid.hash), +struct object *o =deref_tag (lookup_object (the_repository, + ref->old_oid.hash),NULL ,0 );if (!o || o->type !=OBJ_COMMIT || !(o->flags &COMPLETE ))
@@ -821,7 +822,7 @@ static int everything_local(struct fetch_pack_args *args,const struct object_id *remote = &ref->old_oid;struct object *o; - o =lookup_object (remote->hash); + o =lookup_object (the_repository, remote->hash);if (!o || !(o->flags &COMPLETE )) { retval =0 ; print_verbose(args, "want %s (%s)", oid_to_hex(remote),
@@ -1120,7 +1121,7 @@ static void add_wants(const struct ref *wants, struct strbuf *req_buf)* interested in the case we *know* the object is * reachable and we have already scanned it. */ -if (((o =lookup_object (remote->hash)) !=NULL ) && +if (((o =lookup_object (the_repository, remote->hash)) !=NULL ) && (o->flags &COMPLETE )) {continue ; }
@@ -1317,7 +1318,7 @@ static void receive_shallow_info(struct fetch_pack_args *args,if (skip_prefix (reader->line,"unshallow " , &arg)) {if (get_oid_hex (arg, &oid))die (_ ("invalid unshallow line: %s" ), reader->line); -if (!lookup_object (oid.hash)) +if (!lookup_object (the_repository, oid.hash))die (_ ("object not found: %s" ), reader->line);/* make sure that it is parsed as shallow */ if (!parse_object (the_repository, &oid))
http-push.c +1 -1
@@ -722,7 +722,7 @@ static void one_remote_object(const struct object_id *oid) {struct object *obj; - obj =lookup_object (oid->hash); + obj =lookup_object (the_repository, oid->hash);if (!obj) obj =parse_object (the_repository, oid);
object.c +4 -4
@@ -84,7 +84,7 @@ static void insert_obj_hash(struct object *obj, struct object **hash, unsigned i* Look up the record for the given sha1 in the hash map stored in * obj_hash. Return NULL if it was not found. */ -struct object *lookup_object (const unsigned char *sha1) +struct object *lookup_object_the_repository (const unsigned char *sha1) {unsigned int i, first;struct object *obj;
@@ -179,7 +179,7 @@ void *object_as_type(struct object *obj, enum object_type type, int quiet)struct object *lookup_unknown_object (const unsigned char *sha1) { -struct object *obj =lookup_object (sha1); +struct object *obj =lookup_object (the_repository, sha1);if (!obj) obj =create_object (the_repository, sha1,alloc_object_node (the_repository));
@@ -255,7 +255,7 @@ struct object *parse_object_the_repository(const struct object_id *oid)void *buffer;struct object *obj; - obj =lookup_object (oid->hash); + obj =lookup_object (the_repository, oid->hash);if (obj && obj->parsed)return obj;
@@ -267,7 +267,7 @@ struct object *parse_object_the_repository(const struct object_id *oid)return NULL ; }parse_blob_buffer (lookup_blob (oid),NULL ,0 ); -return lookup_object (oid->hash); +return lookup_object (the_repository, oid->hash); } buffer =read_object_file (oid, &type, &size);
object.h +2 -1
@@ -109,7 +109,8 @@ extern struct object *get_indexed_object(unsigned int);* half-initialised objects, the caller is expected to initialize them * by calling parse_object() on them. */ -struct object *lookup_object (const unsigned char *sha1); +#define lookup_object (r, s) lookup_object_##r(s) +struct object *lookup_object_the_repository (const unsigned char *sha1);extern void *create_object (struct repository *r,const unsigned char *sha1,void *obj);
reachable.c +2 -2
@@ -108,7 +108,7 @@ static int add_recent_loose(const struct object_id *oid, const char *path, void *data) { struct stat st; -struct object *obj =lookup_object (oid->hash); +struct object *obj =lookup_object (the_repository, oid->hash);if (obj && obj->flags &SEEN )return 0 ;
@@ -133,7 +133,7 @@ static int add_recent_packed(const struct object_id *oid, struct packed_git *p, uint32_t pos, void *data) { - struct object *obj = lookup_object(oid->hash); + struct object *obj = lookup_object(the_repository, oid->hash);if (obj && obj->flags &SEEN )return 0 ;
tag.c +1 -1
@@ -94,7 +94,7 @@ struct object *deref_tag_noverify(struct object *o)struct tag *lookup_tag (const struct object_id *oid) { -struct object *obj =lookup_object (oid->hash); +struct object *obj =lookup_object (the_repository, oid->hash);if (!obj)return create_object (the_repository, oid->hash,alloc_tag_node (the_repository));
tree.c +1 -1
@@ -197,7 +197,7 @@ int read_tree(struct tree *tree, int stage, struct pathspec *match,struct tree *lookup_tree (const struct object_id *oid) { -struct object *obj =lookup_object (oid->hash); +struct object *obj =lookup_object (the_repository, oid->hash);if (!obj)return create_object (the_repository, oid->hash,alloc_tree_node (the_repository));
upload-pack.c +1 -1
@@ -570,7 +570,7 @@ static int get_reachable_list(struct object_array *src,if (parse_oid_hex (namebuf, &sha1, &p) || *p !='\n' )break ; - o =lookup_object (sha1.hash); + o =lookup_object (the_repository, sha1.hash);if (o && o->type ==OBJ_COMMIT ) { o->flags &= ~TMP_MARK ; }
Signature · 1 line
2.18.0.399.gad0ab374a1-goog
PATCH v3 1/32 object: add repository argument to parse_object
In reply to Stefan BellerAdd a repository argument to allow the callers of parse_object to be more specific about which repository to act on. This is a small mechanical change; it doesn't change the implementation to handle repositories other than the_repository yet.
As with the previous commits, use a macro to catch callers passing a repository other than the_repository at compile time.
--- builtin/diff-tree.c | 3 ++- builtin/diff.c | 2 +- builtin/fast-export.c | 2 +- builtin/fmt-merge-msg.c | 6 ++++-- builtin/fsck.c | 4 ++-- builtin/log.c | 3 ++- builtin/name-rev.c | 7 ++++--- builtin/receive-pack.c | 6 +++--- builtin/reflog.c | 3 ++- builtin/rev-list.c | 2 +- bundle.c | 5 +++-- commit.c | 5 +++-- fetch-pack.c | 18 ++++++++++-------- fsck.c | 3 ++- http-backend.c | 2 +- http-push.c | 6 ++++-- log-tree.c | 7 ++++--- merge-recursive.c | 4 +++- object.c | 4 ++-- object.h | 3 ++- packfile.c | 2 +- pretty.c | 2 +- ref-filter.c | 3 ++- reflog-walk.c | 3 ++- refs/files-backend.c | 2 +- remote.c | 4 ++-- revision.c | 14 +++++++------- server-info.c | 2 +- sha1-name.c | 14 +++++++------- tag.c | 5 +++-- tree.c | 5 +++-- upload-pack.c | 13 +++++++------ walker.c | 3 ++- 33 files changed, 95 insertions(+), 72 deletions(-)
builtin/diff-tree.c +2 -1
@@ -5,6 +5,7 @@#include "log-tree.h" #include "builtin.h" #include "submodule.h" +#include "repository.h" static struct rev_info log_tree_opt;
@@ -68,7 +69,7 @@ static int diff_tree_stdin(char *line) line[len-1 ] =0 ;if (parse_oid_hex (line, &oid, &p))return -1 ; - obj =parse_object (&oid); + obj =parse_object (the_repository, &oid);if (!obj)return -1 ;if (obj->type ==OBJ_COMMIT )
builtin/diff.c +1 -1
@@ -400,7 +400,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)const char *name = entry->name;int flags = (obj->flags &UNINTERESTING );if (!obj->parsed) - obj =parse_object (&obj->oid); + obj =parse_object (the_repository, &obj->oid); obj =deref_tag (obj,NULL ,0 );if (!obj)die (_ ("invalid object '%s' given." ), name);
builtin/fast-export.c +1 -1
@@ -801,7 +801,7 @@ static struct commit *get_commit(struct rev_cmdline_entry *e, char *full_name)/* handle nested tags */ while (tag && tag->object.type ==OBJ_TAG ) { -parse_object (&tag->object.oid); +parse_object (the_repository, &tag->object.oid);string_list_append (&extra_refs, full_name)->util = tag; tag = (struct tag *)tag->tagged; }
builtin/fmt-merge-msg.c +4 -2
@@ -11,6 +11,7 @@#include "branch.h" #include "fmt-merge-msg.h" #include "gpg-interface.h" +#include "repository.h" static const char *const fmt_merge_msg_usage[] = {N_ ("git fmt-merge-msg [-m <message>] [--log[=<n>] | --no-log] [--file <file>]" ),
@@ -343,7 +344,8 @@ static void shortlog(const char *name,const struct object_id *oid = &origin_data->oid;int limit = opts->shortlog_len; - branch =deref_tag (parse_object (oid),oid_to_hex (oid),GIT_SHA1_HEXSZ ); + branch =deref_tag (parse_object (the_repository, oid),oid_to_hex (oid), +GIT_SHA1_HEXSZ );if (!branch || branch->type !=OBJ_COMMIT )return ;
@@ -563,7 +565,7 @@ static void find_merge_parents(struct merge_parents *result,* "name" here and we do not want to contaminate its * util field yet. */ - obj =parse_object (&oid); + obj =parse_object (the_repository, &oid); parent = (struct commit *)peel_to_type (NULL ,0 , obj,OBJ_COMMIT );if (!parent)continue ;
builtin/fsck.c +2 -2
@@ -452,7 +452,7 @@ static int fsck_handle_ref(const char *refname, const struct object_id *oid, {struct object *obj; - obj =parse_object (oid); + obj =parse_object (the_repository, oid);if (!obj) {if (is_promisor_object (oid)) {/*
@@ -614,7 +614,7 @@ static int fsck_cache_tree(struct cache_tree *it)fprintf (stderr,"Checking cache tree\n" );if (0 <= it->entry_count) { -struct object *obj =parse_object (&it->oid); +struct object *obj =parse_object (the_repository, &it->oid);if (!obj) {error ("%s: invalid sha1 pointer in cache-tree" ,oid_to_hex (&it->oid));
builtin/log.c +2 -1
@@ -30,6 +30,7 @@#include "gpg-interface.h" #include "progress.h" #include "commit-slab.h" +#include "repository.h" #define MAIL_DEFAULT_WRAP 72
@@ -619,7 +620,7 @@ int cmd_show(int argc, const char **argv, const char *prefix) rev.shown_one =1 ;if (ret)break ; - o =parse_object (&t->tagged->oid); + o =parse_object (the_repository, &t->tagged->oid);if (!o) ret =error (_ ("Could not read object %s" ),oid_to_hex (&t->tagged->oid));
builtin/name-rev.c +4 -3
@@ -1,5 +1,6 @@#include "builtin.h" #include "cache.h" +#include "repository.h" #include "config.h" #include "commit.h" #include "tag.h"
@@ -203,7 +204,7 @@ static int tipcmp(const void *a_, const void *b_)static int name_ref (const char *path,const struct object_id *oid,int flags,void *cb_data) { -struct object *o =parse_object (oid); +struct object *o =parse_object (the_repository, oid);struct name_ref_data *data = cb_data;int can_abbreviate_output = data->tags_only && data->name_only;int deref =0 ;
@@ -261,7 +262,7 @@ static int name_ref(const char *path, const struct object_id *oid, int flags, vostruct tag *t = (struct tag *) o;if (!t->tagged)break ;/* broken repository */ - o =parse_object (&t->tagged->oid); + o =parse_object (the_repository, &t->tagged->oid); deref =1 ; taggerdate = t->date; }
@@ -451,7 +452,7 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix) } commit =NULL ; - object =parse_object (&oid); + object =parse_object (the_repository, &oid);if (object) {struct object *peeled =deref_tag (object, *argv,0 );if (peeled && peeled->type ==OBJ_COMMIT )
builtin/receive-pack.c +3 -3
@@ -1108,8 +1108,8 @@ static const char *update(struct command *cmd, struct shallow_info *si)struct object *old_object, *new_object;struct commit *old_commit, *new_commit; - old_object =parse_object (old_oid); - new_object =parse_object (new_oid); + old_object =parse_object (the_repository, old_oid); + new_object =parse_object (the_repository, new_oid); if (!old_object || !new_object || old_object->type != OBJ_COMMIT ||
@@ -1132,7 +1132,7 @@ static const char *update(struct command *cmd, struct shallow_info *si)if (is_null_oid (new_oid)) {struct strbuf err =STRBUF_INIT ; -if (!parse_object (old_oid)) { +if (!parse_object (the_repository, old_oid)) { old_oid =NULL ;if (ref_exists (name)) {rp_warning ("Allowing deletion of corrupt ref." );
builtin/reflog.c +2 -1
@@ -2,6 +2,7 @@#include "config.h" #include "lockfile.h" #include "object-store.h" +#include "repository.h" #include "commit.h" #include "refs.h" #include "dir.h"
@@ -129,7 +130,7 @@ static int commit_is_complete(struct commit *commit)struct commit_list *parent; c = (struct commit *)object_array_pop (&study); -if (!c->object.parsed && !parse_object (&c->object.oid)) +if (!c->object.parsed && !parse_object (the_repository, &c->object.oid)) c->object.flags |=INCOMPLETE ;if (c->object.flags &INCOMPLETE ) {
builtin/rev-list.c +1 -1
@@ -239,7 +239,7 @@ static int finish_object(struct object *obj, const char *name, void *cb_data)return 1 ; }if (info->revs->verify_objects && !obj->parsed && obj->type !=OBJ_COMMIT ) -parse_object (&obj->oid); +parse_object (the_repository, &obj->oid);return 0 ; }
bundle.c +3 -2
@@ -2,6 +2,7 @@#include "lockfile.h" #include "bundle.h" #include "object-store.h" +#include "repository.h" #include "object.h" #include "commit.h" #include "diff.h"
@@ -142,7 +143,7 @@ int verify_bundle(struct bundle_header *header, int verbose)init_revisions (&revs,NULL );for (i =0 ; i < p->nr; i++) {struct ref_list_entry *e = p->list + i; -struct object *o =parse_object (&e->oid); +struct object *o =parse_object (the_repository, &e->oid);if (o) { o->flags |=PREREQ_MARK ;add_pending_object (&revs, o, e->name);
@@ -167,7 +168,7 @@ int verify_bundle(struct bundle_header *header, int verbose)for (i =0 ; i < p->nr; i++) {struct ref_list_entry *e = p->list + i; -struct object *o =parse_object (&e->oid); +struct object *o =parse_object (the_repository, &e->oid);assert (o);/* otherwise we'd have returned early */ if (o->flags &SHOWN )continue ;
commit.c +3 -2
@@ -27,7 +27,8 @@ const char *commit_type = "commit";struct commit *lookup_commit_reference_gently (const struct object_id *oid,int quiet) { -struct object *obj =deref_tag (parse_object (oid),NULL ,0 ); +struct object *obj =deref_tag (parse_object (the_repository, oid), +NULL ,0 );if (!obj)return NULL ;
@@ -1692,7 +1693,7 @@ struct commit *get_merge_parent(const char *name)struct object_id oid;if (get_oid (name, &oid))return NULL ; - obj =parse_object (&oid); + obj =parse_object (the_repository, &oid); commit = (struct commit *)peel_to_type (name,0 , obj,OBJ_COMMIT );if (commit && !merge_remote_util (commit))set_merge_remote_desc (commit, name, obj);
fetch-pack.c +10 -8
@@ -84,7 +84,7 @@ static void cache_one_alternate(const char *refname, void *vcache) {struct alternate_object_cache *cache = vcache; -struct object *obj =parse_object (oid); +struct object *obj =parse_object (the_repository, oid);if (!obj || (obj->flags &ALTERNATE ))return ;
@@ -126,7 +126,8 @@ static void rev_list_push(struct commit *commit, int mark)static int rev_list_insert_ref (const char *refname,const struct object_id *oid) { -struct object *o =deref_tag (parse_object (oid), refname,0 ); +struct object *o =deref_tag (parse_object (the_repository, oid), + refname,0 );if (o && o->type ==OBJ_COMMIT )rev_list_push ((struct commit *)o,SEEN );
@@ -143,7 +144,8 @@ static int rev_list_insert_ref_oid(const char *refname, const struct object_id *static int clear_marks (const char *refname,const struct object_id *oid,int flag,void *cb_data) { -struct object *o =deref_tag (parse_object (oid), refname,0 ); +struct object *o =deref_tag (parse_object (the_repository, oid), + refname,0 );if (o && o->type ==OBJ_COMMIT ) clear_commit_marks((struct commit *)o,
@@ -437,7 +439,7 @@ static int find_common(struct fetch_pack_args *args,if (!lookup_object (oid.hash))die (_ ("object not found: %s" ), line);/* make sure that it is parsed as shallow */ -if (!parse_object (&oid)) +if (!parse_object (the_repository, &oid))die (_ ("error in object: %s" ), line);if (unregister_shallow (&oid))die (_ ("no shallow found: %s" ), line);
@@ -570,14 +572,14 @@ static struct commit_list *complete;static int mark_complete (const struct object_id *oid) { -struct object *o =parse_object (oid); +struct object *o =parse_object (the_repository, oid);while (o && o->type ==OBJ_TAG ) {struct tag *t = (struct tag *) o;if (!t->tagged)break ;/* broken repository */ o->flags |=COMPLETE ; - o =parse_object (&t->tagged->oid); + o =parse_object (the_repository, &t->tagged->oid); }if (o && o->type ==OBJ_COMMIT ) {struct commit *commit = (struct commit *)o;
@@ -768,7 +770,7 @@ static int everything_local(struct fetch_pack_args *args,if (!has_object_file_with_flags (&ref->old_oid, flags))continue ; - o =parse_object (&ref->old_oid); + o =parse_object (the_repository, &ref->old_oid);if (!o)continue ;
@@ -1318,7 +1320,7 @@ static void receive_shallow_info(struct fetch_pack_args *args,if (!lookup_object (oid.hash))die (_ ("object not found: %s" ), reader->line);/* make sure that it is parsed as shallow */ -if (!parse_object (&oid)) +if (!parse_object (the_repository, &oid))die (_ ("error in object: %s" ), reader->line);if (unregister_shallow (&oid))die (_ ("no shallow found: %s" ), reader->line);
fsck.c +2 -1
@@ -1,5 +1,6 @@#include "cache.h" #include "object-store.h" +#include "repository.h" #include "object.h" #include "blob.h" #include "tree.h"
@@ -511,7 +512,7 @@ int fsck_walk(struct object *obj, void *data, struct fsck_options *options)return -1 ;if (obj->type ==OBJ_NONE ) -parse_object (&obj->oid); +parse_object (the_repository, &obj->oid);switch (obj->type) {case OBJ_BLOB :
http-backend.c +1 -1
@@ -436,7 +436,7 @@ static int show_text_ref(const char *name, const struct object_id *oid, {const char *name_nons =strip_namespace (name);struct strbuf *buf = cb_data; -struct object *o =parse_object (oid); +struct object *o =parse_object (the_repository, oid);if (!o)return 0 ;
http-push.c +4 -2
@@ -1,4 +1,5 @@#include "cache.h" +#include "repository.h" #include "commit.h" #include "tag.h" #include "blob.h"
@@ -14,6 +15,7 @@#include "packfile.h" #include "object-store.h" +#ifdef EXPAT_NEEDS_XMLPARSE_H #include <xmlparse.h> #else
@@ -722,7 +724,7 @@ static void one_remote_object(const struct object_id *oid) obj =lookup_object (oid->hash);if (!obj) - obj =parse_object (oid); + obj =parse_object (the_repository, oid);/* Ignore remote objects that don't exist locally */ if (!obj)
@@ -1459,7 +1461,7 @@ static void add_remote_info_ref(struct remote_ls_ctx *ls)return ; } - o =parse_object (&ref->old_oid); + o =parse_object (the_repository, &ref->old_oid);if (!o) { fprintf(stderr, "Unable to parse object %s for remote ref %s\n",
log-tree.c +4 -3
@@ -2,6 +2,7 @@#include "config.h" #include "diff.h" #include "object-store.h" +#include "repository.h" #include "commit.h" #include "tag.h" #include "graph.h"
@@ -98,13 +99,13 @@ static int add_ref_decoration(const char *refname, const struct object_id *oid,warning ("invalid replace ref %s" , refname);return 0 ; } - obj =parse_object (&original_oid); + obj =parse_object (the_repository, &original_oid);if (obj)add_name_decoration (DECORATION_GRAFTED ,"replaced" , obj);return 0 ; } - obj =parse_object (oid); + obj =parse_object (the_repository, oid);if (!obj)return 0 ;
@@ -125,7 +126,7 @@ static int add_ref_decoration(const char *refname, const struct object_id *oid,if (!obj)break ;if (!obj->parsed) -parse_object (&obj->oid); +parse_object (the_repository, &obj->oid);add_name_decoration (DECORATION_REF_TAG , refname, obj); }return 0 ;
merge-recursive.c +3 -1
@@ -9,6 +9,7 @@#include "lockfile.h" #include "cache-tree.h" #include "object-store.h" +#include "repository.h" #include "commit.h" #include "blob.h" #include "builtin.h"
@@ -3488,7 +3489,8 @@ static struct commit *get_ref(const struct object_id *oid, const char *name) {struct object *object; - object =deref_tag (parse_object (oid), name,strlen (name)); + object =deref_tag (parse_object (the_repository, oid), name, +strlen (name));if (!object)return NULL ;if (object->type ==OBJ_TREE )
object.c +2 -2
@@ -239,14 +239,14 @@ struct object *parse_object_buffer(const struct object_id *oid, enum object_typestruct object *parse_object_or_die (const struct object_id *oid,const char *name) { -struct object *o =parse_object (oid); +struct object *o =parse_object (the_repository, oid);if (o)return o;die (_ ("unable to parse object: %s" ), name ? name :oid_to_hex (oid)); } -struct object *parse_object (const struct object_id *oid) +struct object *parse_object_the_repository (const struct object_id *oid) {unsigned long size;enum object_type type;
object.h +2 -1
@@ -120,7 +120,8 @@ void *object_as_type(struct object *obj, enum object_type type, int quiet);* * Returns NULL if the object is missing or corrupt. */ -struct object *parse_object (const struct object_id *oid); +#define parse_object (r, oid) parse_object_##r(oid) +struct object *parse_object_the_repository (const struct object_id *oid);/* * Like parse_object, but will die() instead of returning NULL. If the
packfile.c +1 -1
@@ -1934,7 +1934,7 @@ static int add_promisor_object(const struct object_id *oid, void *set_) {struct oidset *set = set_; -struct object *obj =parse_object (oid); +struct object *obj =parse_object (the_repository, oid);if (!obj)return 1 ;
pretty.c +1 -1
@@ -1146,7 +1146,7 @@ static size_t format_commit_one(struct strbuf *sb, /* in UTF-8 *//* these depend on the commit */ if (!commit->object.parsed) -parse_object (&commit->object.oid); +parse_object (the_repository, &commit->object.oid);switch (placeholder[0 ]) {case 'H' :/* commit hash */
ref-filter.c +2 -1
@@ -4,6 +4,7 @@#include "refs.h" #include "wildmatch.h" #include "object-store.h" +#include "repository.h" #include "commit.h" #include "remote.h" #include "color.h"
@@ -1914,7 +1915,7 @@ static const struct object_id *match_points_at(struct oid_array *points_at,if (oid_array_lookup (points_at, oid) >=0 )return oid; - obj =parse_object (oid); + obj =parse_object (the_repository, oid);if (!obj)die (_ ("malformed object at '%s'" ), refname);if (obj->type ==OBJ_TAG )
reflog-walk.c +2 -1
@@ -305,7 +305,8 @@ static struct commit *next_reflog_commit(struct commit_reflog *log) {for (; log->recno >=0 ; log->recno--) {struct reflog_info *entry = &log->reflogs->items[log->recno]; -struct object *obj =parse_object (&entry->noid); +struct object *obj =parse_object (the_repository, + &entry->noid);if (obj && obj->type ==OBJ_COMMIT )return (struct commit *)obj;
refs/files-backend.c +1 -1
@@ -1660,7 +1660,7 @@ static int write_ref_to_lockfile(struct ref_lock *lock,struct object *o;int fd; - o =parse_object (oid); + o =parse_object (the_repository, oid);if (!o) { strbuf_addf(err, "trying to write ref '%s' with nonexistent object %s",
remote.c +2 -2
@@ -1801,12 +1801,12 @@ int ref_newer(const struct object_id *new_oid, const struct object_id *old_oid)* Both new_commit and old_commit must be commit-ish and new_commit is descendant of * old_commit. Otherwise we require --force. */ - o =deref_tag (parse_object (old_oid),NULL ,0 ); + o =deref_tag (parse_object (the_repository, old_oid),NULL ,0 );if (!o || o->type !=OBJ_COMMIT )return 0 ; old_commit = (struct commit *) o; - o =deref_tag (parse_object (new_oid),NULL ,0 ); + o =deref_tag (parse_object (the_repository, new_oid),NULL ,0 );if (!o || o->type !=OBJ_COMMIT )return 0 ; new_commit = (struct commit *) o;
revision.c +7 -7
@@ -197,7 +197,7 @@ void add_head_to_pending(struct rev_info *revs)struct object *obj;if (get_oid ("HEAD" , &oid))return ; - obj =parse_object (&oid); + obj =parse_object (the_repository, &oid);if (!obj)return ;add_pending_object (revs, obj,"HEAD" );
@@ -209,7 +209,7 @@ static struct object *get_reference(struct rev_info *revs, const char *name, {struct object *object; - object =parse_object (oid); + object =parse_object (the_repository, oid);if (!object) {if (revs->ignore_missing)return object;
@@ -246,7 +246,7 @@ static struct commit *handle_commit(struct rev_info *revs,add_pending_object (revs, object, tag->tag);if (!tag->tagged)die ("bad tag" ); - object =parse_object (&tag->tagged->oid); + object =parse_object (the_repository, &tag->tagged->oid);if (!object) {if (revs->ignore_missing_links || (flags &UNINTERESTING ))return NULL ;
@@ -1249,7 +1249,7 @@ static void handle_one_reflog_commit(struct object_id *oid, void *cb_data) {struct all_refs_cb *cb = cb_data;if (!is_null_oid (oid)) { -struct object *o =parse_object (oid); +struct object *o =parse_object (the_repository, oid);if (o) { o->flags |= cb->all_flags;/* ??? CMDLINEFLAGS ??? */
@@ -1577,8 +1577,8 @@ static int handle_dotdot_1(const char *arg, char *dotdot, *dotdot ='\0' ; } - a_obj =parse_object (&a_oid); - b_obj =parse_object (&b_oid); + a_obj =parse_object (the_repository, &a_oid); + b_obj =parse_object (the_repository, &b_oid);if (!a_obj || !b_obj)return dotdot_missing (arg, dotdot, revs, symmetric);
@@ -2883,7 +2883,7 @@ static int mark_uninteresting(const struct object_id *oid,uint32_t pos, void *unused) { - struct object *o = parse_object(oid); + struct object *o = parse_object(the_repository, oid); o->flags |=UNINTERESTING |SEEN ;return 0 ; }
server-info.c +1 -1
@@ -56,7 +56,7 @@ static int add_info_ref(const char *path, const struct object_id *oid, int flag, void *cb_data) { FILE *fp = cb_data; -struct object *o =parse_object (oid); +struct object *o =parse_object (the_repository, oid);if (!o)return -1 ;
sha1-name.c +7 -7
@@ -239,7 +239,7 @@ static int disambiguate_committish_only(const struct object_id *oid, void *cb_dareturn 0 ;/* We need to do this the hard way... */ - obj =deref_tag (parse_object (oid),NULL ,0 ); + obj =deref_tag (parse_object (the_repository, oid),NULL ,0 );if (obj && obj->type ==OBJ_COMMIT )return 1 ;return 0 ;
@@ -263,7 +263,7 @@ static int disambiguate_treeish_only(const struct object_id *oid, void *cb_data_return 0 ;/* We need to do this the hard way... */ - obj =deref_tag (parse_object (oid),NULL ,0 ); + obj =deref_tag (parse_object (the_repository, oid),NULL ,0 );if (obj && (obj->type ==OBJ_TREE || obj->type ==OBJ_COMMIT ))return 1 ;return 0 ;
@@ -891,7 +891,7 @@ struct object *peel_to_type(const char *name, int namelen,if (name && !namelen) namelen =strlen (name);while (1 ) { -if (!o || (!o->parsed && !parse_object (&o->oid))) +if (!o || (!o->parsed && !parse_object (the_repository, &o->oid)))return NULL ;if (expected_type ==OBJ_ANY || o->type == expected_type)return o;
@@ -964,12 +964,12 @@ static int peel_onion(const char *name, int len, struct object_id *oid,if (get_oid_1 (name, sp - name -2 , &outer, lookup_flags))return -1 ; - o =parse_object (&outer); + o =parse_object (the_repository, &outer);if (!o)return -1 ;if (!expected_type) { o =deref_tag (o, name, sp - name -2 ); -if (!o || (!o->parsed && !parse_object (&o->oid))) +if (!o || (!o->parsed && !parse_object (the_repository, &o->oid)))return -1 ;oidcpy (oid, &o->oid);return 0 ;
@@ -1096,7 +1096,7 @@ static int handle_one_ref(const char *path, const struct object_id *oid, int flag, void *cb_data) { struct commit_list **list = cb_data; -struct object *object =parse_object (oid); +struct object *object =parse_object (the_repository, oid);if (!object)return 0 ;if (object->type ==OBJ_TAG ) {
@@ -1142,7 +1142,7 @@ static int get_oid_oneline(const char *prefix, struct object_id *oid,int matches; commit =pop_most_recent_commit (&list,ONELINE_SEEN ); -if (!parse_object (&commit->object.oid)) +if (!parse_object (the_repository, &commit->object.oid))continue ; buf =get_commit_buffer (commit,NULL ); p =strstr (buf,"\n\n" );
tag.c +3 -2
@@ -68,7 +68,8 @@ struct object *deref_tag(struct object *o, const char *warn, int warnlen) {while (o && o->type ==OBJ_TAG )if (((struct tag *)o)->tagged) - o =parse_object (&((struct tag *)o)->tagged->oid); + o =parse_object (the_repository, + &((struct tag *)o)->tagged->oid);else o =NULL ;if (!o && warn) {
@@ -82,7 +83,7 @@ struct object *deref_tag(struct object *o, const char *warn, int warnlen)struct object *deref_tag_noverify (struct object *o) {while (o && o->type ==OBJ_TAG ) { - o =parse_object (&o->oid); + o =parse_object (the_repository, &o->oid);if (o && o->type ==OBJ_TAG && ((struct tag *)o)->tagged) o = ((struct tag *)o)->tagged;else
tree.c +3 -2
@@ -8,6 +8,7 @@#include "tag.h" #include "alloc.h" #include "tree-walk.h" +#include "repository.h" const char *tree_type ="tree" ;
@@ -244,7 +245,7 @@ void free_tree_buffer(struct tree *tree)struct tree *parse_tree_indirect (const struct object_id *oid) { -struct object *obj =parse_object (oid); +struct object *obj =parse_object (the_repository, oid); do { if (!obj) return NULL;
@@ -257,6 +258,6 @@ struct tree *parse_tree_indirect(const struct object_id *oid)else return NULL ;if (!obj->parsed) -parse_object (&obj->oid); +parse_object (the_repository, &obj->oid); }while (1 ); }
upload-pack.c +7 -6
@@ -3,6 +3,7 @@#include "refs.h" #include "pkt-line.h" #include "sideband.h" +#include "repository.h" #include "object-store.h" #include "tag.h" #include "object.h"
@@ -311,7 +312,7 @@ static int got_oid(const char *hex, struct object_id *oid)if (!has_object_file (oid))return -1 ; - o =parse_object (oid); + o =parse_object (the_repository, oid);if (!o)die ("oops (%s)" ,oid_to_hex (oid));if (o->type ==OBJ_COMMIT ) {
@@ -349,7 +350,7 @@ static int reachable(struct commit *want)break ; }if (!commit->object.parsed) -parse_object (&commit->object.oid); +parse_object (the_repository, &commit->object.oid);if (commit->object.flags &REACHABLE )continue ; commit->object.flags |=REACHABLE ;
@@ -800,7 +801,7 @@ static int process_shallow(const char *line, struct object_array *shallows)struct object *object;if (get_oid_hex (arg, &oid))die ("invalid shallow line: %s" , line); - object =parse_object (&oid); + object =parse_object (the_repository, &oid);if (!object)return 1 ;if (object->type !=OBJ_COMMIT )
@@ -926,7 +927,7 @@ static void receive_needs(void)if (allow_filter &&parse_feature_request (features,"filter" )) filter_capability_requested =1 ; - o =parse_object (&oid_buf); + o =parse_object (the_repository, &oid_buf);if (!o) { packet_write_fmt(1, "ERR upload-pack: not our ref %s",
@@ -1167,7 +1168,7 @@ static int parse_want(const char *line)die ("git upload-pack: protocol error, " "expected to get oid, not '%s'" , line); - o =parse_object (&oid); + o =parse_object (the_repository, &oid);if (!o) { packet_write_fmt(1, "ERR upload-pack: not our ref %s",
@@ -1279,7 +1280,7 @@ static int process_haves(struct oid_array *haves, struct oid_array *common)oid_array_append (common, oid); - o =parse_object (oid); + o =parse_object (the_repository, oid);if (!o)die ("oops (%s)" ,oid_to_hex (oid));if (o->type ==OBJ_COMMIT ) {
walker.c +2 -1
@@ -1,5 +1,6 @@#include "cache.h" #include "walker.h" +#include "repository.h" #include "object-store.h" #include "commit.h" #include "tree.h"
@@ -178,7 +179,7 @@ static int loop(struct walker *walker) } }if (!obj->type) -parse_object (&obj->oid); +parse_object (the_repository, &obj->oid);if (process_object (walker, obj))return -1 ; }
Signature · 1 line
2.18.0.399.gad0ab374a1-goog
PATCH v3 3/32 object: add repository argument to parse_object_buffer
In reply to Stefan BellerAdd a repository argument to allow the callers of parse_object_buffer to be more specific about which repository to act on. This is a small mechanical change; it doesn't change the implementation to handle repositories other than the_repository yet.
As with the previous commits, use a macro to catch callers passing a repository other than the_repository at compile time.
--- builtin/fast-export.c | 3 ++- builtin/fsck.c | 7 +++++-- builtin/index-pack.c | 3 ++- builtin/unpack-objects.c | 3 ++- object.c | 5 +++-- object.h | 3 ++- ref-filter.c | 3 ++- 7 files changed, 18 insertions(+), 9 deletions(-)
builtin/fast-export.c +2 -1
@@ -244,7 +244,8 @@ static void export_blob(const struct object_id *oid)die ("Could not read blob %s" ,oid_to_hex (oid));if (check_object_signature (oid, buf, size,type_name (type)) <0 )die ("sha1 mismatch in blob %s" ,oid_to_hex (oid)); - object =parse_object_buffer (oid, type, size, buf, &eaten); + object =parse_object_buffer (the_repository, oid, type, + size, buf, &eaten); }if (!object)
builtin/fsck.c +5 -2
@@ -392,7 +392,8 @@ static int fsck_obj_buffer(const struct object_id *oid, enum object_type type,* verify_packfile(), data_valid variable for details. */ struct object *obj; - obj =parse_object_buffer (oid, type, size, buffer, eaten); + obj =parse_object_buffer (the_repository, oid, type, size, buffer, + eaten);if (!obj) { errors_found |=ERROR_OBJECT ;return error ("%s: object corrupt or missing" ,oid_to_hex (oid));
@@ -525,7 +526,9 @@ static int fsck_loose(const struct object_id *oid, const char *path, void *data)if (!contents && type !=OBJ_BLOB )BUG ("read_loose_object streamed a non-blob" ); - obj =parse_object_buffer (oid, type, size, contents, &eaten); + obj =parse_object_buffer (the_repository, oid, type, size, + contents, &eaten); +if (!obj) { errors_found |=ERROR_OBJECT ; error("%s: object could not be parsed: %s",
builtin/index-pack.c +2 -1
@@ -851,7 +851,8 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,* we do not need to free the memory here, as the * buf is deleted by the caller. */ - obj =parse_object_buffer (oid, type, size, buf, + obj =parse_object_buffer (the_repository, oid, type, + size, buf, &eaten);if (!obj)die (_ ("invalid %s" ),type_name (type));
builtin/unpack-objects.c +2 -1
@@ -265,7 +265,8 @@ static void write_object(unsigned nr, enum object_type type,int eaten;hash_object_file (buf, size,type_name (type), &obj_list[nr].oid);added_object (nr, type, buf, size); - obj =parse_object_buffer (&obj_list[nr].oid, type, size, buf, + obj =parse_object_buffer (the_repository, &obj_list[nr].oid, + type, size, buf, &eaten);if (!obj)die ("invalid %s" ,type_name (type));
object.c +3 -2
@@ -186,7 +186,7 @@ struct object *lookup_unknown_object(const unsigned char *sha1)return obj; } -struct object *parse_object_buffer (const struct object_id *oid,enum object_type type,unsigned long size,void *buffer,int *eaten_p) +struct object *parse_object_buffer_the_repository (const struct object_id *oid,enum object_type type,unsigned long size,void *buffer,int *eaten_p) {struct object *obj; *eaten_p =0 ;
@@ -278,7 +278,8 @@ struct object *parse_object_the_repository(const struct object_id *oid)return NULL ; } - obj =parse_object_buffer (oid, type, size, buffer, &eaten); + obj =parse_object_buffer (the_repository, oid, type, size, + buffer, &eaten);if (!eaten)free (buffer);return obj;
object.h +2 -1
@@ -135,7 +135,8 @@ struct object *parse_object_or_die(const struct object_id *oid, const char *name* parsing it. eaten_p indicates if the object has a borrowed copy * of buffer and the caller should not free() it. */ -struct object *parse_object_buffer (const struct object_id *oid,enum object_type type,unsigned long size,void *buffer,int *eaten_p); +#define parse_object_buffer (r, o, t, s, b, e) parse_object_buffer_##r(o, t, s, b, e) +struct object *parse_object_buffer_the_repository (const struct object_id *oid,enum object_type type,unsigned long size,void *buffer,int *eaten_p);/** Returns the object, with potentially excess memory allocated. **/ struct object *lookup_unknown_object (const unsigned char *sha1);
ref-filter.c +2 -1
@@ -807,7 +807,8 @@ static void *get_obj(const struct object_id *oid, struct object **obj, unsignedvoid *buf =read_object_file (oid, &type, sz);if (buf) - *obj =parse_object_buffer (oid, type, *sz, buf, eaten); + *obj =parse_object_buffer (the_repository, oid, type, *sz, + buf, eaten);else *obj =NULL ;return buf;
Signature · 1 line
2.18.0.399.gad0ab374a1-goog
PATCH v3 5/32 blob: add repository argument to lookup_blob
In reply to Stefan BellerAdd a repository argument to allow the callers of lookup_blob to be more specific about which repository to act on. This is a small mechanical change; it doesn't change the implementation to handle repositories other than the_repository yet.
As with the previous commits, use a macro to catch callers passing a repository other than the_repository at compile time.
--- blob.c | 2 +- blob.h | 3 ++- builtin/fast-export.c | 2 +- builtin/fsck.c | 3 ++- builtin/index-pack.c | 2 +- builtin/merge-tree.c | 3 ++- builtin/unpack-objects.c | 2 +- fsck.c | 4 ++-- http-push.c | 3 ++- list-objects.c | 2 +- object.c | 4 ++-- reachable.c | 2 +- revision.c | 4 ++-- tag.c | 2 +- walker.c | 3 ++- 15 files changed, 23 insertions(+), 18 deletions(-)
blob.c +1 -1
@@ -5,7 +5,7 @@const char *blob_type ="blob" ; -struct blob *lookup_blob (const struct object_id *oid) +struct blob *lookup_blob_the_repository (const struct object_id *oid) {struct object *obj =lookup_object (the_repository, oid->hash);if (!obj)
blob.h +2 -1
@@ -9,7 +9,8 @@ struct blob {struct object object; }; -struct blob *lookup_blob (const struct object_id *oid); +#define lookup_blob (r, o) lookup_blob_##r(o) +struct blob *lookup_blob_the_repository (const struct object_id *oid);int parse_blob_buffer (struct blob *item,void *buffer,unsigned long size);
builtin/fast-export.c +1 -1
@@ -236,7 +236,7 @@ static void export_blob(const struct object_id *oid)if (anonymize) { buf =anonymize_blob (&size); - object = (struct object *)lookup_blob (oid); + object = (struct object *)lookup_blob (the_repository, oid); eaten =0 ; }else { buf =read_object_file (oid, &type, &size);
builtin/fsck.c +2 -1
@@ -810,7 +810,8 @@ int cmd_fsck(int argc, const char **argv, const char *prefix) mode = active_cache[i]->ce_mode;if (S_ISGITLINK (mode))continue ; - blob =lookup_blob (&active_cache[i]->oid); + blob =lookup_blob (the_repository, + &active_cache[i]->oid);if (!blob)continue ; obj = &blob->object;
builtin/index-pack.c +1 -1
@@ -832,7 +832,7 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,if (strict || do_fsck_object) {read_lock ();if (type ==OBJ_BLOB ) { -struct blob *blob =lookup_blob (oid); +struct blob *blob =lookup_blob (the_repository, oid);if (blob) blob->object.flags |=FLAG_CHECKED ;else
builtin/merge-tree.c +2 -1
@@ -2,6 +2,7 @@#include "tree-walk.h" #include "xdiff-interface.h" #include "object-store.h" +#include "repository.h" #include "blob.h" #include "exec-cmd.h" #include "merge-blobs.h"
@@ -170,7 +171,7 @@ static struct merge_list *create_entry(unsigned stage, unsigned mode, const stru res->stage = stage; res->path = path; res->mode = mode; - res->blob =lookup_blob (oid); + res->blob =lookup_blob (the_repository, oid);return res; }
builtin/unpack-objects.c +1 -1
@@ -254,7 +254,7 @@ static void write_object(unsigned nr, enum object_type type,added_object (nr, type, buf, size);free (buf); - blob =lookup_blob (&obj_list[nr].oid); + blob =lookup_blob (the_repository, &obj_list[nr].oid);if (blob) blob->object.flags |=FLAG_WRITTEN ;else
fsck.c +2 -2
@@ -414,7 +414,7 @@ static int fsck_walk_tree(struct tree *tree, void *data, struct fsck_options *op result = options->walk (obj,OBJ_TREE , data, options); }else if (S_ISREG (entry.mode) ||S_ISLNK (entry.mode)) { - obj = (struct object *)lookup_blob (entry.oid); + obj = (struct object *)lookup_blob (the_repository, entry.oid);if (name && obj)put_object_name (options, obj,"%s%s" , name, entry.path);
@@ -1070,7 +1070,7 @@ int fsck_finish(struct fsck_options *options)if (oidset_contains (&gitmodules_done, oid))continue ; - blob =lookup_blob (oid); + blob =lookup_blob (the_repository, oid);if (!blob) {struct object *obj =lookup_unknown_object (oid->hash); ret |= report(options, obj,
http-push.c +2 -1
@@ -1314,7 +1314,8 @@ static struct object_list **process_tree(struct tree *tree, p =process_tree (lookup_tree (entry.oid), p);break ;case OBJ_BLOB : - p =process_blob (lookup_blob (entry.oid), p); + p =process_blob (lookup_blob (the_repository, entry.oid), + p);break ;default :/* Subproject commit - not in this repository */
list-objects.c +1 -1
@@ -167,7 +167,7 @@ static void process_tree(struct rev_info *revs, cb_data); elseprocess_blob (revs , - lookup_blob(entry.oid), + lookup_blob(the_repository, entry.oid), show, base, entry.path,cb_data ,filter_fn ,filter_data ); }
object.c +2 -2
@@ -193,7 +193,7 @@ struct object *parse_object_buffer_the_repository(const struct object_id *oid, e obj =NULL ;if (type ==OBJ_BLOB ) { -struct blob *blob =lookup_blob (oid); +struct blob *blob =lookup_blob (the_repository, oid);if (blob) {if (parse_blob_buffer (blob, buffer, size))return NULL ;
@@ -266,7 +266,7 @@ struct object *parse_object_the_repository(const struct object_id *oid)error ("sha1 mismatch %s" ,oid_to_hex (oid));return NULL ; } -parse_blob_buffer (lookup_blob (oid),NULL ,0 ); +parse_blob_buffer (lookup_blob (the_repository, oid),NULL ,0 );return lookup_object (the_repository, oid->hash); }
reachable.c +1 -1
@@ -91,7 +91,7 @@ static void add_recent_object(const struct object_id *oid, obj = (struct object *)lookup_tree (oid);break ;case OBJ_BLOB : - obj = (struct object *)lookup_blob (oid); + obj = (struct object *)lookup_blob (the_repository, oid);break ;default : die("unknown object type for %s: %s",
revision.c +2 -2
@@ -66,7 +66,7 @@ static void mark_tree_contents_uninteresting(struct tree *tree)mark_tree_uninteresting (lookup_tree (entry.oid));break ;case OBJ_BLOB : -mark_blob_uninteresting (lookup_blob (entry.oid)); +mark_blob_uninteresting (lookup_blob (the_repository, entry.oid));break ;default :/* Subproject commit - not in this repository */
@@ -1348,7 +1348,7 @@ static void do_add_index_objects_to_pending(struct rev_info *revs,if (S_ISGITLINK (ce->ce_mode))continue ; - blob =lookup_blob (&ce->oid); + blob =lookup_blob (the_repository, &ce->oid);if (!blob)die ("unable to add index blob to traversal" ); add_pending_object_with_path(revs, &blob->object, "",
tag.c +1 -1
@@ -154,7 +154,7 @@ int parse_tag_buffer(struct tag *item, const void *data, unsigned long size) bufptr = nl +1 ;if (!strcmp (type, blob_type)) { - item->tagged = (struct object *)lookup_blob (&oid); + item->tagged = (struct object *)lookup_blob (the_repository, &oid); }else if (!strcmp (type, tree_type)) { item->tagged = (struct object *)lookup_tree (&oid); }else if (!strcmp (type, commit_type)) {
walker.c +2 -1
@@ -54,7 +54,8 @@ static int process_tree(struct walker *walker, struct tree *tree) obj = &tree->object; }else { -struct blob *blob =lookup_blob (entry.oid); +struct blob *blob =lookup_blob (the_repository, + entry.oid);if (blob) obj = &blob->object; }
Signature · 1 line
2.18.0.399.gad0ab374a1-goog
PATCH v3 4/32 object: add repository argument to object_as_type
In reply to Stefan Beller--- blob.c | 2 +- builtin/fsck.c | 2 +- commit.c | 4 ++-- object.c | 2 +- object.h | 3 ++- refs.c | 2 +- tag.c | 2 +- tree.c | 2 +- 8 files changed, 10 insertions(+), 9 deletions(-)
blob.c +1 -1
@@ -11,7 +11,7 @@ struct blob *lookup_blob(const struct object_id *oid)if (!obj)return create_object (the_repository, oid->hash,alloc_blob_node (the_repository)); -return object_as_type (obj,OBJ_BLOB ,0 ); +return object_as_type (the_repository, obj,OBJ_BLOB ,0 ); }int parse_blob_buffer (struct blob *item,void *buffer,unsigned long size)
builtin/fsck.c +1 -1
@@ -70,7 +70,7 @@ static const char *printable_type(struct object *obj)enum object_type type =oid_object_info (the_repository, &obj->oid,NULL );if (type >0 ) -object_as_type (obj, type,0 ); +object_as_type (the_repository, obj, type,0 ); } ret =type_name (obj->type);
commit.c +2 -2
@@ -32,7 +32,7 @@ struct commit *lookup_commit_reference_gently(const struct object_id *oid,if (!obj)return NULL ; -return object_as_type (obj,OBJ_COMMIT , quiet); +return object_as_type (the_repository, obj,OBJ_COMMIT , quiet); }struct commit *lookup_commit_reference (const struct object_id *oid)
@@ -58,7 +58,7 @@ struct commit *lookup_commit(const struct object_id *oid)if (!obj)return create_object (the_repository, oid->hash,alloc_commit_node (the_repository)); -return object_as_type (obj,OBJ_COMMIT ,0 ); +return object_as_type (the_repository, obj,OBJ_COMMIT ,0 ); }struct commit *lookup_commit_reference_by_name (const char *name)
object.c +1 -1
@@ -158,7 +158,7 @@ void *create_object(struct repository *r, const unsigned char *sha1, void *o)return obj; } -void *object_as_type (struct object *obj,enum object_type type,int quiet) +void *object_as_type_the_repository (struct object *obj,enum object_type type,int quiet) {if (obj->type == type)return obj;
object.h +2 -1
@@ -114,7 +114,8 @@ struct object *lookup_object_the_repository(const unsigned char *sha1);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); +#define object_as_type (r, o, t, q) object_as_type_##r(o, t, q) +void *object_as_type_the_repository (struct object *obj,enum object_type type,int quiet);/* * Returns the object, having parsed it to find out what it is.
refs.c +1 -1
@@ -305,7 +305,7 @@ enum peel_status peel_object(const struct object_id *name, struct object_id *oidif (o->type ==OBJ_NONE ) {int type =oid_object_info (the_repository, name,NULL ); -if (type <0 || !object_as_type (o, type,0 )) +if (type <0 || !object_as_type (the_repository, o, type,0 ))return PEEL_INVALID ; }
tag.c +1 -1
@@ -98,7 +98,7 @@ struct tag *lookup_tag(const struct object_id *oid)if (!obj)return create_object (the_repository, oid->hash,alloc_tag_node (the_repository)); -return object_as_type (obj,OBJ_TAG ,0 ); +return object_as_type (the_repository, obj,OBJ_TAG ,0 ); }static timestamp_t parse_tag_date (const char *buf,const char *tail)
tree.c +1 -1
@@ -201,7 +201,7 @@ struct tree *lookup_tree(const struct object_id *oid)if (!obj)return create_object (the_repository, oid->hash,alloc_tree_node (the_repository)); -return object_as_type (obj,OBJ_TREE ,0 ); +return object_as_type (the_repository, obj,OBJ_TREE ,0 ); }int parse_tree_buffer (struct tree *item,void *buffer,unsigned long size)
Signature · 1 line
2.18.0.399.gad0ab374a1-goog
PATCH v3 8/32 commit: add repository argument to lookup_commit_reference
In reply to Stefan BellerAdd a repository argument to allow callers of lookup_commit_reference to be more specific about which repository to handle. This is a small mechanical change; it doesn't change the implementation to handle repositories other than the_repository yet.
As with the previous commits, use a macro to catch callers passing a repository other than the_repository at compile time.
--- bisect.c | 2 +- blame.c | 2 +- branch.c | 2 +- builtin/branch.c | 7 ++++--- builtin/clone.c | 3 ++- builtin/describe.c | 2 +- builtin/diff-tree.c | 2 +- builtin/log.c | 7 ++++--- builtin/merge-base.c | 5 +++-- builtin/notes.c | 3 ++- builtin/pull.c | 15 ++++++++++----- builtin/replace.c | 4 ++-- builtin/reset.c | 4 ++-- builtin/rev-parse.c | 6 +++--- builtin/show-branch.c | 2 +- builtin/tag.c | 2 +- bundle.c | 3 ++- commit.c | 6 +++--- commit.h | 4 +++- merge-recursive.c | 6 +++--- notes-merge.c | 5 +++-- parse-options-cb.c | 2 +- remote.c | 4 ++-- revision.c | 4 ++-- sequencer.c | 6 +++--- sha1-name.c | 4 ++-- submodule.c | 4 ++-- 27 files changed, 65 insertions(+), 51 deletions(-)
bisect.c +1 -1
@@ -724,7 +724,7 @@ static int bisect_checkout(const struct object_id *bisect_rev, int no_checkout)static struct commit *get_commit_reference (const struct object_id *oid) { -struct commit *r =lookup_commit_reference (oid); +struct commit *r =lookup_commit_reference (the_repository, oid);if (!r)die (_ ("Not a valid commit name %s" ),oid_to_hex (oid));return r;
blame.c +1 -1
@@ -119,7 +119,7 @@ static struct commit_list **append_parent(struct commit_list **tail, const struc {struct commit *parent; - parent =lookup_commit_reference (oid); + parent =lookup_commit_reference (the_repository, oid);if (!parent)die ("no such commit %s" ,oid_to_hex (oid));return &commit_list_insert (parent, tail)->next;
branch.c +1 -1
@@ -302,7 +302,7 @@ void create_branch(const char *name, const char *start_name,break ; } -if ((commit =lookup_commit_reference (&oid)) ==NULL ) +if ((commit =lookup_commit_reference (the_repository, &oid)) ==NULL )die (_ ("Not a valid branch point: '%s'." ), start_name);oidcpy (&oid, &commit->object.oid);
builtin/branch.c +4 -3
@@ -121,7 +121,8 @@ static int branch_merged(int kind, const char *name, (reference_name = reference_name_to_free = resolve_refdup(upstream, RESOLVE_REF_READING, &oid, NULL)) != NULL) - reference_rev =lookup_commit_reference (&oid); + reference_rev =lookup_commit_reference (the_repository, + &oid); }if (!reference_rev) reference_rev = head_rev;
@@ -154,7 +155,7 @@ static int check_branch_commit(const char *branchname, const char *refname, const struct object_id *oid, struct commit *head_rev, int kinds, int force) { - struct commit *rev = lookup_commit_reference(oid); + struct commit *rev = lookup_commit_reference(the_repository, oid);if (!rev) {error (_ ("Couldn't look up commit object for '%s'" ), refname);return -1 ;
@@ -208,7 +209,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds, }if (!force) { - head_rev =lookup_commit_reference (&head_oid); + head_rev =lookup_commit_reference (the_repository, &head_oid);if (!head_rev)die (_ ("Couldn't look up commit object for HEAD" )); }
builtin/clone.c +2 -1
@@ -696,7 +696,8 @@ static void update_head(const struct ref *our, const struct ref *remote,install_branch_config (0 , head, option_origin, our->name); } }else if (our) { -struct commit *c =lookup_commit_reference (&our->old_oid); +struct commit *c =lookup_commit_reference (the_repository, + &our->old_oid);/* --branch specifies a non-branch (i.e. tags), detach HEAD */ update_ref (msg,"HEAD" , &c->object.oid,NULL ,REF_NO_DEREF ,UPDATE_REFS_DIE_ON_ERR );
builtin/describe.c +1 -1
@@ -303,7 +303,7 @@ static void describe_commit(struct object_id *oid, struct strbuf *dst)unsigned long seen_commits =0 ;unsigned int unannotated_cnt =0 ; - cmit =lookup_commit_reference (oid); + cmit =lookup_commit_reference (the_repository, oid); n =find_commit_name (&cmit->object.oid);if (n && (tags || all || n->prio ==2 )) {
builtin/diff-tree.c +1 -1
@@ -11,7 +11,7 @@ static struct rev_info log_tree_opt;static int diff_tree_commit_oid (const struct object_id *oid) { -struct commit *commit =lookup_commit_reference (oid); +struct commit *commit =lookup_commit_reference (the_repository, oid);if (!commit)return -1 ;return log_tree_commit (&log_tree_opt, commit);
builtin/log.c +4 -3
@@ -907,8 +907,8 @@ static void get_patch_ids(struct rev_info *rev, struct patch_ids *ids) o2 = rev->pending.objects[1 ].item; flags1 = o1->flags; flags2 = o2->flags; - c1 =lookup_commit_reference (&o1->oid); - c2 =lookup_commit_reference (&o2->oid); + c1 =lookup_commit_reference (the_repository, &o1->oid); + c2 =lookup_commit_reference (the_repository, &o2->oid);if ((flags1 &UNINTERESTING ) == (flags2 &UNINTERESTING ))die (_ ("Not a range." ));
@@ -1864,7 +1864,8 @@ static int add_pending_commit(const char *arg, struct rev_info *revs, int flags) {struct object_id oid;if (get_oid (arg, &oid) ==0 ) { -struct commit *commit =lookup_commit_reference (&oid); +struct commit *commit =lookup_commit_reference (the_repository, + &oid);if (commit) { commit->object.flags |= flags;add_pending_object (revs, &commit->object, arg);
builtin/merge-base.c +3 -2
@@ -6,6 +6,7 @@#include "diff.h" #include "revision.h" #include "parse-options.h" +#include "repository.h" static int show_merge_base (struct commit **rev,int rev_nr,int show_all) {
@@ -42,7 +43,7 @@ static struct commit *get_commit_reference(const char *arg)if (get_oid (arg, &revkey))die ("Not a valid object name %s" , arg); - r =lookup_commit_reference (&revkey); + r =lookup_commit_reference (the_repository, &revkey);if (!r)die ("Not a valid commit name %s" , arg);
@@ -171,7 +172,7 @@ static int handle_fork_point(int argc, const char **argv)if (get_oid (commitname, &oid))die ("Not a valid object name: '%s'" , commitname); - derived =lookup_commit_reference (&oid); + derived =lookup_commit_reference (the_repository, &oid);memset (&revs,0 ,sizeof (revs)); revs.initial =1 ;for_each_reflog_ent (refname, collect_one_reflog_ent, &revs);
builtin/notes.c +2 -1
@@ -12,6 +12,7 @@#include "builtin.h" #include "notes.h" #include "object-store.h" +#include "repository.h" #include "blob.h" #include "pretty.h" #include "refs.h"
@@ -711,7 +712,7 @@ static int merge_commit(struct notes_merge_options *o)if (get_oid ("NOTES_MERGE_PARTIAL" , &oid))die (_ ("failed to read ref NOTES_MERGE_PARTIAL" )); -else if (!(partial =lookup_commit_reference (&oid))) +else if (!(partial =lookup_commit_reference (the_repository, &oid)))die (_ ("could not find commit from NOTES_MERGE_PARTIAL." ));else if (parse_commit (partial))die (_ ("could not parse commit from NOTES_MERGE_PARTIAL." ));
builtin/pull.c +10 -5
@@ -765,10 +765,13 @@ static int get_octopus_merge_base(struct object_id *merge_base, {struct commit_list *revs =NULL , *result; -commit_list_insert (lookup_commit_reference (curr_head), &revs); -commit_list_insert (lookup_commit_reference (merge_head), &revs); +commit_list_insert (lookup_commit_reference (the_repository, curr_head), + &revs); +commit_list_insert (lookup_commit_reference (the_repository, merge_head), + &revs);if (!is_null_oid (fork_point)) -commit_list_insert (lookup_commit_reference (fork_point), &revs); +commit_list_insert (lookup_commit_reference (the_repository, fork_point), + &revs); result =get_octopus_merge_bases (revs);free_commit_list (revs);
@@ -944,9 +947,11 @@ int cmd_pull(int argc, const char **argv, const char *prefix)struct commit_list *list =NULL ;struct commit *merge_head, *head; - head =lookup_commit_reference (&orig_head); + head =lookup_commit_reference (the_repository, + &orig_head);commit_list_insert (head, &list); - merge_head =lookup_commit_reference (&merge_heads.oid[0 ]); + merge_head =lookup_commit_reference (the_repository, + &merge_heads.oid[0 ]);if (is_descendant_of (merge_head, list)) {/* we can fast-forward this without invoking rebase */ opt_ff ="--ff-only" ;
builtin/replace.c +2 -2
@@ -371,7 +371,7 @@ static int replace_parents(struct strbuf *buf, int argc, const char **argv)return error (_ ("Not a valid object name: '%s'" ), argv[i]); } -if (!lookup_commit_reference (&oid)) { +if (!lookup_commit_reference (the_repository, &oid)) {strbuf_release (&new_parents);return error (_ ("could not parse %s" ), argv[i]); }
@@ -443,7 +443,7 @@ static int create_graft(int argc, const char **argv, int force, int gentle)if (get_oid (old_ref, &old_oid) <0 )return error (_ ("Not a valid object name: '%s'" ), old_ref); - commit =lookup_commit_reference (&old_oid); + commit =lookup_commit_reference (the_repository, &old_oid);if (!commit)return error (_ ("could not parse %s" ), old_ref);
builtin/reset.c +2 -2
@@ -319,7 +319,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)struct commit *commit;if (get_oid_committish (rev, &oid))die (_ ("Failed to resolve '%s' as a valid revision." ), rev); - commit =lookup_commit_reference (&oid); + commit =lookup_commit_reference (the_repository, &oid);if (!commit)die (_ ("Could not parse object '%s'." ), rev);oidcpy (&oid, &commit->object.oid);
@@ -396,7 +396,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix) update_ref_status =reset_refs (rev, &oid);if (reset_type ==HARD && !update_ref_status && !quiet) -print_new_head_line (lookup_commit_reference (&oid)); +print_new_head_line (lookup_commit_reference (the_repository, &oid)); }if (!pathspec.nr)remove_branch_state ();
builtin/rev-parse.c +3 -3
@@ -280,8 +280,8 @@ static int try_difference(const char *arg)if (symmetric) {struct commit_list *exclude;struct commit *a, *b; - a =lookup_commit_reference (&start_oid); - b =lookup_commit_reference (&end_oid); + a =lookup_commit_reference (the_repository, &start_oid); + b =lookup_commit_reference (the_repository, &end_oid);if (!a || !b) { *dotdot ='.' ;return 0 ;
@@ -333,7 +333,7 @@ static int try_parent_shorthands(const char *arg) *dotdot =0 ;if (get_oid_committish (arg, &oid) || - !(commit =lookup_commit_reference (&oid))) { + !(commit =lookup_commit_reference (the_repository, &oid))) { *dotdot ='^' ;return 0 ; }
builtin/show-branch.c +1 -1
@@ -831,7 +831,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix) MAX_REVS), MAX_REVS);if (get_oid (ref_name[num_rev], &revkey))die (_ ("'%s' is not a valid ref." ), ref_name[num_rev]); - commit =lookup_commit_reference (&revkey); + commit =lookup_commit_reference (the_repository, &revkey);if (!commit)die (_ ("cannot find commit %s (%s)" ), ref_name[num_rev],oid_to_hex (&revkey));
builtin/tag.c +1 -1
@@ -313,7 +313,7 @@ static void create_reflog_msg(const struct object_id *oid, struct strbuf *sb) }free (buf); -if ((c =lookup_commit_reference (oid)) !=NULL ) +if ((c =lookup_commit_reference (the_repository, oid)) !=NULL )strbuf_addf (sb,", %s" ,show_date (c->date,0 ,DATE_MODE (SHORT )));break ;case OBJ_TREE :
bundle.c +2 -1
@@ -375,7 +375,8 @@ static int write_bundle_refs(int bundle_fd, struct rev_info *revs)* in terms of a tag (e.g. v2.0 from the range * "v1.0..v2.0")? */ -struct commit *one =lookup_commit_reference (&oid); +struct commit *one =lookup_commit_reference (the_repository, + &oid);struct object *obj;if (e->item == &(one->object)) {
commit.c +3 -3
@@ -35,14 +35,14 @@ struct commit *lookup_commit_reference_gently_the_repository(return object_as_type (the_repository, obj,OBJ_COMMIT , quiet); } -struct commit *lookup_commit_reference (const struct object_id *oid) +struct commit *lookup_commit_reference_the_repository (const struct object_id *oid) {return lookup_commit_reference_gently (the_repository, oid,0 ); }struct commit *lookup_commit_or_die (const struct object_id *oid,const char *ref_name) { -struct commit *c =lookup_commit_reference (oid); +struct commit *c =lookup_commit_reference (the_repository, oid);if (!c)die (_ ("could not parse %s" ), ref_name);if (oidcmp (oid, &c->object.oid)) {
@@ -68,7 +68,7 @@ struct commit *lookup_commit_reference_by_name(const char *name)if (get_oid_committish (name, &oid))return NULL ; - commit =lookup_commit_reference (&oid); + commit =lookup_commit_reference (the_repository, &oid);if (parse_commit (commit))return NULL ;return commit;
commit.h +3 -1
@@ -64,7 +64,9 @@ void add_name_decoration(enum decoration_type type, const char *name, struct objconst struct name_decoration *get_name_decoration (const struct object *obj);struct commit *lookup_commit (const struct object_id *oid); -struct commit *lookup_commit_reference (const struct object_id *oid); +#define lookup_commit_reference (r, o) \ + lookup_commit_reference_##r(o) +struct commit *lookup_commit_reference_the_repository (const struct object_id *oid);#define lookup_commit_reference_gently (r, o, q) \ lookup_commit_reference_gently_##r(o, q) struct commit *lookup_commit_reference_gently_the_repository(
merge-recursive.c +3 -3
@@ -1192,9 +1192,9 @@ static int merge_submodule(struct merge_options *o,return 0 ; } -if (!(commit_base =lookup_commit_reference (base)) || - !(commit_a =lookup_commit_reference (a)) || - !(commit_b =lookup_commit_reference (b))) { +if (!(commit_base =lookup_commit_reference (the_repository, base)) || + !(commit_a =lookup_commit_reference (the_repository, a)) || + !(commit_b =lookup_commit_reference (the_repository, b))) {output (o,1 ,_ ("Failed to merge submodule %s (commits not present)" ), path);return 0 ; }
notes-merge.c +3 -2
@@ -2,6 +2,7 @@#include "commit.h" #include "refs.h" #include "object-store.h" +#include "repository.h" #include "diff.h" #include "diffcore.h" #include "xdiff-interface.h"
@@ -553,7 +554,7 @@ int notes_merge(struct notes_merge_options *o,else if (!check_refname_format (o->local_ref,0 ) &&is_null_oid (&local_oid)) local =NULL ;/* local_oid == null_oid indicates unborn ref */ -else if (!(local =lookup_commit_reference (&local_oid))) +else if (!(local =lookup_commit_reference (the_repository, &local_oid)))die ("Could not parse local commit %s (%s)" ,oid_to_hex (&local_oid), o->local_ref);trace_printf ("\tlocal commit: %.7s\n" ,oid_to_hex (&local_oid));
@@ -571,7 +572,7 @@ int notes_merge(struct notes_merge_options *o,die ("Failed to resolve remote notes ref '%s'" , o->remote_ref); } - }else if (!(remote =lookup_commit_reference (&remote_oid))) { + }else if (!(remote =lookup_commit_reference (the_repository, &remote_oid))) {die ("Could not parse remote commit %s (%s)" ,oid_to_hex (&remote_oid), o->remote_ref); }
parse-options-cb.c +1 -1
@@ -91,7 +91,7 @@ int parse_opt_commits(const struct option *opt, const char *arg, int unset)return -1 ;if (get_oid (arg, &oid))return error ("malformed object name %s" , arg); - commit =lookup_commit_reference (&oid); + commit =lookup_commit_reference (the_repository, &oid);if (!commit)return error ("no such commit %s" , arg);commit_list_insert (commit, opt->value);
remote.c +2 -2
@@ -1865,13 +1865,13 @@ int stat_tracking_info(struct branch *branch, int *num_ours, int *num_theirs,/* Cannot stat if what we used to build on no longer exists */ if (read_ref (base, &oid))return -1 ; - theirs =lookup_commit_reference (&oid); + theirs =lookup_commit_reference (the_repository, &oid);if (!theirs)return -1 ;if (read_ref (branch->refname, &oid))return -1 ; - ours =lookup_commit_reference (&oid); + ours =lookup_commit_reference (the_repository, &oid);if (!ours)return -1 ;
revision.c +2 -2
@@ -1591,8 +1591,8 @@ static int handle_dotdot_1(const char *arg, char *dotdot,struct commit *a, *b;struct commit_list *exclude; - a =lookup_commit_reference (&a_obj->oid); - b =lookup_commit_reference (&b_obj->oid); + a =lookup_commit_reference (the_repository, &a_obj->oid); + b =lookup_commit_reference (the_repository, &b_obj->oid);if (!a || !b)return dotdot_missing (arg, dotdot, revs, symmetric);
sequencer.c +3 -3
@@ -1176,7 +1176,7 @@ static int parse_head(struct commit **head)if (get_oid ("HEAD" , &oid)) { current_head =NULL ; }else { - current_head =lookup_commit_reference (&oid); + current_head =lookup_commit_reference (the_repository, &oid);if (!current_head)return error (_ ("could not parse HEAD" ));if (oidcmp (&oid, ¤t_head->object.oid)) {
@@ -1511,7 +1511,7 @@ static int update_squash_messages(enum todo_command command,if (get_oid ("HEAD" , &head))return error (_ ("need a HEAD to fixup" )); -if (!(head_commit =lookup_commit_reference (&head))) +if (!(head_commit =lookup_commit_reference (the_repository, &head)))return error (_ ("could not read HEAD" ));if (!(head_message =get_commit_buffer (head_commit,NULL )))return error (_ ("could not read HEAD's commit message" ));
@@ -2009,7 +2009,7 @@ static int parse_insn_line(struct todo_item *item, const char *bol, char *eol)if (status <0 )return -1 ; - item->commit =lookup_commit_reference (&commit_oid); + item->commit =lookup_commit_reference (the_repository, &commit_oid);return !item->commit; }
sha1-name.c +2 -2
@@ -844,7 +844,7 @@ static int get_parent(const char *name, int len,if (ret)return ret; - commit =lookup_commit_reference (&oid); + commit =lookup_commit_reference (the_repository, &oid);if (parse_commit (commit))return -1 ;if (!idx) {
@@ -872,7 +872,7 @@ static int get_nth_ancestor(const char *name, int len, ret =get_oid_1 (name, len, &oid,GET_OID_COMMITTISH );if (ret)return ret; - commit =lookup_commit_reference (&oid); + commit =lookup_commit_reference (the_repository, &oid);if (!commit)return -1 ;
submodule.c +2 -2
@@ -517,8 +517,8 @@ static void show_submodule_header(struct diff_options *o, const char *path,* Attempt to lookup the commit references, and determine if this is * a fast forward or fast backwards update. */ - *left =lookup_commit_reference (one); - *right =lookup_commit_reference (two); + *left =lookup_commit_reference (the_repository, one); + *right =lookup_commit_reference (the_repository, two);/* * Warn about missing commits in the submodule project, but only if
Signature · 1 line
2.18.0.399.gad0ab374a1-goog
PATCH v3 10/32 commit: add repository argument to parse_commit_buffer
In reply to Stefan BellerAdd a repository argument to allow the callers of parse_commit_buffer to be more specific about which repository to act on. This is a small mechanical change; it doesn't change the implementation to handle repositories other than the_repository yet.
As with the previous commits, use a macro to catch callers passing a repository other than the_repository at compile time.
--- commit.c | 4 ++-- commit.h | 3 ++- object.c | 2 +- sha1-file.c | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-)
commit.c +2 -2
@@ -363,7 +363,7 @@ const void *detach_commit_buffer(struct commit *commit, unsigned long *sizep)return ret; } -int parse_commit_buffer (struct commit *item,const void *buffer,unsigned long size,int check_graph) +int parse_commit_buffer_the_repository (struct commit *item,const void *buffer,unsigned long size,int check_graph) {const char *tail = buffer;const char *bufptr = buffer;
@@ -448,7 +448,7 @@ int parse_commit_gently(struct commit *item, int quiet_on_missing)return error ("Object %s not a commit" ,oid_to_hex (&item->object.oid)); } - ret =parse_commit_buffer (item, buffer, size,0 ); + ret =parse_commit_buffer (the_repository, item, buffer, size,0 );if (save_commit_buffer && !ret) {set_commit_buffer (item, buffer, size);return 0 ;
commit.h +2 -1
@@ -82,7 +82,8 @@ struct commit *lookup_commit_reference_by_name(const char *name);*/ struct commit *lookup_commit_or_die (const struct object_id *oid,const char *ref_name); -int parse_commit_buffer (struct commit *item,const void *buffer,unsigned long size,int check_graph); +#define parse_commit_buffer (r, i, b, s, g) parse_commit_buffer_##r(i, b, s, g) +int parse_commit_buffer_the_repository (struct commit *item,const void *buffer,unsigned long size,int check_graph);int parse_commit_gently (struct commit *item,int quiet_on_missing);static inline int parse_commit (struct commit *item) {
object.c +1 -1
@@ -214,7 +214,7 @@ struct object *parse_object_buffer_the_repository(const struct object_id *oid, e }else if (type ==OBJ_COMMIT ) {struct commit *commit =lookup_commit (the_repository, oid);if (commit) { -if (parse_commit_buffer (commit, buffer, size,1 )) +if (parse_commit_buffer (the_repository, commit, buffer, size,1 ))return NULL ;if (!get_cached_commit_buffer (commit,NULL )) {set_commit_buffer (commit, buffer, size);
sha1-file.c +1 -1
@@ -1801,7 +1801,7 @@ static void check_commit(const void *buf, size_t size) {struct commit c;memset (&c,0 ,sizeof (c)); -if (parse_commit_buffer (&c, buf, size,0 )) +if (parse_commit_buffer (the_repository, &c, buf, size,0 ))die ("corrupt commit" ); }
Signature · 1 line
2.18.0.399.gad0ab374a1-goog
PATCH v3 6/32 tree: add repository argument to lookup_tree
In reply to Stefan BellerAdd a repository argument to allow the callers of lookup_tree to be more specific about which repository to act on. This is a small mechanical change; it doesn't change the implementation to handle repositories other than the_repository yet.
As with the previous commits, use a macro to catch callers passing a repository other than the_repository at compile time.
--- builtin/am.c | 6 ++++-- builtin/diff-tree.c | 2 +- builtin/diff.c | 3 ++- builtin/reflog.c | 2 +- cache-tree.c | 3 ++- commit-graph.c | 2 +- commit.c | 2 +- fsck.c | 2 +- http-push.c | 3 ++- list-objects.c | 2 +- merge-recursive.c | 6 +++--- object.c | 2 +- reachable.c | 2 +- revision.c | 4 ++-- sequencer.c | 2 +- tag.c | 2 +- tree.c | 4 ++-- tree.h | 3 ++- walker.c | 3 ++- 19 files changed, 31 insertions(+), 24 deletions(-)
builtin/am.c +4 -2
@@ -32,6 +32,7 @@#include "apply.h" #include "string-list.h" #include "packfile.h" +#include "repository.h" /** * Returns 1 if the file is empty or does not exist, 0 otherwise.
@@ -1400,9 +1401,10 @@ static void write_index_patch(const struct am_state *state)FILE *fp;if (!get_oid_tree ("HEAD" , &head)) - tree =lookup_tree (&head); + tree =lookup_tree (the_repository, &head);else - tree =lookup_tree (the_hash_algo->empty_tree); + tree =lookup_tree (the_repository, + the_repository->hash_algo->empty_tree); fp =xfopen (am_path (state,"patch" ),"w" );init_revisions (&rev_info,NULL );
builtin/diff-tree.c +1 -1
@@ -46,7 +46,7 @@ static int stdin_diff_trees(struct tree *tree1, const char *p)struct tree *tree2;if (!isspace (*p++) ||parse_oid_hex (p, &oid, &p) || *p)return error ("Need exactly two trees, separated by a space" ); - tree2 =lookup_tree (&oid); + tree2 =lookup_tree (the_repository, &oid);if (!tree2 ||parse_tree (tree2))return -1 ; printf("%s %s\n", oid_to_hex(&tree1->object.oid),
builtin/diff.c +2 -1
@@ -386,7 +386,8 @@ int cmd_diff(int argc, const char **argv, const char *prefix)add_head_to_pending (&rev);if (!rev.pending.nr) {struct tree *tree; - tree =lookup_tree (the_hash_algo->empty_tree); + tree =lookup_tree (the_repository, + the_repository->hash_algo->empty_tree);add_pending_object (&rev, &tree->object,"HEAD" ); }break ;
builtin/reflog.c +1 -1
@@ -66,7 +66,7 @@ static int tree_is_complete(const struct object_id *oid)int complete;struct tree *tree; - tree =lookup_tree (oid); + tree =lookup_tree (the_repository, oid);if (!tree)return 0 ;if (tree->object.flags &SEEN )
cache-tree.c +2 -1
@@ -671,7 +671,8 @@ static void prime_cache_tree_rec(struct cache_tree *it, struct tree *tree) cnt++; else {struct cache_tree_sub *sub; -struct tree *subtree =lookup_tree (entry.oid); +struct tree *subtree =lookup_tree (the_repository, + entry.oid);if (!subtree->object.parsed)parse_tree (subtree); sub =cache_tree_sub (it, entry.path);
commit-graph.c +1 -1
@@ -344,7 +344,7 @@ static struct tree *load_tree_for_commit(struct commit_graph *g, struct commit *GRAPH_DATA_WIDTH * (c->graph_pos);hashcpy (oid.hash, commit_data); - c->maybe_tree =lookup_tree (&oid); + c->maybe_tree =lookup_tree (the_repository, &oid);return c->maybe_tree; }
commit.c +1 -1
@@ -383,7 +383,7 @@ int parse_commit_buffer(struct commit *item, const void *buffer, unsigned long sif (get_oid_hex (bufptr +5 , &parent) <0 )return error ("bad tree pointer in commit %s" ,oid_to_hex (&item->object.oid)); - item->maybe_tree =lookup_tree (&parent); + item->maybe_tree =lookup_tree (the_repository, &parent); bufptr += tree_entry_len +1 ;/* "tree " + "hex sha1" + "\n" */ pptr = &item->parents;
fsck.c +1 -1
@@ -407,7 +407,7 @@ static int fsck_walk_tree(struct tree *tree, void *data, struct fsck_options *opcontinue ;if (S_ISDIR (entry.mode)) { - obj = (struct object *)lookup_tree (entry.oid); + obj = (struct object *)lookup_tree (the_repository, entry.oid);if (name && obj)put_object_name (options, obj,"%s%s/" , name, entry.path);
http-push.c +2 -1
@@ -1311,7 +1311,8 @@ static struct object_list **process_tree(struct tree *tree,while (tree_entry (&desc, &entry))switch (object_type (entry.mode)) {case OBJ_TREE : - p =process_tree (lookup_tree (entry.oid), p); + p =process_tree (lookup_tree (the_repository, entry.oid), + p);break ;case OBJ_BLOB : p = process_blob(lookup_blob(the_repository, entry.oid),
list-objects.c +1 -1
@@ -158,7 +158,7 @@ static void process_tree(struct rev_info *revs,if (S_ISDIR (entry.mode))process_tree (revs, -lookup_tree (entry.oid), +lookup_tree (the_repository, entry.oid), show, base, entry.path, cb_data, filter_fn, filter_data);else if (S_ISGITLINK (entry.mode))
merge-recursive.c +3 -3
@@ -158,7 +158,7 @@ static struct tree *shift_tree_object(struct tree *one, struct tree *two, }if (!oidcmp (&two->object.oid, &shifted))return two; -return lookup_tree (&shifted); +return lookup_tree (the_repository, &shifted); }static struct commit *make_virtual_commit (struct tree *tree,const char *comment)
@@ -416,7 +416,7 @@ struct tree *write_tree_from_memory(struct merge_options *o)return NULL ; } - result =lookup_tree (&active_cache_tree->oid); + result =lookup_tree (the_repository, &active_cache_tree->oid);return result; }
@@ -3427,7 +3427,7 @@ int merge_recursive(struct merge_options *o,/* if there is no common ancestor, use an empty tree */ struct tree *tree; - tree =lookup_tree (the_hash_algo->empty_tree); + tree =lookup_tree (the_repository, the_repository->hash_algo->empty_tree); merged_common_ancestors =make_virtual_commit (tree,"ancestor" ); }
object.c +1 -1
@@ -200,7 +200,7 @@ struct object *parse_object_buffer_the_repository(const struct object_id *oid, e obj = &blob->object; } }else if (type ==OBJ_TREE ) { -struct tree *tree =lookup_tree (oid); +struct tree *tree =lookup_tree (the_repository, oid);if (tree) { obj = &tree->object;if (!tree->buffer)
reachable.c +1 -1
@@ -88,7 +88,7 @@ static void add_recent_object(const struct object_id *oid, obj =parse_object_or_die (oid,NULL );break ;case OBJ_TREE : - obj = (struct object *)lookup_tree (oid); + obj = (struct object *)lookup_tree (the_repository, oid);break ;case OBJ_BLOB : obj = (struct object *)lookup_blob (the_repository, oid);
revision.c +2 -2
@@ -63,7 +63,7 @@ static void mark_tree_contents_uninteresting(struct tree *tree)while (tree_entry (&desc, &entry)) {switch (object_type (entry.mode)) {case OBJ_TREE : -mark_tree_uninteresting (lookup_tree (entry.oid)); +mark_tree_uninteresting (lookup_tree (the_repository, entry.oid));break ;case OBJ_BLOB :mark_blob_uninteresting (lookup_blob (the_repository, entry.oid));
@@ -1322,7 +1322,7 @@ static void add_cache_tree(struct cache_tree *it, struct rev_info *revs,int i;if (it->entry_count >=0 ) { -struct tree *tree =lookup_tree (&it->oid); +struct tree *tree =lookup_tree (the_repository, &it->oid);add_pending_object_with_path (revs, &tree->object,"" ,040000 , path->buf); }
sequencer.c +1 -1
@@ -433,7 +433,7 @@ static int read_oneliner(struct strbuf *buf,static struct tree *empty_tree (void ) { -return lookup_tree (the_hash_algo->empty_tree); +return lookup_tree (the_repository, the_repository->hash_algo->empty_tree); }static int error_dirty_index (struct replay_opts *opts)
tag.c +1 -1
@@ -156,7 +156,7 @@ int parse_tag_buffer(struct tag *item, const void *data, unsigned long size)if (!strcmp (type, blob_type)) { item->tagged = (struct object *)lookup_blob (the_repository, &oid); }else if (!strcmp (type, tree_type)) { - item->tagged = (struct object *)lookup_tree (&oid); + item->tagged = (struct object *)lookup_tree (the_repository, &oid); }else if (!strcmp (type, commit_type)) { item->tagged = (struct object *)lookup_commit (&oid); }else if (!strcmp (type, tag_type)) {
tree.c +2 -2
@@ -120,7 +120,7 @@ static int read_tree_1(struct tree *tree, struct strbuf *base, len =tree_entry_len (&entry);strbuf_add (base, entry.path, len);strbuf_addch (base,'/' ); - retval =read_tree_1 (lookup_tree (&oid), + retval =read_tree_1 (lookup_tree (the_repository, &oid), base, stage, pathspec, fn, context);strbuf_setlen (base, oldlen);
@@ -195,7 +195,7 @@ int read_tree(struct tree *tree, int stage, struct pathspec *match,return 0 ; } -struct tree *lookup_tree (const struct object_id *oid) +struct tree *lookup_tree_the_repository (const struct object_id *oid) {struct object *obj =lookup_object (the_repository, oid->hash);if (!obj)
tree.h +2 -1
@@ -12,7 +12,8 @@ struct tree {unsigned long size; }; -struct tree *lookup_tree (const struct object_id *oid); +#define lookup_tree (r, oid) lookup_tree_##r(oid) +struct tree *lookup_tree_the_repository (const struct object_id *oid);int parse_tree_buffer (struct tree *item,void *buffer,unsigned long size);
walker.c +2 -1
@@ -49,7 +49,8 @@ static int process_tree(struct walker *walker, struct tree *tree)if (S_ISGITLINK (entry.mode))continue ;if (S_ISDIR (entry.mode)) { -struct tree *tree =lookup_tree (entry.oid); +struct tree *tree =lookup_tree (the_repository, + entry.oid);if (tree) obj = &tree->object; }
Signature · 1 line
2.18.0.399.gad0ab374a1-goog
PATCH v3 11/32 commit: add repository argument to set_commit_buffer
In reply to Stefan BellerAdd a repository argument to allow callers of set_commit_buffer to be more specific about which repository to handle. This is a small mechanical change; it doesn't change the implementation to handle repositories other than the_repository yet.
As with the previous commits, use a macro to catch callers passing a repository other than the_repository at compile time.
--- blame.c | 2 +- commit.c | 4 ++-- commit.h | 3 ++- object.c | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-)
blame.c +1 -1
@@ -158,7 +158,7 @@ static void set_commit_buffer_from_strbuf(struct commit *c, struct strbuf *sb) {size_t len;void *buf =strbuf_detach (sb, &len); -set_commit_buffer (c, buf, len); +set_commit_buffer (the_repository, c, buf, len); }/*
commit.c +2 -2
@@ -262,7 +262,7 @@ struct commit_buffer { define_commit_slab(buffer_slab, struct commit_buffer);static struct buffer_slab buffer_slab =COMMIT_SLAB_INIT (1 , buffer_slab); -void set_commit_buffer (struct commit *commit,void *buffer,unsigned long size) +void set_commit_buffer_the_repository (struct commit *commit,void *buffer,unsigned long size) {struct commit_buffer *v =buffer_slab_at (&buffer_slab, commit); v->buffer = buffer;
@@ -450,7 +450,7 @@ int parse_commit_gently(struct commit *item, int quiet_on_missing) } ret =parse_commit_buffer (the_repository, item, buffer, size,0 );if (save_commit_buffer && !ret) { -set_commit_buffer (item, buffer, size); +set_commit_buffer (the_repository, item, buffer, size);return 0 ; }free (buffer);
commit.h +2 -1
@@ -95,7 +95,8 @@ void parse_commit_or_die(struct commit *item);* Associate an object buffer with the commit. The ownership of the * memory is handed over to the commit, and must be free()-able. */ -void set_commit_buffer (struct commit *,void *buffer,unsigned long size); +#define set_commit_buffer (r, c, b, s) set_commit_buffer_##r(c, b, s) +void set_commit_buffer_the_repository (struct commit *,void *buffer,unsigned long size);/* * Get any cached object buffer associated with the commit. Returns NULL
object.c +1 -1
@@ -217,7 +217,7 @@ struct object *parse_object_buffer_the_repository(const struct object_id *oid, eif (parse_commit_buffer (the_repository, commit, buffer, size,1 ))return NULL ;if (!get_cached_commit_buffer (commit,NULL )) { -set_commit_buffer (commit, buffer, size); +set_commit_buffer (the_repository, commit, buffer, size); *eaten_p =1 ; } obj = &commit->object;
Signature · 1 line
2.18.0.399.gad0ab374a1-goog
PATCH v3 12/32 commit: add repository argument to get_cached_commit_buffer
In reply to Stefan BellerAdd a repository argument to allow callers of get_cached_commit_buffer to be more specific about which repository to handle. This is a small mechanical change; it doesn't change the implementation to handle repositories other than the_repository yet.
As with the previous commits, use a macro to catch callers passing a repository other than the_repository at compile time.
--- commit.c | 4 ++-- commit.h | 3 ++- object.c | 2 +- pretty.c | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-)
commit.c +2 -2
@@ -269,7 +269,7 @@ void set_commit_buffer_the_repository(struct commit *commit, void *buffer, unsig v->size = size; } -const void *get_cached_commit_buffer (const struct commit *commit,unsigned long *sizep) +const void *get_cached_commit_buffer_the_repository (const struct commit *commit,unsigned long *sizep) {struct commit_buffer *v =buffer_slab_peek (&buffer_slab, commit);if (!v) {
@@ -284,7 +284,7 @@ const void *get_cached_commit_buffer(const struct commit *commit, unsigned longconst void *get_commit_buffer (const struct commit *commit,unsigned long *sizep) { -const void *ret =get_cached_commit_buffer (commit, sizep); +const void *ret =get_cached_commit_buffer (the_repository, commit, sizep);if (!ret) {enum object_type type;unsigned long size;
commit.h +2 -1
@@ -102,7 +102,8 @@ void set_commit_buffer_the_repository(struct commit *, void *buffer, unsigned lo* Get any cached object buffer associated with the commit. Returns NULL * if none. The resulting memory should not be freed. */ -const void *get_cached_commit_buffer (const struct commit *,unsigned long *size); +#define get_cached_commit_buffer (r, c, s) get_cached_commit_buffer_##r(c, s) +const void *get_cached_commit_buffer_the_repository (const struct commit *,unsigned long *size);/* * Get the commit's object contents, either from cache or by reading the object
object.c +1 -1
@@ -216,7 +216,7 @@ struct object *parse_object_buffer_the_repository(const struct object_id *oid, eif (commit) {if (parse_commit_buffer (the_repository, commit, buffer, size,1 ))return NULL ; -if (!get_cached_commit_buffer (commit,NULL )) { +if (!get_cached_commit_buffer (the_repository, commit,NULL )) {set_commit_buffer (the_repository, commit, buffer, size); *eaten_p =1 ; }
pretty.c +1 -1
@@ -630,7 +630,7 @@ const char *logmsg_reencode(const struct commit *commit,* the cached copy from get_commit_buffer, we need to duplicate it * to avoid munging the cached copy. */ -if (msg ==get_cached_commit_buffer (commit,NULL )) +if (msg ==get_cached_commit_buffer (the_repository, commit,NULL )) out =xstrdup (msg);else out = (char *)msg;
Signature · 1 line
2.18.0.399.gad0ab374a1-goog
PATCH v3 14/32 tag: add repository argument to parse_tag_buffer
In reply to Stefan BellerAdd a repository argument to allow the callers of parse_tag_buffer to be more specific about which repository to act on. This is a small mechanical change; it doesn't change the implementation to handle repositories other than the_repository yet.
As with the previous commits, use a macro to catch callers passing a repository other than the_repository at compile time.
--- builtin/replace.c | 2 +- log-tree.c | 2 +- object.c | 2 +- sha1-file.c | 2 +- tag.c | 4 ++-- tag.h | 3 ++- 6 files changed, 8 insertions(+), 7 deletions(-)
builtin/replace.c +1 -1
@@ -405,7 +405,7 @@ static int check_one_mergetag(struct commit *commit, tag =lookup_tag (the_repository, &tag_oid);if (!tag)return error (_ ("bad mergetag in commit '%s'" ), ref); -if (parse_tag_buffer (tag, extra->value, extra->len)) +if (parse_tag_buffer (the_repository, tag, extra->value, extra->len))return error (_ ("malformed mergetag in commit '%s'" ), ref);/* iterate over new parents */
log-tree.c +1 -1
@@ -503,7 +503,7 @@ static int show_one_mergetag(struct commit *commit,return -1 ;/* error message already given */ strbuf_init (&verify_message,256 ); -if (parse_tag_buffer (tag, extra->value, extra->len)) +if (parse_tag_buffer (the_repository, tag, extra->value, extra->len))strbuf_addstr (&verify_message,"malformed mergetag\n" );else if (is_common_merge (commit) && !oidcmp(&tag->tagged->oid,
object.c +1 -1
@@ -225,7 +225,7 @@ struct object *parse_object_buffer_the_repository(const struct object_id *oid, e }else if (type ==OBJ_TAG ) {struct tag *tag =lookup_tag (the_repository, oid);if (tag) { -if (parse_tag_buffer (tag, buffer, size)) +if (parse_tag_buffer (the_repository, tag, buffer, size))return NULL ; obj = &tag->object; }
sha1-file.c +1 -1
@@ -1809,7 +1809,7 @@ static void check_tag(const void *buf, size_t size) {struct tag t;memset (&t,0 ,sizeof (t)); -if (parse_tag_buffer (&t, buf, size)) +if (parse_tag_buffer (the_repository, &t, buf, size))die ("corrupt tag" ); }
tag.c +2 -2
@@ -126,7 +126,7 @@ void release_tag_memory(struct tag *t) t->date =0 ; } -int parse_tag_buffer (struct tag *item,const void *data,unsigned long size) +int parse_tag_buffer_the_repository (struct tag *item,const void *data,unsigned long size) {struct object_id oid;char type[20 ];
@@ -203,7 +203,7 @@ int parse_tag(struct tag *item)return error ("Object %s not a tag" ,oid_to_hex (&item->object.oid)); } - ret =parse_tag_buffer (item, data, size); + ret =parse_tag_buffer (the_repository, item, data, size);free (data);return ret; }
tag.h +2 -1
@@ -13,7 +13,8 @@ struct tag { };#define lookup_tag (r, o) lookup_tag_##r(o)extern struct tag *lookup_tag_the_repository (const struct object_id *oid); -extern int parse_tag_buffer (struct tag *item,const void *data,unsigned long size); +#define parse_tag_buffer (r, i, d, s) parse_tag_buffer_##r(i, d, s) +extern int parse_tag_buffer_the_repository (struct tag *item,const void *data,unsigned long size);extern int parse_tag (struct tag *item);extern void release_tag_memory (struct tag *t);extern struct object *deref_tag (struct object *,const char *,int );
Signature · 1 line
2.18.0.399.gad0ab374a1-goog
PATCH v3 15/32 tag: add repository argument to deref_tag
In reply to Stefan BellerAdd a repository argument to allow the callers of deref_tag to be more specific about which repository to act on. This is a small mechanical change; it doesn't change the implementation to handle repositories other than the_repository yet.
As with the previous commits, use a macro to catch callers passing a repository other than the_repository at compile time.
--- blame.c | 6 +++--- builtin/diff.c | 2 +- builtin/fmt-merge-msg.c | 3 ++- builtin/grep.c | 3 ++- builtin/name-rev.c | 3 ++- commit.c | 3 ++- fetch-pack.c | 9 ++++++--- http-backend.c | 2 +- http-push.c | 2 +- line-log.c | 2 +- merge-recursive.c | 3 ++- remote.c | 6 ++++-- server-info.c | 2 +- sha1-name.c | 11 +++++++---- shallow.c | 4 +++- tag.c | 2 +- tag.h | 3 ++- upload-pack.c | 2 +- 18 files changed, 42 insertions(+), 26 deletions(-)
blame.c +3 -3
@@ -1674,7 +1674,7 @@ static struct commit *find_single_final(struct rev_info *revs,struct object *obj = revs->pending.objects[i].item;if (obj->flags &UNINTERESTING )continue ; - obj =deref_tag (obj,NULL ,0 ); + obj =deref_tag (the_repository, obj,NULL ,0 );if (obj->type !=OBJ_COMMIT )die ("Non commit %s?" , revs->pending.objects[i].name);if (found)
@@ -1705,7 +1705,7 @@ static struct commit *dwim_reverse_initial(struct rev_info *revs,/* Is that sole rev a committish? */ obj = revs->pending.objects[0 ].item; - obj =deref_tag (obj,NULL ,0 ); + obj =deref_tag (the_repository, obj,NULL ,0 );if (obj->type !=OBJ_COMMIT )return NULL ;
@@ -1741,7 +1741,7 @@ static struct commit *find_single_initial(struct rev_info *revs,struct object *obj = revs->pending.objects[i].item;if (!(obj->flags &UNINTERESTING ))continue ; - obj =deref_tag (obj,NULL ,0 ); + obj =deref_tag (the_repository, obj,NULL ,0 );if (obj->type !=OBJ_COMMIT )die ("Non commit %s?" , revs->pending.objects[i].name);if (found)
builtin/diff.c +1 -1
@@ -402,7 +402,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)int flags = (obj->flags &UNINTERESTING );if (!obj->parsed) obj =parse_object (the_repository, &obj->oid); - obj =deref_tag (obj,NULL ,0 ); + obj =deref_tag (the_repository, obj,NULL ,0 );if (!obj)die (_ ("invalid object '%s' given." ), name);if (obj->type ==OBJ_COMMIT )
builtin/fmt-merge-msg.c +2 -1
@@ -344,7 +344,8 @@ static void shortlog(const char *name,const struct object_id *oid = &origin_data->oid;int limit = opts->shortlog_len; - branch =deref_tag (parse_object (the_repository, oid),oid_to_hex (oid), + branch =deref_tag (the_repository,parse_object (the_repository, oid), +oid_to_hex (oid),GIT_SHA1_HEXSZ );if (!branch || branch->type !=OBJ_COMMIT )return ;
builtin/grep.c +2 -1
@@ -647,7 +647,8 @@ static int grep_objects(struct grep_opt *opt, const struct pathspec *pathspec,for (i =0 ; i < nr; i++) {struct object *real_obj; - real_obj =deref_tag (list->objects[i].item,NULL ,0 ); + real_obj =deref_tag (the_repository, list->objects[i].item, +NULL ,0 );/* load the gitmodules file for this rev */ if (recurse_submodules) {
builtin/name-rev.c +2 -1
@@ -455,7 +455,8 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix) commit =NULL ; object =parse_object (the_repository, &oid);if (object) { -struct object *peeled =deref_tag (object, *argv,0 ); +struct object *peeled =deref_tag (the_repository, + object, *argv,0 );if (peeled && peeled->type ==OBJ_COMMIT ) commit = (struct commit *)peeled; }
commit.c +2 -1
@@ -27,7 +27,8 @@ const char *commit_type = "commit";struct commit *lookup_commit_reference_gently_the_repository (const struct object_id *oid,int quiet) { -struct object *obj =deref_tag (parse_object (the_repository, oid), +struct object *obj =deref_tag (the_repository, +parse_object (the_repository, oid),NULL ,0 );if (!obj)
fetch-pack.c +6 -3
@@ -126,7 +126,8 @@ static void rev_list_push(struct commit *commit, int mark)static int rev_list_insert_ref (const char *refname,const struct object_id *oid) { -struct object *o =deref_tag (parse_object (the_repository, oid), +struct object *o =deref_tag (the_repository, +parse_object (the_repository, oid), refname,0 );if (o && o->type ==OBJ_COMMIT )
@@ -144,7 +145,8 @@ static int rev_list_insert_ref_oid(const char *refname, const struct object_id *static int clear_marks (const char *refname,const struct object_id *oid,int flag,void *cb_data) { -struct object *o =deref_tag (parse_object (the_repository, oid), +struct object *o =deref_tag (the_repository, +parse_object (the_repository, oid), refname,0 );if (o && o->type ==OBJ_COMMIT )
@@ -802,7 +804,8 @@ static int everything_local(struct fetch_pack_args *args,* Don't mark them common yet; the server has to be told so first. */ for (ref = *refs; ref; ref = ref->next) { -struct object *o =deref_tag (lookup_object (the_repository, +struct object *o =deref_tag (the_repository, +lookup_object (the_repository, ref->old_oid.hash),NULL ,0 );
http-backend.c +1 -1
@@ -442,7 +442,7 @@ static int show_text_ref(const char *name, const struct object_id *oid,strbuf_addf (buf,"%s\t%s\n" ,oid_to_hex (oid), name_nons);if (o->type ==OBJ_TAG ) { - o =deref_tag (o, name,0 ); + o =deref_tag (the_repository, o, name,0 );if (!o)return 0 ; strbuf_addf(buf, "%s\t%s^{}\n", oid_to_hex(&o->oid),
http-push.c +1 -1
@@ -1477,7 +1477,7 @@ static void add_remote_info_ref(struct remote_ls_ctx *ls) oid_to_hex(&ref->old_oid), ls->dentry_name);if (o->type ==OBJ_TAG ) { - o =deref_tag (o, ls->dentry_name,0 ); + o =deref_tag (the_repository, o, ls->dentry_name,0 );if (o)strbuf_addf (buf,"%s\t%s^{}\n" ,oid_to_hex (&o->oid), ls->dentry_name);
line-log.c +1 -1
@@ -479,7 +479,7 @@ static struct commit *check_single_commit(struct rev_info *revs)struct object *obj = revs->pending.objects[i].item;if (obj->flags &UNINTERESTING )continue ; - obj =deref_tag (obj,NULL ,0 ); + obj =deref_tag (the_repository, obj,NULL ,0 );if (obj->type !=OBJ_COMMIT )die ("Non commit %s?" , revs->pending.objects[i].name);if (commit)
merge-recursive.c +2 -1
@@ -3489,7 +3489,8 @@ static struct commit *get_ref(const struct object_id *oid, const char *name) {struct object *object; - object =deref_tag (parse_object (the_repository, oid), name, + object =deref_tag (the_repository,parse_object (the_repository, oid), + name,strlen (name));if (!object)return NULL ;
remote.c +4 -2
@@ -1802,12 +1802,14 @@ int ref_newer(const struct object_id *new_oid, const struct object_id *old_oid)* Both new_commit and old_commit must be commit-ish and new_commit is descendant of * old_commit. Otherwise we require --force. */ - o =deref_tag (parse_object (the_repository, old_oid),NULL ,0 ); + o =deref_tag (the_repository,parse_object (the_repository, old_oid), +NULL ,0 );if (!o || o->type !=OBJ_COMMIT )return 0 ; old_commit = (struct commit *) o; - o =deref_tag (parse_object (the_repository, new_oid),NULL ,0 ); + o =deref_tag (the_repository,parse_object (the_repository, new_oid), +NULL ,0 );if (!o || o->type !=OBJ_COMMIT )return 0 ; new_commit = (struct commit *) o;
server-info.c +1 -1
@@ -64,7 +64,7 @@ static int add_info_ref(const char *path, const struct object_id *oid,return -1 ;if (o->type ==OBJ_TAG ) { - o =deref_tag (o, path,0 ); + o =deref_tag (the_repository, o, path,0 );if (o)if (fprintf (fp,"%s %s^{}\n" ,oid_to_hex (&o->oid), path) <0 )
sha1-name.c +7 -4
@@ -239,7 +239,8 @@ static int disambiguate_committish_only(const struct object_id *oid, void *cb_dareturn 0 ;/* We need to do this the hard way... */ - obj =deref_tag (parse_object (the_repository, oid),NULL ,0 ); + obj =deref_tag (the_repository,parse_object (the_repository, oid), +NULL ,0 );if (obj && obj->type ==OBJ_COMMIT )return 1 ;return 0 ;
@@ -263,7 +264,8 @@ static int disambiguate_treeish_only(const struct object_id *oid, void *cb_data_return 0 ;/* We need to do this the hard way... */ - obj =deref_tag (parse_object (the_repository, oid),NULL ,0 ); + obj =deref_tag (the_repository,parse_object (the_repository, oid), +NULL ,0 );if (obj && (obj->type ==OBJ_TREE || obj->type ==OBJ_COMMIT ))return 1 ;return 0 ;
@@ -968,7 +970,7 @@ static int peel_onion(const char *name, int len, struct object_id *oid,if (!o)return -1 ;if (!expected_type) { - o =deref_tag (o, name, sp - name -2 ); + o =deref_tag (the_repository, o, name, sp - name -2 );if (!o || (!o->parsed && !parse_object (the_repository, &o->oid)))return -1 ;oidcpy (oid, &o->oid);
@@ -1100,7 +1102,8 @@ static int handle_one_ref(const char *path, const struct object_id *oid,if (!object)return 0 ;if (object->type ==OBJ_TAG ) { - object =deref_tag (object, path,strlen (path)); + object =deref_tag (the_repository, object, path, +strlen (path));if (!object)return 0 ; }
shallow.c +3 -1
@@ -96,7 +96,9 @@ struct commit_list *get_shallow_commits(struct object_array *heads, int depth,if (i < heads->nr) {int **depth_slot; commit = (struct commit *) -deref_tag (heads->objects[i++].item,NULL ,0 ); +deref_tag (the_repository, + heads->objects[i++].item, +NULL ,0 );if (!commit || commit->object.type !=OBJ_COMMIT ) { commit =NULL ;continue ;
tag.c +1 -1
@@ -64,7 +64,7 @@ int gpg_verify_tag(const struct object_id *oid, const char *name_to_report,return ret; } -struct object *deref_tag (struct object *o,const char *warn,int warnlen) +struct object *deref_tag_the_repository (struct object *o,const char *warn,int warnlen) {while (o && o->type ==OBJ_TAG )if (((struct tag *)o)->tagged)
tag.h +2 -1
@@ -17,7 +17,8 @@ extern struct tag *lookup_tag_the_repository(const struct object_id *oid);extern int parse_tag_buffer_the_repository (struct tag *item,const void *data,unsigned long size);extern int parse_tag (struct tag *item);extern void release_tag_memory (struct tag *t); -extern struct object *deref_tag (struct object *,const char *,int ); +#define deref_tag (r, o, w, l) deref_tag_##r(o, w, l) +extern struct object *deref_tag_the_repository (struct object *,const char *,int );extern struct object *deref_tag_noverify (struct object *);extern int gpg_verify_tag (const struct object_id *oid,const char *name_to_report,unsigned flags);
upload-pack.c +1 -1
@@ -380,7 +380,7 @@ static int ok_to_give_up(void)if (want->flags &COMMON_KNOWN )continue ; - want =deref_tag (want,"a want line" ,0 ); + want =deref_tag (the_repository, want,"a want line" ,0 );if (!want || want->type !=OBJ_COMMIT ) {/* no way to tell if this is reachable by * looking at the ancestry chain alone, so
Signature · 1 line
2.18.0.399.gad0ab374a1-goog
PATCH v3 16/32 object: allow object_as_type to handle arbitrary repositories
In reply to Stefan Beller--- object.c | 4 ++-- object.h | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-)
object.c +2 -2
@@ -158,13 +158,13 @@ void *create_object(struct repository *r, const unsigned char *sha1, void *o)return obj; } -void *object_as_type_the_repository (struct object *obj,enum object_type type,int quiet) +void *object_as_type (struct repository *r,struct object *obj,enum object_type type,int quiet) {if (obj->type == type)return obj;else if (obj->type ==OBJ_NONE ) {if (type ==OBJ_COMMIT ) - ((struct commit *)obj)->index =alloc_commit_index (the_repository); + ((struct commit *)obj)->index =alloc_commit_index (r); obj->type = type;return obj; }
object.h +1 -2
@@ -114,8 +114,7 @@ struct object *lookup_object_the_repository(const unsigned char *sha1);extern void *create_object (struct repository *r,const unsigned char *sha1,void *obj); -#define object_as_type (r, o, t, q) object_as_type_##r(o, t, q) -void *object_as_type_the_repository (struct object *obj,enum object_type type,int quiet); +void *object_as_type (struct repository *r,struct object *obj,enum object_type type,int quiet);/* * Returns the object, having parsed it to find out what it is.
Signature · 1 line
2.18.0.399.gad0ab374a1-goog
PATCH v3 17/32 object: allow lookup_object to handle arbitrary repositories
In reply to Stefan Beller--- object.c | 15 +++++++-------- object.h | 3 +-- 2 files changed, 8 insertions(+), 10 deletions(-)
object.c +7 -8
@@ -84,21 +84,20 @@ static void insert_obj_hash(struct object *obj, struct object **hash, unsigned i* Look up the record for the given sha1 in the hash map stored in * obj_hash. Return NULL if it was not found. */ -struct object *lookup_object_the_repository (const unsigned char *sha1) +struct object *lookup_object (struct repository *r,const unsigned char *sha1) {unsigned int i, first;struct object *obj; -if (!the_repository->parsed_objects->obj_hash) +if (!r->parsed_objects->obj_hash)return NULL ; - first = i =hash_obj (sha1, - the_repository->parsed_objects->obj_hash_size); -while ((obj = the_repository->parsed_objects->obj_hash[i]) !=NULL ) { + first = i =hash_obj (sha1, r->parsed_objects->obj_hash_size); +while ((obj = r->parsed_objects->obj_hash[i]) !=NULL ) {if (!hashcmp (sha1, obj->oid.hash))break ; i++; -if (i == the_repository->parsed_objects->obj_hash_size) +if (i == r->parsed_objects->obj_hash_size) i =0 ; }if (obj && i != first) {
@@ -107,8 +106,8 @@ struct object *lookup_object_the_repository(const unsigned char *sha1)* that we do not need to walk the hash table the next * time we look for it. */ -SWAP (the_repository->parsed_objects->obj_hash[i], - the_repository->parsed_objects->obj_hash[first]); +SWAP (r->parsed_objects->obj_hash[i], + r->parsed_objects->obj_hash[first]); }return obj; }
object.h +1 -2
@@ -109,8 +109,7 @@ extern struct object *get_indexed_object(unsigned int);* half-initialised objects, the caller is expected to initialize them * by calling parse_object() on them. */ -#define lookup_object (r, s) lookup_object_##r(s) -struct object *lookup_object_the_repository (const unsigned char *sha1); +struct object *lookup_object (struct repository *r,const unsigned char *sha1);extern void *create_object (struct repository *r,const unsigned char *sha1,void *obj);
Signature · 1 line
2.18.0.399.gad0ab374a1-goog
PATCH v3 18/32 blob: allow lookup_blob to handle arbitrary repositories
In reply to Stefan Beller--- blob.c | 10 +++++----- blob.h | 3 +-- 2 files changed, 6 insertions(+), 7 deletions(-)
blob.c +5 -5
@@ -5,13 +5,13 @@const char *blob_type ="blob" ; -struct blob *lookup_blob_the_repository (const struct object_id *oid) +struct blob *lookup_blob (struct repository *r,const struct object_id *oid) { -struct object *obj =lookup_object (the_repository, oid->hash); +struct object *obj =lookup_object (r, oid->hash);if (!obj) -return create_object (the_repository, oid->hash, -alloc_blob_node (the_repository)); -return object_as_type (the_repository, obj,OBJ_BLOB ,0 ); +return create_object (r, oid->hash, +alloc_blob_node (r)); +return object_as_type (r, obj,OBJ_BLOB ,0 ); }int parse_blob_buffer (struct blob *item,void *buffer,unsigned long size)
blob.h +1 -2
@@ -9,8 +9,7 @@ struct blob {struct object object; }; -#define lookup_blob (r, o) lookup_blob_##r(o) -struct blob *lookup_blob_the_repository (const struct object_id *oid); +struct blob *lookup_blob (struct repository *r,const struct object_id *oid);int parse_blob_buffer (struct blob *item,void *buffer,unsigned long size);
Signature · 1 line
2.18.0.399.gad0ab374a1-goog
PATCH v3 19/32 tree: allow lookup_tree to handle arbitrary repositories
In reply to Stefan Beller--- tree.c | 10 +++++----- tree.h | 3 +-- 2 files changed, 6 insertions(+), 7 deletions(-)
tree.c +5 -5
@@ -195,13 +195,13 @@ int read_tree(struct tree *tree, int stage, struct pathspec *match,return 0 ; } -struct tree *lookup_tree_the_repository (const struct object_id *oid) +struct tree *lookup_tree (struct repository *r,const struct object_id *oid) { -struct object *obj =lookup_object (the_repository, oid->hash); +struct object *obj =lookup_object (r, oid->hash);if (!obj) -return create_object (the_repository, oid->hash, -alloc_tree_node (the_repository)); -return object_as_type (the_repository, obj,OBJ_TREE ,0 ); +return create_object (r, oid->hash, +alloc_tree_node (r)); +return object_as_type (r, obj,OBJ_TREE ,0 ); }int parse_tree_buffer (struct tree *item,void *buffer,unsigned long size)
tree.h +1 -2
@@ -12,8 +12,7 @@ struct tree {unsigned long size; }; -#define lookup_tree (r, oid) lookup_tree_##r(oid) -struct tree *lookup_tree_the_repository (const struct object_id *oid); +struct tree *lookup_tree (struct repository *r,const struct object_id *oid);int parse_tree_buffer (struct tree *item,void *buffer,unsigned long size);
Signature · 1 line
2.18.0.399.gad0ab374a1-goog
PATCH v3 20/32 commit: allow lookup_commit to handle arbitrary repositories
In reply to Stefan Beller--- commit.c | 10 +++++----- commit.h | 3 +-- 2 files changed, 6 insertions(+), 7 deletions(-)
commit.c +5 -5
@@ -53,13 +53,13 @@ struct commit *lookup_commit_or_die(const struct object_id *oid, const char *refreturn c; } -struct commit *lookup_commit_the_repository (const struct object_id *oid) +struct commit *lookup_commit (struct repository *r,const struct object_id *oid) { -struct object *obj =lookup_object (the_repository, oid->hash); +struct object *obj =lookup_object (r, oid->hash);if (!obj) -return create_object (the_repository, oid->hash, -alloc_commit_node (the_repository)); -return object_as_type (the_repository, obj,OBJ_COMMIT ,0 ); +return create_object (r, oid->hash, +alloc_commit_node (r)); +return object_as_type (r, obj,OBJ_COMMIT ,0 ); }struct commit *lookup_commit_reference_by_name (const char *name)
commit.h +1 -2
@@ -63,8 +63,7 @@ enum decoration_type {void add_name_decoration (enum decoration_type type,const char *name,struct object *obj);const struct name_decoration *get_name_decoration (const struct object *obj); -#define lookup_commit (r, o) lookup_commit_##r(o) -struct commit *lookup_commit_the_repository (const struct object_id *oid); +struct commit *lookup_commit (struct repository *r,const struct object_id *oid);#define lookup_commit_reference (r, o) \ lookup_commit_reference_##r(o)struct commit *lookup_commit_reference_the_repository (const struct object_id *oid);
Signature · 1 line
2.18.0.399.gad0ab374a1-goog
PATCH v3 21/32 tag: allow lookup_tag to handle arbitrary repositories
In reply to Stefan Beller--- tag.c | 10 +++++----- tag.h | 3 +-- 2 files changed, 6 insertions(+), 7 deletions(-)
tag.c +5 -5
@@ -92,13 +92,13 @@ struct object *deref_tag_noverify(struct object *o)return o; } -struct tag *lookup_tag_the_repository (const struct object_id *oid) +struct tag *lookup_tag (struct repository *r,const struct object_id *oid) { -struct object *obj =lookup_object (the_repository, oid->hash); +struct object *obj =lookup_object (r, oid->hash);if (!obj) -return create_object (the_repository, oid->hash, -alloc_tag_node (the_repository)); -return object_as_type (the_repository, obj,OBJ_TAG ,0 ); +return create_object (r, oid->hash, +alloc_tag_node (r)); +return object_as_type (r, obj,OBJ_TAG ,0 ); }static timestamp_t parse_tag_date (const char *buf,const char *tail)
tag.h +1 -2
@@ -11,8 +11,7 @@ struct tag {char *tag;timestamp_t date; }; -#define lookup_tag (r, o) lookup_tag_##r(o) -extern struct tag *lookup_tag_the_repository (const struct object_id *oid); +extern struct tag *lookup_tag (struct repository *r,const struct object_id *oid);#define parse_tag_buffer (r, i, d, s) parse_tag_buffer_##r(i, d, s)extern int parse_tag_buffer_the_repository (struct tag *item,const void *data,unsigned long size);extern int parse_tag (struct tag *item);
Signature · 1 line
2.18.0.399.gad0ab374a1-goog
PATCH v3 23/32 commit.c: allow parse_commit_buffer to handle arbitrary repositories
In reply to Stefan Beller--- commit.c | 10 +++++----- commit.h | 3 +-- 2 files changed, 6 insertions(+), 7 deletions(-)
commit.c +5 -5
@@ -364,7 +364,7 @@ const void *detach_commit_buffer(struct commit *commit, unsigned long *sizep)return ret; } -int parse_commit_buffer_the_repository (struct commit *item,const void *buffer,unsigned long size,int check_graph) +int parse_commit_buffer (struct repository *r,struct commit *item,const void *buffer,unsigned long size,int check_graph) {const char *tail = buffer;const char *bufptr = buffer;
@@ -384,11 +384,11 @@ int parse_commit_buffer_the_repository(struct commit *item, const void *buffer,if (get_oid_hex (bufptr +5 , &parent) <0 )return error ("bad tree pointer in commit %s" ,oid_to_hex (&item->object.oid)); - item->maybe_tree =lookup_tree (the_repository, &parent); + item->maybe_tree =lookup_tree (r, &parent); bufptr += tree_entry_len +1 ;/* "tree " + "hex sha1" + "\n" */ pptr = &item->parents; - graft =lookup_commit_graft (the_repository, &item->object.oid); + graft =lookup_commit_graft (r, &item->object.oid);while (bufptr + parent_entry_len < tail && !memcmp (bufptr,"parent " ,7 )) {struct commit *new_parent;
@@ -403,7 +403,7 @@ int parse_commit_buffer_the_repository(struct commit *item, const void *buffer,*/ if (graft && (graft->nr_parent <0 || grafts_replace_parents))continue ; - new_parent =lookup_commit (the_repository, &parent); + new_parent =lookup_commit (r, &parent);if (new_parent) pptr = &commit_list_insert (new_parent, pptr)->next; }
@@ -411,7 +411,7 @@ int parse_commit_buffer_the_repository(struct commit *item, const void *buffer,int i;struct commit *new_parent;for (i =0 ; i < graft->nr_parent; i++) { - new_parent =lookup_commit (the_repository, + new_parent =lookup_commit (r, &graft->parent[i]);if (!new_parent)continue ;
commit.h +1 -2
@@ -81,8 +81,7 @@ struct commit *lookup_commit_reference_by_name(const char *name);*/ struct commit *lookup_commit_or_die (const struct object_id *oid,const char *ref_name); -#define parse_commit_buffer (r, i, b, s, g) parse_commit_buffer_##r(i, b, s, g) -int parse_commit_buffer_the_repository (struct commit *item,const void *buffer,unsigned long size,int check_graph); +int parse_commit_buffer (struct repository *r,struct commit *item,const void *buffer,unsigned long size,int check_graph);int parse_commit_gently (struct commit *item,int quiet_on_missing);static inline int parse_commit (struct commit *item) {
Signature · 1 line
2.18.0.399.gad0ab374a1-goog
PATCH v3 24/32 commit-slabs: remove realloc counter outside of slab struct
In reply to Stefan BellerThe realloc counter is declared outside the struct for the given slabname, which makes it harder for a follow up patch to move the declaration of the struct around as then the counter variable would need special treatment.
As the reallocation counter is currently unused we can just remove it. If we ever need to count the reallocations again, we can reintroduce the counter as part of 'struct slabname' in commit-slab-decl.h.
--- commit-slab-impl.h | 3 --- 1 file changed, 3 deletions(-)
commit-slab-impl.h +0 -3
@@ -11,8 +11,6 @@#define implement_commit_slab (slabname, elemtype, scope) \ \ -static int stat_ ##slabname## realloc; \ - \ scope void init_ ##slabname## _with_stride(struct slabname *s, \ unsigned stride) \ { \
@@ -54,7 +52,6 @@ scope elemtype *slabname## _at_peek(struct slabname *s, \if (!add_if_missing) \return NULL ; \REALLOC_ARRAY (s->slab, nth_slab +1 ); \ - stat_ ##slabname## realloc++; \for (i = s->slab_count; i <= nth_slab; i++) \ s->slab[i] =NULL ; \ s->slab_count = nth_slab +1 ; \
Signature · 1 line
2.18.0.399.gad0ab374a1-goog
PATCH v3 25/32 commit.c: migrate the commit buffer to the parsed object store
In reply to Stefan Beller--- commit.c | 29 +++++++++++++++++++++++------ commit.h | 4 ++++ object.c | 5 +++++ object.h | 4 ++++ 4 files changed, 36 insertions(+), 6 deletions(-)
commit.c +23 -6
@@ -261,18 +261,32 @@ struct commit_buffer {unsigned long size; }; define_commit_slab(buffer_slab, struct commit_buffer); -static struct buffer_slab buffer_slab =COMMIT_SLAB_INIT (1 , buffer_slab); + +struct buffer_slab *allocate_commit_buffer_slab (void ) +{ +struct buffer_slab *bs =xmalloc (sizeof (*bs)); +init_buffer_slab (bs); +return bs; +} + +void free_commit_buffer_slab (struct buffer_slab *bs) +{ +clear_buffer_slab (bs); +free (bs); +}void set_commit_buffer_the_repository (struct commit *commit,void *buffer,unsigned long size) { -struct commit_buffer *v =buffer_slab_at (&buffer_slab, commit); +struct commit_buffer *v =buffer_slab_at ( + the_repository->parsed_objects->buffer_slab, commit); v->buffer = buffer; v->size = size; }const void *get_cached_commit_buffer_the_repository (const struct commit *commit,unsigned long *sizep) { -struct commit_buffer *v =buffer_slab_peek (&buffer_slab, commit); +struct commit_buffer *v =buffer_slab_peek ( + the_repository->parsed_objects->buffer_slab, commit);if (!v) {if (sizep) *sizep =0 ;
@@ -304,14 +318,16 @@ const void *get_commit_buffer(const struct commit *commit, unsigned long *sizep)void unuse_commit_buffer (const struct commit *commit,const void *buffer) { -struct commit_buffer *v =buffer_slab_peek (&buffer_slab, commit); +struct commit_buffer *v =buffer_slab_peek ( + the_repository->parsed_objects->buffer_slab, commit);if (!(v && v->buffer == buffer))free ((void *)buffer); }void free_commit_buffer (struct commit *commit) { -struct commit_buffer *v =buffer_slab_peek (&buffer_slab, commit); +struct commit_buffer *v =buffer_slab_peek ( + the_repository->parsed_objects->buffer_slab, commit);if (v) {FREE_AND_NULL (v->buffer); v->size =0 ;
@@ -347,7 +363,8 @@ void release_commit_memory(struct commit *c)const void *detach_commit_buffer (struct commit *commit,unsigned long *sizep) { -struct commit_buffer *v =buffer_slab_peek (&buffer_slab, commit); +struct commit_buffer *v =buffer_slab_peek ( + the_repository->parsed_objects->buffer_slab, commit);void *ret;if (!v) {
commit.h +4 -0
@@ -89,6 +89,10 @@ static inline int parse_commit(struct commit *item) }void parse_commit_or_die (struct commit *item); +struct buffer_slab ; +struct buffer_slab *allocate_commit_buffer_slab (void ); +void free_commit_buffer_slab (struct buffer_slab *bs); +/* * Associate an object buffer with the commit. The ownership of the * memory is handed over to the commit, and must be free()-able.
object.c +5 -0
@@ -467,6 +467,8 @@ struct parsed_object_pool *parsed_object_pool_new(void) o->is_shallow =-1 ; o->shallow_stat =xcalloc (1 ,sizeof (*o->shallow_stat)); + o->buffer_slab =allocate_commit_buffer_slab (); +return o; }
@@ -541,6 +543,9 @@ void parsed_object_pool_clear(struct parsed_object_pool *o)FREE_AND_NULL (o->obj_hash); o->obj_hash_size =0 ; +free_commit_buffer_slab (o->buffer_slab); + o->buffer_slab =NULL ; +clear_alloc_state (o->blob_state);clear_alloc_state (o->tree_state);clear_alloc_state (o->commit_state);
object.h +4 -0
@@ -1,6 +1,8 @@ #ifndef OBJECT_H #define OBJECT_H +struct buffer_slab; + struct parsed_object_pool { struct object **obj_hash; int nr_objs, obj_hash_size;
@@ -22,6 +24,8 @@ struct parsed_object_pool {char *alternate_shallow_file;int commit_graft_prepared; + +struct buffer_slab *buffer_slab; };struct parsed_object_pool *parsed_object_pool_new (void );
Signature · 1 line
2.18.0.399.gad0ab374a1-goog
PATCH v3 26/32 commit.c: allow set_commit_buffer to handle arbitrary repositories
In reply to Stefan Beller--- commit.c | 4 ++-- commit.h | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-)
commit.c +2 -2
@@ -275,10 +275,10 @@ void free_commit_buffer_slab(struct buffer_slab *bs)free (bs); } -void set_commit_buffer_the_repository (struct commit *commit,void *buffer,unsigned long size) +void set_commit_buffer (struct repository *r,struct commit *commit,void *buffer,unsigned long size) {struct commit_buffer *v =buffer_slab_at ( - the_repository->parsed_objects->buffer_slab, commit); + r->parsed_objects->buffer_slab, commit); v->buffer = buffer; v->size = size; }
commit.h +1 -2
@@ -97,8 +97,7 @@ void free_commit_buffer_slab(struct buffer_slab *bs);* Associate an object buffer with the commit. The ownership of the * memory is handed over to the commit, and must be free()-able. */ -#define set_commit_buffer (r, c, b, s) set_commit_buffer_##r(c, b, s) -void set_commit_buffer_the_repository (struct commit *,void *buffer,unsigned long size); +void set_commit_buffer (struct repository *r,struct commit *,void *buffer,unsigned long size);/* * Get any cached object buffer associated with the commit. Returns NULL
Signature · 1 line
2.18.0.399.gad0ab374a1-goog
PATCH v3 28/32 object.c: allow parse_object_buffer to handle arbitrary repositories
In reply to Stefan Beller--- object.c | 18 +++++++++--------- object.h | 3 +-- 2 files changed, 10 insertions(+), 11 deletions(-)
object.c +9 -9
@@ -185,21 +185,21 @@ struct object *lookup_unknown_object(const unsigned char *sha1)return obj; } -struct object *parse_object_buffer_the_repository (const struct object_id *oid,enum object_type type,unsigned long size,void *buffer,int *eaten_p) +struct object *parse_object_buffer (struct repository *r,const struct object_id *oid,enum object_type type,unsigned long size,void *buffer,int *eaten_p) {struct object *obj; *eaten_p =0 ; obj =NULL ;if (type ==OBJ_BLOB ) { -struct blob *blob =lookup_blob (the_repository, oid); +struct blob *blob =lookup_blob (r, oid);if (blob) {if (parse_blob_buffer (blob, buffer, size))return NULL ; obj = &blob->object; } }else if (type ==OBJ_TREE ) { -struct tree *tree =lookup_tree (the_repository, oid); +struct tree *tree =lookup_tree (r, oid);if (tree) { obj = &tree->object;if (!tree->buffer)
@@ -211,20 +211,20 @@ struct object *parse_object_buffer_the_repository(const struct object_id *oid, e } } }else if (type ==OBJ_COMMIT ) { -struct commit *commit =lookup_commit (the_repository, oid); +struct commit *commit =lookup_commit (r, oid);if (commit) { -if (parse_commit_buffer (the_repository, commit, buffer, size,1 )) +if (parse_commit_buffer (r, commit, buffer, size,1 ))return NULL ; -if (!get_cached_commit_buffer (the_repository, commit,NULL )) { -set_commit_buffer (the_repository, commit, buffer, size); +if (!get_cached_commit_buffer (r, commit,NULL )) { +set_commit_buffer (r, commit, buffer, size); *eaten_p =1 ; } obj = &commit->object; } }else if (type ==OBJ_TAG ) { -struct tag *tag =lookup_tag (the_repository, oid); +struct tag *tag =lookup_tag (r, oid);if (tag) { -if (parse_tag_buffer (the_repository, tag, buffer, size)) +if (parse_tag_buffer (r, tag, buffer, size))return NULL ; obj = &tag->object; }
object.h +1 -2
@@ -138,8 +138,7 @@ struct object *parse_object_or_die(const struct object_id *oid, const char *name* parsing it. eaten_p indicates if the object has a borrowed copy * of buffer and the caller should not free() it. */ -#define parse_object_buffer (r, o, t, s, b, e) parse_object_buffer_##r(o, t, s, b, e) -struct object *parse_object_buffer_the_repository (const struct object_id *oid,enum object_type type,unsigned long size,void *buffer,int *eaten_p); +struct object *parse_object_buffer (struct repository *r,const struct object_id *oid,enum object_type type,unsigned long size,void *buffer,int *eaten_p);/** Returns the object, with potentially excess memory allocated. **/ struct object *lookup_unknown_object (const unsigned char *sha1);
Signature · 1 line
2.18.0.399.gad0ab374a1-goog
PATCH v3 30/32 tag.c: allow deref_tag to handle arbitrary repositories
In reply to Stefan Beller--- tag.c | 5 ++--- tag.h | 3 +-- 2 files changed, 3 insertions(+), 5 deletions(-)
tag.c +2 -3
@@ -64,12 +64,11 @@ int gpg_verify_tag(const struct object_id *oid, const char *name_to_report,return ret; } -struct object *deref_tag_the_repository (struct object *o,const char *warn,int warnlen) +struct object *deref_tag (struct repository *r,struct object *o,const char *warn,int warnlen) {while (o && o->type ==OBJ_TAG )if (((struct tag *)o)->tagged) - o =parse_object (the_repository, - &((struct tag *)o)->tagged->oid); + o =parse_object (r, &((struct tag *)o)->tagged->oid);else o =NULL ;if (!o && warn) {
tag.h +1 -2
@@ -15,8 +15,7 @@ extern struct tag *lookup_tag(struct repository *r, const struct object_id *oid)extern int parse_tag_buffer (struct repository *r,struct tag *item,const void *data,unsigned long size);extern int parse_tag (struct tag *item);extern void release_tag_memory (struct tag *t); -#define deref_tag (r, o, w, l) deref_tag_##r(o, w, l) -extern struct object *deref_tag_the_repository (struct object *,const char *,int ); +extern struct object *deref_tag (struct repository *r,struct object *,const char *,int );extern struct object *deref_tag_noverify (struct object *);extern int gpg_verify_tag (const struct object_id *oid,const char *name_to_report,unsigned flags);
Signature · 1 line
2.18.0.399.gad0ab374a1-goog
PATCH v3 29/32 object.c: allow parse_object to handle arbitrary repositories
In reply to Stefan Beller--- object.c | 14 +++++++------- object.h | 3 +-- 2 files changed, 8 insertions(+), 9 deletions(-)
object.c +7 -7
@@ -245,28 +245,28 @@ struct object *parse_object_or_die(const struct object_id *oid,die (_ ("unable to parse object: %s" ), name ? name :oid_to_hex (oid)); } -struct object *parse_object_the_repository (const struct object_id *oid) +struct object *parse_object (struct repository *r,const struct object_id *oid) {unsigned long size;enum object_type type;int eaten; -const struct object_id *repl =lookup_replace_object (the_repository, oid); +const struct object_id *repl =lookup_replace_object (r, oid);void *buffer;struct object *obj; - obj =lookup_object (the_repository, oid->hash); + obj =lookup_object (r, oid->hash);if (obj && obj->parsed)return obj;if ((obj && obj->type ==OBJ_BLOB &&has_object_file (oid)) || (!obj &&has_object_file (oid) && -oid_object_info (the_repository, oid,NULL ) ==OBJ_BLOB )) { +oid_object_info (r, oid,NULL ) ==OBJ_BLOB )) {if (check_object_signature (repl,NULL ,0 ,NULL ) <0 ) {error ("sha1 mismatch %s" ,oid_to_hex (oid));return NULL ; } -parse_blob_buffer (lookup_blob (the_repository, oid),NULL ,0 ); -return lookup_object (the_repository, oid->hash); +parse_blob_buffer (lookup_blob (r, oid),NULL ,0 ); +return lookup_object (r, oid->hash); } buffer =read_object_file (oid, &type, &size);
@@ -277,7 +277,7 @@ struct object *parse_object_the_repository(const struct object_id *oid)return NULL ; } - obj =parse_object_buffer (the_repository, oid, type, size, + obj =parse_object_buffer (r, oid, type, size, buffer, &eaten);if (!eaten)free (buffer);
object.h +1 -2
@@ -124,8 +124,7 @@ void *object_as_type(struct repository *r, struct object *obj, enum object_type* * Returns NULL if the object is missing or corrupt. */ -#define parse_object (r, oid) parse_object_##r(oid) -struct object *parse_object_the_repository (const struct object_id *oid); +struct object *parse_object (struct repository *r,const struct object_id *oid);/* * Like parse_object, but will die() instead of returning NULL. If the
Signature · 1 line
2.18.0.399.gad0ab374a1-goog
PATCH v3 31/32 commit.c: allow lookup_commit_reference_gently to handle arbitrary repositories
In reply to Stefan Beller--- commit.c | 8 ++++---- commit.h | 4 +--- 2 files changed, 5 insertions(+), 7 deletions(-)
commit.c +4 -4
@@ -24,16 +24,16 @@ int save_commit_buffer = 1;const char *commit_type ="commit" ; -struct commit *lookup_commit_reference_gently_the_repository ( +struct commit *lookup_commit_reference_gently (struct repository *r,const struct object_id *oid,int quiet) { -struct object *obj =deref_tag (the_repository, -parse_object (the_repository, oid), +struct object *obj =deref_tag (r, +parse_object (r, oid),NULL ,0 );if (!obj)return NULL ; -return object_as_type (the_repository, obj,OBJ_COMMIT , quiet); +return object_as_type (r, obj,OBJ_COMMIT , quiet); }struct commit *lookup_commit_reference_the_repository (const struct object_id *oid)
commit.h +1 -3
@@ -67,9 +67,7 @@ struct commit *lookup_commit(struct repository *r, const struct object_id *oid);#define lookup_commit_reference (r, o) \ lookup_commit_reference_##r(o)struct commit *lookup_commit_reference_the_repository (const struct object_id *oid); -#define lookup_commit_reference_gently (r, o, q) \ - lookup_commit_reference_gently_##r(o, q) -struct commit *lookup_commit_reference_gently_the_repository ( +struct commit *lookup_commit_reference_gently (struct repository *r,const struct object_id *oid,int quiet);struct commit *lookup_commit_reference_by_name (const char *name);
Signature · 1 line
2.18.0.399.gad0ab374a1-goog
PATCH v3 32/32 commit.c: allow lookup_commit_reference to handle arbitrary repositories
In reply to Stefan Beller--- commit.c | 4 ++-- commit.h | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-)
commit.c +2 -2
@@ -36,9 +36,9 @@ struct commit *lookup_commit_reference_gently(struct repository *r,return object_as_type (r, obj,OBJ_COMMIT , quiet); } -struct commit *lookup_commit_reference_the_repository (const struct object_id *oid) +struct commit *lookup_commit_reference (struct repository *r,const struct object_id *oid) { -return lookup_commit_reference_gently (the_repository, oid,0 ); +return lookup_commit_reference_gently (r, oid,0 ); }struct commit *lookup_commit_or_die (const struct object_id *oid,const char *ref_name)
commit.h +2 -3
@@ -64,9 +64,8 @@ void add_name_decoration(enum decoration_type type, const char *name, struct objconst struct name_decoration *get_name_decoration (const struct object *obj);struct commit *lookup_commit (struct repository *r,const struct object_id *oid); -#define lookup_commit_reference (r, o) \ - lookup_commit_reference_##r(o) -struct commit *lookup_commit_reference_the_repository (const struct object_id *oid); +struct commit *lookup_commit_reference (struct repository *r, +const struct object_id *oid);struct commit *lookup_commit_reference_gently (struct repository *r,const struct object_id *oid,int quiet);
Signature · 1 line
2.18.0.399.gad0ab374a1-goog
PATCH v3 22/32 tag: allow parse_tag_buffer to handle arbitrary repositories
In reply to Stefan Beller--- tag.c | 10 +++++----- tag.h | 3 +-- 2 files changed, 6 insertions(+), 7 deletions(-)
tag.c +5 -5
@@ -126,7 +126,7 @@ void release_tag_memory(struct tag *t) t->date =0 ; } -int parse_tag_buffer_the_repository (struct tag *item,const void *data,unsigned long size) +int parse_tag_buffer (struct repository *r,struct tag *item,const void *data,unsigned long size) {struct object_id oid;char type[20 ];
@@ -154,13 +154,13 @@ int parse_tag_buffer_the_repository(struct tag *item, const void *data, unsigned bufptr = nl +1 ;if (!strcmp (type, blob_type)) { - item->tagged = (struct object *)lookup_blob (the_repository, &oid); + item->tagged = (struct object *)lookup_blob (r, &oid); }else if (!strcmp (type, tree_type)) { - item->tagged = (struct object *)lookup_tree (the_repository, &oid); + item->tagged = (struct object *)lookup_tree (r, &oid); }else if (!strcmp (type, commit_type)) { - item->tagged = (struct object *)lookup_commit (the_repository, &oid); + item->tagged = (struct object *)lookup_commit (r, &oid); }else if (!strcmp (type, tag_type)) { - item->tagged = (struct object *)lookup_tag (the_repository, &oid); + item->tagged = (struct object *)lookup_tag (r, &oid); }else {error ("Unknown type %s" , type); item->tagged =NULL ;
tag.h +1 -2
@@ -12,8 +12,7 @@ struct tag {timestamp_t date; };extern struct tag *lookup_tag (struct repository *r,const struct object_id *oid); -#define parse_tag_buffer (r, i, d, s) parse_tag_buffer_##r(i, d, s) -extern int parse_tag_buffer_the_repository (struct tag *item,const void *data,unsigned long size); +extern int parse_tag_buffer (struct repository *r,struct tag *item,const void *data,unsigned long size);extern int parse_tag (struct tag *item);extern void release_tag_memory (struct tag *t);#define deref_tag (r, o, w, l) deref_tag_##r(o, w, l)
Signature · 1 line
2.18.0.399.gad0ab374a1-goog
PATCH v3 27/32 commit.c: allow get_cached_commit_buffer to handle arbitrary repositories
In reply to Stefan Beller--- commit.c | 4 ++-- commit.h | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-)
commit.c +2 -2
@@ -283,10 +283,10 @@ void set_commit_buffer(struct repository *r, struct commit *commit, void *buffer v->size = size; } -const void *get_cached_commit_buffer_the_repository (const struct commit *commit,unsigned long *sizep) +const void *get_cached_commit_buffer (struct repository *r,const struct commit *commit,unsigned long *sizep) {struct commit_buffer *v =buffer_slab_peek ( - the_repository->parsed_objects->buffer_slab, commit); + r->parsed_objects->buffer_slab, commit);if (!v) {if (sizep) *sizep =0 ;
commit.h +1 -2
@@ -103,8 +103,7 @@ void set_commit_buffer(struct repository *r, struct commit *, void *buffer, unsi* Get any cached object buffer associated with the commit. Returns NULL * if none. The resulting memory should not be freed. */ -#define get_cached_commit_buffer (r, c, s) get_cached_commit_buffer_##r(c, s) -const void *get_cached_commit_buffer_the_repository (const struct commit *,unsigned long *size); +const void *get_cached_commit_buffer (struct repository *,const struct commit *,unsigned long *size);/* * Get the commit's object contents, either from cache or by reading the object
Signature · 1 line
2.18.0.399.gad0ab374a1-goog
PATCH v3 7/32 commit: add repository argument to lookup_commit_reference_gently
In reply to Stefan BellerAdd a repository argument to allow callers of lookup_commit_reference_gently to be more specific about which repository to handle. This is a small mechanical change; it doesn't change the implementation to handle repositories other than the_repository yet.
As with the previous commits, use a macro to catch callers passing a repository other than the_repository at compile time.
--- archive.c | 2 +- blame.c | 3 ++- builtin/checkout.c | 6 +++--- builtin/describe.c | 5 +++-- builtin/fetch.c | 9 ++++++--- builtin/reflog.c | 10 ++++++---- builtin/show-branch.c | 3 ++- bundle.c | 2 +- commit-graph.c | 2 +- commit.c | 6 +++--- commit.h | 5 ++++- fast-import.c | 6 ++++-- notes-cache.c | 3 ++- ref-filter.c | 6 ++++-- remote.c | 9 +++++---- sequencer.c | 2 +- sha1-name.c | 4 ++-- shallow.c | 9 ++++++--- walker.c | 3 ++- wt-status.c | 2 +- 20 files changed, 59 insertions(+), 38 deletions(-)
archive.c +1 -1
@@ -380,7 +380,7 @@ static void parse_treeish_arg(const char **argv,if (get_oid (name, &oid))die ("Not a valid object name" ); - commit =lookup_commit_reference_gently (&oid,1 ); + commit =lookup_commit_reference_gently (the_repository, &oid,1 );if (commit) { commit_sha1 = commit->object.oid.hash; archive_time = commit->date;
blame.c +2 -1
@@ -1712,7 +1712,8 @@ static struct commit *dwim_reverse_initial(struct rev_info *revs,/* Do we have HEAD? */ if (!resolve_ref_unsafe ("HEAD" ,RESOLVE_REF_READING , &head_oid,NULL ))return NULL ; - head_commit =lookup_commit_reference_gently (&head_oid,1 ); + head_commit =lookup_commit_reference_gently (the_repository, + &head_oid,1 );if (!head_commit)return NULL ;
builtin/checkout.c +3 -3
@@ -379,7 +379,7 @@ static int checkout_paths(const struct checkout_opts *opts,die (_ ("unable to write new index file" ));read_ref_full ("HEAD" ,0 , &rev,NULL ); - head =lookup_commit_reference_gently (&rev,1 ); + head =lookup_commit_reference_gently (the_repository, &rev,1 ); errs |=post_checkout_hook (head, head,0 );return errs;
@@ -830,7 +830,7 @@ static int switch_branches(const struct checkout_opts *opts,memset (&old_branch_info,0 ,sizeof (old_branch_info)); old_branch_info.path = path_to_free =resolve_refdup ("HEAD" ,0 , &rev, &flag);if (old_branch_info.path) - old_branch_info.commit =lookup_commit_reference_gently (&rev,1 ); + old_branch_info.commit =lookup_commit_reference_gently (the_repository, &rev,1 );if (!(flag &REF_ISSYMREF )) old_branch_info.path =NULL ;
@@ -1004,7 +1004,7 @@ static int parse_branchname_arg(int argc, const char **argv,else new_branch_info->path =NULL ;/* not an existing branch */ - new_branch_info->commit =lookup_commit_reference_gently (rev,1 ); + new_branch_info->commit =lookup_commit_reference_gently (the_repository, rev,1 );if (!new_branch_info->commit) {/* not a commit */ *source_tree =parse_tree_indirect (rev);
builtin/describe.c +3 -2
@@ -331,7 +331,8 @@ static void describe_commit(struct object_id *oid, struct strbuf *dst)init_commit_names (&commit_names); n =hashmap_iter_first (&names, &iter);for (; n; n =hashmap_iter_next (&iter)) { - c =lookup_commit_reference_gently (&n->peeled,1 ); + c =lookup_commit_reference_gently (the_repository, + &n->peeled,1 );if (c) *commit_names_at (&commit_names, c) = n; }
@@ -509,7 +510,7 @@ static void describe(const char *arg, int last_one)if (get_oid (arg, &oid))die (_ ("Not a valid object name %s" ), arg); - cmit =lookup_commit_reference_gently (&oid,1 ); + cmit =lookup_commit_reference_gently (the_repository, &oid,1 );if (cmit)describe_commit (&oid, &sb);
builtin/fetch.c +6 -3
@@ -684,8 +684,10 @@ static int update_local_ref(struct ref *ref,return r; } - current =lookup_commit_reference_gently (&ref->old_oid,1 ); - updated =lookup_commit_reference_gently (&ref->new_oid,1 ); + current =lookup_commit_reference_gently (the_repository, + &ref->old_oid,1 ); + updated =lookup_commit_reference_gently (the_repository, + &ref->new_oid,1 );if (!current || !updated) {const char *msg;const char *what;
@@ -818,7 +820,8 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,continue ; } - commit =lookup_commit_reference_gently (&rm->old_oid, + commit =lookup_commit_reference_gently (the_repository, + &rm->old_oid,1 );if (!commit) rm->fetch_head_status =FETCH_HEAD_NOT_FOR_MERGE ;
builtin/reflog.c +6 -4
@@ -196,7 +196,7 @@ static int keep_entry(struct commit **it, struct object_id *oid)if (is_null_oid (oid))return 1 ; - commit =lookup_commit_reference_gently (oid,1 ); + commit =lookup_commit_reference_gently (the_repository, oid,1 );if (!commit)return 0 ;
@@ -265,7 +265,8 @@ static int unreachable(struct expire_reflog_policy_cb *cb, struct commit *commitif (is_null_oid (oid))return 0 ; - commit =lookup_commit_reference_gently (oid,1 ); + commit =lookup_commit_reference_gently (the_repository, oid, +1 );/* Not a commit -- keep it */ if (!commit)
@@ -322,7 +323,7 @@ static int push_tip_to_list(const char *refname, const struct object_id *oid,struct commit *tip_commit;if (flags &REF_ISSYMREF )return 0 ; - tip_commit =lookup_commit_reference_gently (oid,1 ); + tip_commit =lookup_commit_reference_gently (the_repository, oid,1 );if (!tip_commit)return 0 ;commit_list_insert (tip_commit, list);
@@ -339,7 +340,8 @@ static void reflog_expiry_prepare(const char *refname, cb->tip_commit =NULL ; cb->unreachable_expire_kind =UE_HEAD ; }else { - cb->tip_commit =lookup_commit_reference_gently (oid,1 ); + cb->tip_commit =lookup_commit_reference_gently (the_repository, + oid,1 );if (!cb->tip_commit) cb->unreachable_expire_kind =UE_ALWAYS ;else
builtin/show-branch.c +2 -1
@@ -378,7 +378,8 @@ static void sort_ref_range(int bottom, int top)static int append_ref (const char *refname,const struct object_id *oid,int allow_dups) { -struct commit *commit =lookup_commit_reference_gently (oid,1 ); +struct commit *commit =lookup_commit_reference_gently (the_repository, + oid,1 );int i;if (!commit)
bundle.c +1 -1
@@ -180,7 +180,7 @@ int verify_bundle(struct bundle_header *header, int verbose)/* Clean up objects used, as they will be reused. */ for (i =0 ; i < p->nr; i++) {struct ref_list_entry *e = p->list + i; - commit =lookup_commit_reference_gently (&e->oid,1 ); + commit =lookup_commit_reference_gently (the_repository, &e->oid,1 );if (commit)clear_commit_marks (commit,ALL_REV_FLAGS ); }
commit-graph.c +1 -1
@@ -701,7 +701,7 @@ void write_commit_graph(const char *obj_dir,if (commit_hex[i] &&parse_oid_hex (commit_hex[i], &oid, &end))continue ; - result =lookup_commit_reference_gently (&oid,1 ); + result =lookup_commit_reference_gently (the_repository, &oid,1 );if (result) {ALLOC_GROW (oids.list, oids.nr +1 , oids.alloc);
commit.c +3 -3
@@ -24,8 +24,8 @@ int save_commit_buffer = 1;const char *commit_type ="commit" ; -struct commit *lookup_commit_reference_gently (const struct object_id *oid, -int quiet) +struct commit *lookup_commit_reference_gently_the_repository ( +const struct object_id *oid,int quiet) {struct object *obj =deref_tag (parse_object (the_repository, oid),NULL ,0 );
@@ -37,7 +37,7 @@ struct commit *lookup_commit_reference_gently(const struct object_id *oid,struct commit *lookup_commit_reference (const struct object_id *oid) { -return lookup_commit_reference_gently (oid,0 ); +return lookup_commit_reference_gently (the_repository, oid,0 ); }struct commit *lookup_commit_or_die (const struct object_id *oid,const char *ref_name)
commit.h +4 -1
@@ -65,7 +65,10 @@ const struct name_decoration *get_name_decoration(const struct object *obj);struct commit *lookup_commit (const struct object_id *oid);struct commit *lookup_commit_reference (const struct object_id *oid); -struct commit *lookup_commit_reference_gently (const struct object_id *oid, +#define lookup_commit_reference_gently (r, o, q) \ + lookup_commit_reference_gently_##r(o, q) +struct commit *lookup_commit_reference_gently_the_repository ( +const struct object_id *oid,int quiet);struct commit *lookup_commit_reference_by_name (const char *name);
fast-import.c +4 -2
@@ -1724,8 +1724,10 @@ static int update_branch(struct branch *b)if (!force_update && !is_null_oid (&old_oid)) {struct commit *old_cmit, *new_cmit; - old_cmit =lookup_commit_reference_gently (&old_oid,0 ); - new_cmit =lookup_commit_reference_gently (&b->oid,0 ); + old_cmit =lookup_commit_reference_gently (the_repository, + &old_oid,0 ); + new_cmit =lookup_commit_reference_gently (the_repository, + &b->oid,0 );if (!old_cmit || !new_cmit)return error ("Branch %s is missing commits." , b->name);
notes-cache.c +2 -1
@@ -1,6 +1,7 @@#include "cache.h" #include "notes-cache.h" #include "object-store.h" +#include "repository.h" #include "commit.h" #include "refs.h"
@@ -15,7 +16,7 @@ static int notes_cache_match_validity(const char *ref, const char *validity)if (read_ref (ref, &oid) <0 )return 0 ; - commit =lookup_commit_reference_gently (&oid,1 ); + commit =lookup_commit_reference_gently (the_repository, &oid,1 );if (!commit)return 0 ;
ref-filter.c +4 -2
@@ -2026,7 +2026,8 @@ static int ref_filter_handler(const char *refname, const struct object_id *oid,* non-commits early. The actual filtering is done later. */ if (filter->merge_commit || filter->with_commit || filter->no_commit || filter->verbose) { - commit =lookup_commit_reference_gently (oid,1 ); + commit =lookup_commit_reference_gently (the_repository, oid, +1 );if (!commit)return 0 ;/* We perform the filtering for the '--contains' option... */
@@ -2383,7 +2384,8 @@ int parse_opt_merge_filter(const struct option *opt, const char *arg, int unset)if (get_oid (arg, &oid))die (_ ("malformed object name %s" ), arg); - rf->merge_commit =lookup_commit_reference_gently (&oid,0 ); + rf->merge_commit =lookup_commit_reference_gently (the_repository, + &oid,0 );if (!rf->merge_commit)return opterror (opt,"must point to a commit" ,0 );
remote.c +5 -4
@@ -1149,7 +1149,7 @@ static void add_to_tips(struct tips *tips, const struct object_id *oid)if (is_null_oid (oid))return ; - commit =lookup_commit_reference_gently (oid,1 ); + commit =lookup_commit_reference_gently (the_repository, oid,1 );if (!commit || (commit->object.flags &TMP_MARK ))return ; commit->object.flags |=TMP_MARK ;
@@ -1211,7 +1211,8 @@ static void add_missing_tags(struct ref *src, struct ref **dst, struct ref ***dsif (is_null_oid (&ref->new_oid))continue ; - commit =lookup_commit_reference_gently (&ref->new_oid, + commit =lookup_commit_reference_gently (the_repository, + &ref->new_oid,1 );if (!commit)/* not pushing a commit, which is not an error */
@@ -1435,8 +1436,8 @@ void set_ref_status_for_push(struct ref *remote_refs, int send_mirror, reject_reason =REF_STATUS_REJECT_ALREADY_EXISTS ; else if (!has_object_file(&ref->old_oid)) reject_reason =REF_STATUS_REJECT_FETCH_FIRST ; - else if (!lookup_commit_reference_gently(&ref->old_oid, 1) || - !lookup_commit_reference_gently(&ref->new_oid, 1)) + else if (!lookup_commit_reference_gently(the_repository, &ref->old_oid, 1) || + !lookup_commit_reference_gently(the_repository, &ref->new_oid, 1)) reject_reason =REF_STATUS_REJECT_NEEDS_FORCE ; else if (!ref_newer(&ref->new_oid, &ref->old_oid)) reject_reason =REF_STATUS_REJECT_NONFASTFORWARD ;
sequencer.c +1 -1
@@ -3610,7 +3610,7 @@ int sequencer_pick_revisions(struct replay_opts *opts)continue ;if (!get_oid (name, &oid)) { -if (!lookup_commit_reference_gently (&oid,1 )) { +if (!lookup_commit_reference_gently (the_repository, &oid,1 )) {enum object_type type =oid_object_info (the_repository, &oid,NULL );
sha1-name.c +2 -2
@@ -1251,13 +1251,13 @@ int get_oid_mb(const char *name, struct object_id *oid) }if (st)return st; - one =lookup_commit_reference_gently (&oid_tmp,0 ); + one =lookup_commit_reference_gently (the_repository, &oid_tmp,0 );if (!one)return -1 ;if (get_oid_committish (dots[3 ] ? (dots +3 ) :"HEAD" , &oid_tmp))return -1 ; - two =lookup_commit_reference_gently (&oid_tmp,0 ); + two =lookup_commit_reference_gently (the_repository, &oid_tmp,0 );if (!two)return -1 ; mbs =get_merge_bases (one, two);
shallow.c +6 -3
@@ -492,7 +492,8 @@ static void paint_down(struct paint_info *info, const struct object_id *oid,struct commit_list *head =NULL ;int bitmap_nr =DIV_ROUND_UP (info->nr_bits,32 );size_t bitmap_size =st_mult (sizeof (uint32_t ), bitmap_nr); -struct commit *c =lookup_commit_reference_gently (oid,1 ); +struct commit *c =lookup_commit_reference_gently (the_repository, oid, +1 );uint32_t *tmp;/* to be freed before return */ uint32_t *bitmap;
@@ -554,7 +555,8 @@ static void paint_down(struct paint_info *info, const struct object_id *oid,static int mark_uninteresting (const char *refname,const struct object_id *oid,int flags,void *cb_data) { -struct commit *commit =lookup_commit_reference_gently (oid,1 ); +struct commit *commit =lookup_commit_reference_gently (the_repository, + oid,1 );if (!commit)return 0 ; commit->object.flags |=UNINTERESTING ;
@@ -664,7 +666,8 @@ static int add_ref(const char *refname, const struct object_id *oid, {struct commit_array *ca = cb_data;ALLOC_GROW (ca->commits, ca->nr +1 , ca->alloc); - ca->commits[ca->nr] =lookup_commit_reference_gently (oid,1 ); + ca->commits[ca->nr] =lookup_commit_reference_gently (the_repository, + oid,1 );if (ca->commits[ca->nr]) ca->nr++;return 0 ;
walker.c +2 -1
@@ -207,7 +207,8 @@ static int interpret_target(struct walker *walker, char *target, struct object_istatic int mark_complete (const char *path,const struct object_id *oid,int flag,void *cb_data) { -struct commit *commit =lookup_commit_reference_gently (oid,1 ); +struct commit *commit =lookup_commit_reference_gently (the_repository, + oid,1 );if (commit) { commit->object.flags |=COMPLETE ;
wt-status.c +1 -1
@@ -1489,7 +1489,7 @@ static void wt_status_get_detached_from(struct wt_status_state *state)/* sha1 is a commit? match without further lookup */ (!oidcmp (&cb.noid, &oid) ||/* perhaps sha1 is a tag, try to dereference to a commit */ - ((commit =lookup_commit_reference_gently (&oid,1 )) !=NULL && + ((commit =lookup_commit_reference_gently (the_repository, &oid,1 )) !=NULL && !oidcmp(&cb.noid, &commit->object.oid)))) { const char *from = ref;if (!skip_prefix (from,"refs/tags/" , &from))
Signature · 1 line
2.18.0.399.gad0ab374a1-goog
PATCH v3 9/32 commit: add repository argument to lookup_commit
In reply to Stefan BellerAdd a repository argument to allow callers of lookup_commit to be more specific about which repository to handle. This is a small mechanical change; it doesn't change the implementation to handle repositories other than the_repository yet.
As with the previous commits, use a macro to catch callers passing a repository other than the_repository at compile time.
--- builtin/am.c | 3 ++- builtin/commit-tree.c | 4 +++- builtin/diff-tree.c | 2 +- builtin/fast-export.c | 2 +- builtin/fmt-merge-msg.c | 2 +- builtin/merge-base.c | 2 +- builtin/verify-commit.c | 4 +++- commit-graph.c | 10 +++++----- commit.c | 7 ++++--- commit.h | 3 ++- fetch-pack.c | 5 +++-- log-tree.c | 2 +- notes-utils.c | 4 +++- object.c | 2 +- sequencer.c | 4 ++-- sha1-name.c | 2 +- shallow.c | 17 ++++++++++------- tag.c | 2 +- tree.c | 2 +- 19 files changed, 46 insertions(+), 33 deletions(-)
builtin/am.c +2 -1
@@ -1633,7 +1633,8 @@ static void do_commit(const struct am_state *state)if (!get_oid_commit ("HEAD" , &parent)) { old_oid = &parent; -commit_list_insert (lookup_commit (&parent), &parents); +commit_list_insert (lookup_commit (the_repository, &parent), + &parents); }else { old_oid =NULL ;say (state, stderr,_ ("applying to an empty history" ));
builtin/commit-tree.c +3 -1
@@ -6,6 +6,7 @@#include "cache.h" #include "config.h" #include "object-store.h" +#include "repository.h" #include "commit.h" #include "tree.h" #include "builtin.h"
@@ -60,7 +61,8 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix)if (get_oid_commit (argv[i], &oid))die ("Not a valid object name %s" , argv[i]);assert_oid_type (&oid,OBJ_COMMIT ); -new_parent (lookup_commit (&oid), &parents); +new_parent (lookup_commit (the_repository, &oid), + &parents);continue ; }
builtin/diff-tree.c +1 -1
@@ -25,7 +25,7 @@ static int stdin_diff_commit(struct commit *commit, const char *p)/* Graft the fake parents locally to the commit */ while (isspace (*p++) && !parse_oid_hex (p, &oid, &p)) { -struct commit *parent =lookup_commit (&oid); +struct commit *parent =lookup_commit (the_repository, &oid);if (!pptr) {/* Free the real parent list */ free_commit_list (commit->parents);
builtin/fast-export.c +1 -1
@@ -963,7 +963,7 @@ static void import_marks(char *input_file)/* only commits */ continue ; - commit =lookup_commit (&oid); + commit =lookup_commit (the_repository, &oid);if (!commit)die ("not a commit? can't happen: %s" ,oid_to_hex (&oid));
builtin/fmt-merge-msg.c +1 -1
@@ -572,7 +572,7 @@ static void find_merge_parents(struct merge_parents *result,commit_list_insert (parent, &parents);add_merge_parent (result, &obj->oid, &parent->object.oid); } - head_commit =lookup_commit (head); + head_commit =lookup_commit (the_repository, head);if (head_commit)commit_list_insert (head_commit, &parents);reduce_heads_replace (&parents);
builtin/merge-base.c +1 -1
@@ -124,7 +124,7 @@ static void add_one_commit(struct object_id *oid, struct rev_collect *revs)if (is_null_oid (oid))return ; - commit =lookup_commit (oid); + commit =lookup_commit (the_repository, oid);if (!commit || (commit->object.flags &TMP_MARK ) ||parse_commit (commit))
builtin/verify-commit.c +3 -1
@@ -9,6 +9,7 @@#include "config.h" #include "builtin.h" #include "object-store.h" +#include "repository.h" #include "commit.h" #include "run-command.h" #include <signal.h>
@@ -27,7 +28,8 @@ static int run_gpg_verify(const struct object_id *oid, const char *buf, unsignedmemset (&signature_check,0 ,sizeof (signature_check)); - ret =check_commit_signature (lookup_commit (oid), &signature_check); + ret =check_commit_signature (lookup_commit (the_repository, oid), + &signature_check);print_signature_buffer (&signature_check, flags);signature_check_clear (&signature_check);
commit-graph.c +5 -5
@@ -242,7 +242,7 @@ static struct commit_list **insert_parent_or_die(struct commit_graph *g,struct commit *c;struct object_id oid;hashcpy (oid.hash, g->chunk_oid_lookup + g->hash_len * pos); - c =lookup_commit (&oid); + c =lookup_commit (the_repository, &oid);if (!c)die ("could not find commit %s" ,oid_to_hex (&oid)); c->graph_pos = pos;
@@ -568,7 +568,7 @@ static void close_reachable(struct packed_oid_list *oids)struct commit *commit;for (i =0 ; i < oids->nr; i++) { - commit =lookup_commit (&oids->list[i]); + commit =lookup_commit (the_repository, &oids->list[i]);if (commit) commit->object.flags |=UNINTERESTING ; }
@@ -579,14 +579,14 @@ static void close_reachable(struct packed_oid_list *oids)* closure. */ for (i =0 ; i < oids->nr; i++) { - commit =lookup_commit (&oids->list[i]); + commit =lookup_commit (the_repository, &oids->list[i]);if (commit && !parse_commit (commit))add_missing_parents (oids, commit); }for (i =0 ; i < oids->nr; i++) { - commit =lookup_commit (&oids->list[i]); + commit =lookup_commit (the_repository, &oids->list[i]);if (commit) commit->object.flags &= ~UNINTERESTING ;
@@ -737,7 +737,7 @@ void write_commit_graph(const char *obj_dir,if (i >0 && !oidcmp (&oids.list[i-1 ], &oids.list[i]))continue ; - commits.list[commits.nr] =lookup_commit (&oids.list[i]); + commits.list[commits.nr] =lookup_commit (the_repository, &oids.list[i]);parse_commit (commits.list[commits.nr]); for (parent = commits.list[commits.nr]->parents;
commit.c +4 -3
@@ -52,7 +52,7 @@ struct commit *lookup_commit_or_die(const struct object_id *oid, const char *refreturn c; } -struct commit *lookup_commit (const struct object_id *oid) +struct commit *lookup_commit_the_repository (const struct object_id *oid) {struct object *obj =lookup_object (the_repository, oid->hash);if (!obj)
@@ -402,7 +402,7 @@ int parse_commit_buffer(struct commit *item, const void *buffer, unsigned long s*/ if (graft && (graft->nr_parent <0 || grafts_replace_parents))continue ; - new_parent =lookup_commit (&parent); + new_parent =lookup_commit (the_repository, &parent);if (new_parent) pptr = &commit_list_insert (new_parent, pptr)->next; }
@@ -410,7 +410,8 @@ int parse_commit_buffer(struct commit *item, const void *buffer, unsigned long sint i;struct commit *new_parent;for (i =0 ; i < graft->nr_parent; i++) { - new_parent =lookup_commit (&graft->parent[i]); + new_parent =lookup_commit (the_repository, + &graft->parent[i]);if (!new_parent)continue ; pptr = &commit_list_insert (new_parent, pptr)->next;
commit.h +2 -1
@@ -63,7 +63,8 @@ enum decoration_type {void add_name_decoration (enum decoration_type type,const char *name,struct object *obj);const struct name_decoration *get_name_decoration (const struct object *obj); -struct commit *lookup_commit (const struct object_id *oid); +#define lookup_commit (r, o) lookup_commit_##r(o) +struct commit *lookup_commit_the_repository (const struct object_id *oid);#define lookup_commit_reference (r, o) \ lookup_commit_reference_##r(o)struct commit *lookup_commit_reference_the_repository (const struct object_id *oid);
fetch-pack.c +3 -2
@@ -498,7 +498,8 @@ static int find_common(struct fetch_pack_args *args,case ACK_ready:case ACK_continue: {struct commit *commit = -lookup_commit (result_oid); +lookup_commit (the_repository, + result_oid);if (!commit)die (_ ("invalid commit %s" ),oid_to_hex (result_oid)); if (args->stateless_rpc
@@ -1278,7 +1279,7 @@ static int process_acks(struct packet_reader *reader, struct oidset *common)if (!get_oid_hex (arg, &oid)) {struct commit *commit;oidset_insert (common, &oid); - commit =lookup_commit (&oid); + commit =lookup_commit (the_repository, &oid);mark_common (commit,0 ,1 ); }continue ;
log-tree.c +1 -1
@@ -134,7 +134,7 @@ static int add_ref_decoration(const char *refname, const struct object_id *oid,static int add_graft_decoration (const struct commit_graft *graft,void *cb_data) { -struct commit *commit =lookup_commit (&graft->oid); +struct commit *commit =lookup_commit (the_repository, &graft->oid);if (!commit)return 0 ;add_name_decoration (DECORATION_GRAFTED ,"grafted" , &commit->object);
notes-utils.c +3 -1
@@ -3,6 +3,7 @@#include "commit.h" #include "refs.h" #include "notes-utils.h" +#include "repository.h" void create_notes_commit(struct notes_tree *t, struct commit_list *parents, const char *msg, size_t msg_len,
@@ -19,7 +20,8 @@ void create_notes_commit(struct notes_tree *t, struct commit_list *parents,/* Deduce parent commit from t->ref */ struct object_id parent_oid;if (!read_ref (t->ref, &parent_oid)) { -struct commit *parent =lookup_commit (&parent_oid); +struct commit *parent =lookup_commit (the_repository, + &parent_oid);if (parse_commit (parent))die ("Failed to find/parse commit %s" , t->ref);commit_list_insert (parent, &parents);
object.c +1 -1
@@ -212,7 +212,7 @@ struct object *parse_object_buffer_the_repository(const struct object_id *oid, e } } }else if (type ==OBJ_COMMIT ) { -struct commit *commit =lookup_commit (oid); +struct commit *commit =lookup_commit (the_repository, oid);if (commit) {if (parse_commit_buffer (commit, buffer, size,1 ))return NULL ;
sequencer.c +2 -2
@@ -594,7 +594,7 @@ static int is_index_unchanged(void)if (!resolve_ref_unsafe ("HEAD" ,RESOLVE_REF_READING , &head_oid,NULL ))return error (_ ("could not resolve HEAD commit" )); - head_commit =lookup_commit (&head_oid); + head_commit =lookup_commit (the_repository, &head_oid);/* * If head_commit is NULL, check_commit, called from
@@ -1101,7 +1101,7 @@ void print_commit_summary(const char *prefix, const struct object_id *oid,struct strbuf author_ident =STRBUF_INIT ;struct strbuf committer_ident =STRBUF_INIT ; - commit =lookup_commit (oid); + commit =lookup_commit (the_repository, oid);if (!commit)die (_ ("couldn't look up newly created commit" ));if (parse_commit (commit))
sha1-name.c +1 -1
@@ -351,7 +351,7 @@ static int show_ambiguous_object(const struct object_id *oid, void *data) type =oid_object_info (the_repository, oid,NULL );if (type ==OBJ_COMMIT ) { -struct commit *commit =lookup_commit (oid); +struct commit *commit =lookup_commit (the_repository, oid);if (commit) {struct pretty_print_context pp = {0 }; pp.date_mode.type =DATE_SHORT ;
shallow.c +10 -7
@@ -31,7 +31,7 @@ int register_shallow(struct repository *r, const struct object_id *oid) {struct commit_graft *graft =xmalloc (sizeof (struct commit_graft )); -struct commit *commit =lookup_commit (oid); +struct commit *commit =lookup_commit (the_repository, oid);oidcpy (&graft->oid, oid); graft->nr_parent =-1 ;
@@ -259,7 +259,7 @@ static int write_one_shallow(const struct commit_graft *graft, void *cb_data)if (graft->nr_parent !=-1 )return 0 ;if (data->flags &SEEN_ONLY ) { -struct commit *c =lookup_commit (&graft->oid); +struct commit *c =lookup_commit (the_repository, &graft->oid);if (!c || !(c->object.flags &SEEN )) {if (data->flags &VERBOSE ) printf("Removing %s from .git/shallow\n",
@@ -624,7 +624,8 @@ void assign_shallow_commits_to_refs(struct shallow_info *info,/* Mark potential bottoms so we won't go out of bound */ for (i =0 ; i < nr_shallow; i++) { -struct commit *c =lookup_commit (&oid[shallow[i]]); +struct commit *c =lookup_commit (the_repository, + &oid[shallow[i]]); c->object.flags |=BOTTOM ; }
@@ -635,7 +636,8 @@ void assign_shallow_commits_to_refs(struct shallow_info *info,int bitmap_size =DIV_ROUND_UP (pi.nr_bits,32 ) *sizeof (uint32_t );memset (used,0 ,sizeof (*used) * info->shallow->nr);for (i =0 ; i < nr_shallow; i++) { -const struct commit *c =lookup_commit (&oid[shallow[i]]); +const struct commit *c =lookup_commit (the_repository, + &oid[shallow[i]]);uint32_t **map =ref_bitmap_at (&pi.ref_bitmap, c);if (*map) used[shallow[i]] =xmemdupz (*map, bitmap_size);
@@ -705,7 +707,7 @@ static void post_assign_shallow(struct shallow_info *info,for (i = dst =0 ; i < info->nr_theirs; i++) {if (i != dst) info->theirs[dst] = info->theirs[i]; - c =lookup_commit (&oid[info->theirs[i]]); + c =lookup_commit (the_repository, &oid[info->theirs[i]]); bitmap =ref_bitmap_at (ref_bitmap, c);if (!*bitmap)continue ;
@@ -726,7 +728,7 @@ static void post_assign_shallow(struct shallow_info *info,for (i = dst =0 ; i < info->nr_ours; i++) {if (i != dst) info->ours[dst] = info->ours[i]; - c =lookup_commit (&oid[info->ours[i]]); + c =lookup_commit (the_repository, &oid[info->ours[i]]); bitmap =ref_bitmap_at (ref_bitmap, c);if (!*bitmap)continue ;
@@ -748,7 +750,8 @@ static void post_assign_shallow(struct shallow_info *info,int delayed_reachability_test (struct shallow_info *si,int c) {if (si->need_reachability_test[c]) { -struct commit *commit =lookup_commit (&si->shallow->oid[c]); +struct commit *commit =lookup_commit (the_repository, + &si->shallow->oid[c]);if (!si->commits) {struct commit_array ca;
tag.c +1 -1
@@ -158,7 +158,7 @@ int parse_tag_buffer(struct tag *item, const void *data, unsigned long size) }else if (!strcmp (type, tree_type)) { item->tagged = (struct object *)lookup_tree (the_repository, &oid); }else if (!strcmp (type, commit_type)) { - item->tagged = (struct object *)lookup_commit (&oid); + item->tagged = (struct object *)lookup_commit (the_repository, &oid); }else if (!strcmp (type, tag_type)) { item->tagged = (struct object *)lookup_tag (&oid); }else {
tree.c +1 -1
@@ -101,7 +101,7 @@ static int read_tree_1(struct tree *tree, struct strbuf *base,else if (S_ISGITLINK (entry.mode)) {struct commit *commit; - commit =lookup_commit (entry.oid); + commit =lookup_commit (the_repository, entry.oid);if (!commit) die("Commit %s in submodule path %s%s not found", oid_to_hex(entry.oid),
Signature · 1 line
2.18.0.399.gad0ab374a1-goog
PATCH v3 13/32 tag: add repository argument to lookup_tag
In reply to Stefan BellerAdd a repository argument to allow the callers of lookup_tag to be more specific about which repository to act on. This is a small mechanical change; it doesn't change the implementation to handle repositories other than the_repository yet.
As with the previous commits, use a macro to catch callers passing a repository other than the_repository at compile time.
--- builtin/describe.c | 6 +++--- builtin/pack-objects.c | 2 +- builtin/replace.c | 2 +- log-tree.c | 2 +- object.c | 2 +- sha1-name.c | 2 +- tag.c | 4 ++-- tag.h | 4 ++-- 8 files changed, 12 insertions(+), 12 deletions(-)
builtin/describe.c +3 -3
@@ -93,13 +93,13 @@ static int replace_name(struct commit_name *e,struct tag *t;if (!e->tag) { - t =lookup_tag (&e->oid); + t =lookup_tag (the_repository, &e->oid);if (!t ||parse_tag (t))return 1 ; e->tag = t; } - t =lookup_tag (oid); + t =lookup_tag (the_repository, oid);if (!t ||parse_tag (t))return 0 ; *tag = t;
@@ -267,7 +267,7 @@ static unsigned long finish_depth_computation(static void append_name (struct commit_name *n,struct strbuf *dst) {if (n->prio ==2 && !n->tag) { - n->tag =lookup_tag (&n->oid); + n->tag =lookup_tag (the_repository, &n->oid);if (!n->tag ||parse_tag (n->tag))die (_ ("annotated tag %s not available" ), n->path); }
builtin/pack-objects.c +1 -1
@@ -2474,7 +2474,7 @@ static void add_tag_chain(const struct object_id *oid)if (packlist_find (&to_pack, oid->hash,NULL ))return ; - tag =lookup_tag (oid); + tag =lookup_tag (the_repository, oid);while (1 ) {if (!tag ||parse_tag (tag) || !tag->tagged) die("unable to pack objects reachable from tag %s",
builtin/replace.c +1 -1
@@ -402,7 +402,7 @@ static int check_one_mergetag(struct commit *commit,int i;hash_object_file (extra->value, extra->len,type_name (OBJ_TAG ), &tag_oid); - tag =lookup_tag (&tag_oid); + tag =lookup_tag (the_repository, &tag_oid);if (!tag)return error (_ ("bad mergetag in commit '%s'" ), ref);if (parse_tag_buffer (tag, extra->value, extra->len))
log-tree.c +1 -1
@@ -498,7 +498,7 @@ static int show_one_mergetag(struct commit *commit,size_t payload_size, gpg_message_offset;hash_object_file (extra->value, extra->len,type_name (OBJ_TAG ), &oid); - tag =lookup_tag (&oid); + tag =lookup_tag (the_repository, &oid);if (!tag)return -1 ;/* error message already given */
object.c +1 -1
@@ -223,7 +223,7 @@ struct object *parse_object_buffer_the_repository(const struct object_id *oid, e obj = &commit->object; } }else if (type ==OBJ_TAG ) { -struct tag *tag =lookup_tag (oid); +struct tag *tag =lookup_tag (the_repository, oid);if (tag) {if (parse_tag_buffer (tag, buffer, size))return NULL ;
sha1-name.c +1 -1
@@ -358,7 +358,7 @@ static int show_ambiguous_object(const struct object_id *oid, void *data)format_commit_message (commit," %ad - %s" , &desc, &pp); } }else if (type ==OBJ_TAG ) { -struct tag *tag =lookup_tag (oid); +struct tag *tag =lookup_tag (the_repository, oid);if (!parse_tag (tag) && tag->tag)strbuf_addf (&desc," %s" , tag->tag); }
tag.c +2 -2
@@ -92,7 +92,7 @@ struct object *deref_tag_noverify(struct object *o)return o; } -struct tag *lookup_tag (const struct object_id *oid) +struct tag *lookup_tag_the_repository (const struct object_id *oid) {struct object *obj =lookup_object (the_repository, oid->hash);if (!obj)
@@ -160,7 +160,7 @@ int parse_tag_buffer(struct tag *item, const void *data, unsigned long size) }else if (!strcmp (type, commit_type)) { item->tagged = (struct object *)lookup_commit (the_repository, &oid); }else if (!strcmp (type, tag_type)) { - item->tagged = (struct object *)lookup_tag (&oid); + item->tagged = (struct object *)lookup_tag (the_repository, &oid); }else {error ("Unknown type %s" , type); item->tagged =NULL ;
tag.h +2 -2
@@ -11,8 +11,8 @@ struct tag {char *tag;timestamp_t date; }; - -extern struct tag *lookup_tag (const struct object_id *oid); +#define lookup_tag (r, o) lookup_tag_##r(o) +extern struct tag *lookup_tag_the_repository (const struct object_id *oid);extern int parse_tag_buffer (struct tag *item,const void *data,unsigned long size);extern int parse_tag (struct tag *item);extern void release_tag_memory (struct tag *t);
Signature · 1 line
2.18.0.399.gad0ab374a1-goog
Re: [PATCH v3 09/32] commit: add repository argument to lookup_commit
In reply to Stefan BellerQuoted 7 lines · Stefan Beller
Add a repository argument to allow callers of
lookup_committo be more specific about which repository to handle. This is a small mechanical change; it doesn't change the implementation to handle repositories other thanthe_repositoryyet.As with the previous commits, use a macro to catch callers passing a repository other than
the_repositoryat compile time.
In ds/commit-graph-fsck I add a few new callers to lookup_commit(), which will affect this patch on a reroll.
Thanks,
-Stolee
Re: [PATCH v3 10/32] commit: add repository argument to parse_commit_buffer
In reply to Stefan BellerQuoted 44 lines · Stefan Beller
Add a repository argument to allow the callers of
parse_commit_bufferto be more specific about which repository to act on. This is a small mechanical change; it doesn't change the implementation to handle repositories other thanthe_repositoryyet.As with the previous commits, use a macro to catch callers passing a repository other than
the_repositoryat compile time.Signed-off-by Jonathan Nieder <[email protected]>Signed-off-by Stefan Beller <[email protected]>--- commit.c | 4 ++-- commit.h | 3 ++- object.c | 2 +- sha1-file.c | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-)commit.c +2
-2@@ -363,7 +363,7 @@ const void *detach_commit_buffer(struct commit *commit, unsigned long *sizep)return ret; } -int parse_commit_buffer (struct commit *item,const void *buffer,unsigned long size,int check_graph) +int parse_commit_buffer_the_repository (struct commit *item,const void *buffer,unsigned long size,int check_graph) {const char *tail = buffer;const char *bufptr = buffer;@@ -448,7 +448,7 @@ int parse_commit_gently(struct commit *item, int quiet_on_missing)return error ("Object %s not a commit" ,oid_to_hex (&item->object.oid)); } - ret =parse_commit_buffer (item, buffer, size,0 ); + ret =parse_commit_buffer (the_repository, item, buffer, size,0 );if (save_commit_buffer && !ret) {set_commit_buffer (item, buffer, size);return 0 ;commit.h +0
-0
commit.h struct commit *lookup_commit_reference_by_name(const char *name); · line 89
Quoted 9 lines
commit.h +2
-1@@ -82,7 +82,8 @@ struct commit *lookup_commit_reference_by_name(const char *name);*/ struct commit *lookup_commit_or_die (const struct object_id *oid,const char *ref_name); -int parse_commit_buffer (struct commit *item,const void *buffer,unsigned long size,int check_graph); +#define parse_commit_buffer (r, i, b, s, g) parse_commit_buffer_##r(i, b, s, g) +int parse_commit_buffer_the_repository (struct commit *item,const void *buffer,unsigned long size,int check_graph);int parse_commit_gently (struct commit *item,int quiet_on_missing);static inline int parse_commit (struct commit *item) {
This part also conflicts with ds/commit-graph-fsck because I added a 'parse_commit_internal' between parse_commit_buffer() and parse_commit_gently(). Likely, you'll want to add a repository struct to that method, too.
That series also adds new callers to parse_commit_buffer().
Quoted 26 lines
object.c +1
-1@@ -214,7 +214,7 @@ struct object *parse_object_buffer_the_repository(const struct object_id *oid, e }else if (type ==OBJ_COMMIT ) {struct commit *commit =lookup_commit (the_repository, oid);if (commit) { -if (parse_commit_buffer (commit, buffer, size,1 )) +if (parse_commit_buffer (the_repository, commit, buffer, size,1 ))return NULL ;if (!get_cached_commit_buffer (commit,NULL )) {set_commit_buffer (commit, buffer, size);sha1-file.c +1
-1@@ -1801,7 +1801,7 @@ static void check_commit(const void *buf, size_t size) {struct commit c;memset (&c,0 ,sizeof (c)); -if (parse_commit_buffer (&c, buf, size,0 )) +if (parse_commit_buffer (the_repository, &c, buf, size,0 ))die ("corrupt commit" ); }
Quoted 8 lines · Stefan Beller
This continues the elimination of global variables in the object store and teaches lookup_commit[_reference] and alike to handle
a_repository.This is also available as
https://github.com/stefanbeller/git/tree/object-store-lookup-commit
or applies on top of02f70d63027(Merge branch 'sb/object-store-grafts' into next, 2018-06-28).
Quoted 8 lines
Picking a base for this one is really hard, as nearly all series currently cooking or in flight collide with it on one or two lines. (lookup_* is used heavily, who would have thought?); I really needed 'sb/object-store-grafts' to build on; and there is only one other series before that in current next, which this series would have conflicted with, if not based on top of it.
In "The state of the object store series" [1], this was tentatively named "sb/object-store-lookup".
As usual, this series was easy to review. It has a few places where it conflicts with ds/commit-graph-fsck, but they are not hard to resolve. I created a merge commit between that branch and your version of this series [1]. It passes all tests on my machine.
Thanks,
-Stolee
[1] https://github.com/derrickstolee/git/commits/commit-graph-fsck-and-object-store
Quoted 11 lines · Stefan Beller
This continues the elimination of global variables in the object store and teaches lookup_commit[_reference] and alike to handle
a_repository.This is also available as
https://github.com/stefanbeller/git/tree/object-store-lookup-commit
or applies on top of02f70d63027(Merge branch 'sb/object-store-grafts' into next, 2018-06-28).Picking a base for this one is really hard, as nearly all series currently cooking or in flight collide with it on one or two lines. (lookup_* is used heavily, who would have thought?)
One technique these (not just this) recent efforts seem to be forgetting is to introduce "new" names that take a_repo and then make the existing one a thin wrapper that calls the new one with &the_repo as the argument.
IOW, a new call to lookup_commit_reference(oid) in a function that is happy to access the default repo (and notice taht 99% of our code is happy with using just the currrent repository the user started the git process for) does not need to be updated to call the function with the same name with a different function signature lookup_commit_reference(the_repo, oid). If we name the new one lookup_commit_reference_in_repo(r, oid) and make the callers that already take a repo pointer call it, while leaving the callers that do not even know or care about multiple in-core repo instances alone to keep calling lookup_commit_reference(oid), you do not have to worry too much about colliding. That way, you do not have to step on each others' toes with avoidable semantic merge conflicts and incrementally improve things over time, no?
Thanks.
Quoted 4 lines · Junio C Hamano
One technique these (not just this) recent efforts seem to be forgetting is to introduce "new" names that take
a_repoand then make the existing one a thin wrapper that calls the new one with&the_repoas the argument.
FWIW, here is how I am resolving semantic conflicts that I found so far while merging this topic to 'pu', which is stored in the merge-fix/ mechanism so that I can reuse it while rebuilding 'pu'.
-- >8 --
Subject: [PATCH] merge-fix/sb/object-store-lookup
--- builtin/bisect--helper.c | 2 +- builtin/branch-diff.c | 2 +- commit-graph.c | 4 ++-- negotiator/default.c | 3 ++- 4 files changed, 6 insertions(+), 5 deletions(-)
builtin/bisect--helper.c +1 -1
@@ -231,7 +231,7 @@ static int bisect_write(const char *state, const char *rev, goto fail; } - commit =lookup_commit_reference (&oid); + commit =lookup_commit_reference (the_repository, &oid);log_commit (fp,"%s" , state, commit);if (!nolog)
builtin/branch-diff.c +1 -1
@@ -329,7 +329,7 @@ static void output_pair_header(struct diff_options *diffopt, struct strbuf *buf,strbuf_addf (buf," %d: %s" , j +1 ,find_unique_abbrev (&b_util->oid,DEFAULT_ABBREV )); - commit =lookup_commit_reference (oid); + commit =lookup_commit_reference (the_repository, oid);if (commit) {const char *commit_buffer =get_commit_buffer (commit,NULL );const char *subject;
commit-graph.c +2 -2
@@ -924,7 +924,7 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g) cur_fanout_pos++; } - graph_commit =lookup_commit (&cur_oid); + graph_commit =lookup_commit (r, &cur_oid);if (!parse_commit_in_graph_one (g, graph_commit))graph_report ("failed to parse %s from commit-graph" ,oid_to_hex (&cur_oid));
@@ -950,7 +950,7 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g)hashcpy (cur_oid.hash, g->chunk_oid_lookup + g->hash_len * i); - graph_commit =lookup_commit (&cur_oid); + graph_commit =lookup_commit (r, &cur_oid); odb_commit = (struct commit *)create_object (r, cur_oid.hash,alloc_commit_node (r));if (parse_commit_internal (odb_commit,0 ,0 )) { graph_report("failed to parse %s from object database",
negotiator/default.c +2 -1
@@ -38,7 +38,8 @@ static void rev_list_push(struct negotiation_state *ns,static int clear_marks (const char *refname,const struct object_id *oid,int flag,void *cb_data) { -struct object *o =deref_tag (parse_object (oid), refname,0 ); +struct object *o =deref_tag (the_repository, +parse_object (the_repository, oid), refname,0 );if (o && o->type ==OBJ_COMMIT ) clear_commit_marks((struct commit *)o,
Signature · 1 line
2.18.0-129-ge3331758f1
Quoted 7 lines · Junio C Hamano
Quoted 4 lines · Junio C Hamano
One technique these (not just this) recent efforts seem to be forgetting is to introduce "new" names that take
a_repoand then make the existing one a thin wrapper that calls the new one with&the_repoas the argument.
So you'd rather want to see it less invasive done similar to NO_THE_INDEX_COMPATIBILITY_MACROS ? Someone (jrnieder?) called that a failed experiment, as now we need to carry that baggage for quite some time and never cleaned up the started migration; only recently Duy started to kill off the_index, which would finish that migration?
Quoted 11 lines
FWIW, here is how I am resolving semantic conflicts that I found so far while merging this topic to 'pu', which is stored in the merge-fix/ mechanism so that I can reuse it while rebuilding 'pu'.
-- >8 --
Subject: [PATCH] merge-fix/sb/object-store-lookup--- builtin/bisect--helper.c | 2 +- builtin/branch-diff.c | 2 +- negotiator/default.c | 3 ++-
These look as if we can just use the_repository
(as you did below).
Quoted 1 line
commit-graph.c | 4 ++--
That is what I want to tackle next, and apparently you already did by using the repository *r in there.
Thanks,
Stefan
Quoted 9 lines · Stefan Beller
Quoted 7 lines · Junio C Hamano
Quoted 4 lines · Junio C Hamano
One technique these (not just this) recent efforts seem to be forgetting is to introduce "new" names that take
a_repoand then make the existing one a thin wrapper that calls the new one with&the_repoas the argument.
Quoted 6 lines
So you'd rather want to see it less invasive done similar to
NO_THE_INDEX_COMPATIBILITY_MACROS? Someone (jrnieder?) called that a failed experiment, as now we need to carry that baggage for quite some time and never cleaned up the started migration; only recently Duy started to kill offthe_index, which would finish that migration?
I do not think it was a failed experiment at all. In fact, most of our code is still happy with the single in-core instance of the_index, and I think it is a mistake to trying to use the variant that take an istate instance as parameter just for the sake of it.
IOW, if there is a good concrete reason why it helps to teach the set of functions involved in a callchain to operate on an in-core instance of the index_state, passing an istate through the callchain is a very welcome change. If you do not do so, and then just replace $foo_cache(...) with $foo_index(&the_index, ...), that is an irritating and useless code churn that harms other topics in flight.
Quoted 23 lines · Junio C Hamano
Quoted 9 lines · Stefan Beller
Quoted 7 lines · Junio C Hamano
Quoted 4 lines · Junio C Hamano
One technique these (not just this) recent efforts seem to be forgetting is to introduce "new" names that take
a_repoand then make the existing one a thin wrapper that calls the new one with&the_repoas the argument.Quoted 6 lines
So you'd rather want to see it less invasive done similar to
NO_THE_INDEX_COMPATIBILITY_MACROS? Someone (jrnieder?) called that a failed experiment, as now we need to carry that baggage for quite some time and never cleaned up the started migration; only recently Duy started to kill offthe_index, which would finish that migration?I do not think it was a failed experiment at all. In fact, most of our code is still happy with the single in-core instance of
the_index, and I think it is a mistake to trying to use the variant that take an istate instance as parameter just for the sake of it.
Quoted 6 lines
IOW, if there is a good concrete reason why it helps to teach the set of functions involved in a callchain to operate on an in-core instance of the
index_state, passing an istate through the callchain is a very welcome change. If you do not do so, and then just replace $foo_cache(...) with $foo_index(&the_index, ...), that is an irritating and useless code churn that harms other topics in flight.
I 100% think that we need to continue these refactorings with both the object store as well as with the_index (removing the index macros and removing the dependency on global state). The whole compat macros most definitely was a failed experiment as we still haven't rid the code base of them yet. Having two APIs which can be used interchangeably from different pieces of library code which have very different semantics is _very_ difficult for contributors to reason about and work around. Especially when one API relies on implied global state while the other does not. (If global state isn't involved, as in the char[20] -> OID work, then having two APIs is 'ok' so long as you're working towards converging to one API).
Having clean APIs makes it incredible easy to reason about sections of code, reason about multi-threading, and implement newer features in a sane manner (talking about submodules here). I implemented submodule support for grep twice, once using a multi-process paradigm because we could not have two repositories open in a single process and then an in-process one once a minimum viable solution for opening multiple repositories in a single process was created. Being able to open up a submodule repository in-process made things infinitely simpler to reason about as well as made it much easier to handle errors. This work needs to continue if we want to improve the submodule experience in git.
Yes this might mean there are a few more conflicts when merging a series (because of the scope of these refactorings) but it is well worth it given what the end-state will look like.
Signature · 1 line
Brandon Williams
Quoted 5 lines · Brandon Williams
I 100% think that we need to continue these refactorings with both the object store as well as with
the_index(removing the index macros and removing the dependency on global state). The whole compat macros most definitely was a failed experiment as we still haven't rid the code base of them yet.
These two are completely different things. You can call the compat macros a failed experiment only if two things hold true: (1) we want to force all callsites to explicitly pass the_index even when they always work on the primary in-core instance of istate and (2) they were invented primarily in the hope that their presense will help us achieve (1) sooner. And neither is true. The mechanism to allow multiple in-core istate were of course helpful in places like branch switching and merging, but we expected that the majority of then-existing code would be required to work on the primary in-core index, so s/foo_cache(/foo_index(&the_index/ conversion all over the place were noisier than it was worth. The compat macros were not introduced as an experiment to help wean ourselves off of the foo_cache API. It was a total opposite---it was a consideration on production code to help existing code keep working in backward compatible way. In short, they were neither failed nor experiment.
What you _could_ say about them, given that more code than before would benefit by learning to work on istate instances other than the default &the_index these days, is that they may have outlived their usefulness, though.