object-store: lookup_commit
cover object-store: lookup_commit
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
Jonathan Nieder (1):
object: add repository argument to lookup_unknown_object
Stefan Beller (34):
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: add repository argument to parse_commit_gently
commit: add repository argument to parse_commit
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 | 17 +++--- blob.c | 10 ++-- blob.h | 2 +- branch.c | 2 +- builtin/am.c | 9 ++- builtin/branch.c | 7 ++- builtin/checkout.c | 10 ++-- builtin/clone.c | 3 +- builtin/commit-tree.c | 4 +- builtin/commit.c | 2 +- builtin/describe.c | 17 +++--- 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 | 22 ++++--- builtin/grep.c | 3 +- builtin/index-pack.c | 5 +- builtin/log.c | 10 ++-- builtin/merge-base.c | 9 +-- builtin/merge-tree.c | 3 +- builtin/name-rev.c | 15 +++-- builtin/notes.c | 5 +- builtin/pack-objects.c | 4 +- builtin/prune.c | 2 +- builtin/pull.c | 15 +++-- builtin/receive-pack.c | 6 +- builtin/reflog.c | 17 +++--- builtin/replace.c | 4 +- builtin/reset.c | 4 +- builtin/rev-list.c | 2 +- builtin/rev-parse.c | 6 +- builtin/show-branch.c | 9 +-- builtin/tag.c | 2 +- builtin/unpack-objects.c | 7 ++- builtin/verify-commit.c | 4 +- bundle.c | 10 ++-- cache-tree.c | 3 +- commit-graph.c | 20 +++---- commit-slab-impl.h | 3 - commit.c | 100 ++++++++++++++++++------------- commit.h | 24 +++++--- fast-import.c | 6 +- fetch-pack.c | 45 ++++++++------ fsck.c | 9 +-- http-backend.c | 4 +- http-push.c | 18 +++--- line-log.c | 2 +- list-objects.c | 4 +- log-tree.c | 13 ++-- merge-recursive.c | 15 +++-- notes-cache.c | 3 +- notes-merge.c | 5 +- notes-utils.c | 6 +- object.c | 63 ++++++++++--------- object.h | 13 ++-- packfile.c | 2 +- parse-options-cb.c | 2 +- pretty.c | 4 +- reachable.c | 8 +-- ref-filter.c | 12 ++-- reflog-walk.c | 3 +- refs.c | 4 +- refs/files-backend.c | 2 +- remote.c | 21 ++++--- revision.c | 37 ++++++------ sequencer.c | 30 +++++----- server-info.c | 4 +- sha1-file.c | 4 +- sha1-name.c | 37 ++++++------ shallow.c | 34 +++++++---- submodule.c | 10 ++-- t/helper/test-example-decorate.c | 6 +- tag.c | 28 ++++----- tag.h | 7 +-- tree.c | 21 +++---- tree.h | 2 +- upload-pack.c | 19 +++--- walker.c | 16 +++-- wt-status.c | 2 +- 83 files changed, 547 insertions(+), 423 deletions(-)
Signature · 1 line
2.17.0.582.gccdcbd54c44.dirty
PATCH 1/35 object: add repository argument to parse_object
Add 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
@@ -393,7 +393,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
@@ -802,7 +802,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)) {/*
@@ -616,7 +616,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
@@ -26,7 +26,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 ;
@@ -1616,7 +1617,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 ;
@@ -1296,7 +1298,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"
@@ -462,7 +463,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"
@@ -111,13 +112,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 ;
@@ -138,7 +139,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"
@@ -2183,7 +2184,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
@@ -121,7 +121,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
@@ -1924,7 +1924,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"
@@ -1898,7 +1899,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
@@ -1994,12 +1994,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
@@ -187,7 +187,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" );
@@ -199,7 +199,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;
@@ -236,7 +236,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 ;
@@ -1239,7 +1239,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 ??? */
@@ -1567,8 +1567,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);
@@ -2872,7 +2872,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 ;
@@ -857,7 +857,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;
@@ -930,12 +930,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 ;
@@ -1062,7 +1062,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 ) {
@@ -1108,7 +1108,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 ;
@@ -798,7 +799,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",
@@ -1168,7 +1169,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",
@@ -1274,7 +1275,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.17.0.582.gccdcbd54c44.dirty
PATCH 2/35 object: add repository argument to lookup_object
In reply to Stefan BellerAdd 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
@@ -231,7 +231,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 ;
@@ -403,7 +403,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,
@@ -762,7 +762,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
@@ -53,7 +53,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 ; }
@@ -1295,7 +1296,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
@@ -110,7 +110,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
@@ -568,7 +568,7 @@ static int get_reachable_list(struct object_array *src,if (namebuf[40 ] !='\n' ||get_oid_hex (namebuf, &sha1))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.17.0.582.gccdcbd54c44.dirty
PATCH 3/35 object: add repository argument to lookup_unknown_object
In reply to Stefan BellerFrom: Jonathan Nieder <[email protected]>
Add a repository argument to allow callers of lookup_unknown_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.
The included coccinelle semantic patch will adapt any new callers in the diff produced by make coccicheck.
--- builtin/fsck.c | 2 +- builtin/pack-objects.c | 2 +- http-push.c | 2 +- object.c | 2 +- object.h | 3 ++- refs.c | 2 +- t/helper/test-example-decorate.c | 6 +++--- upload-pack.c | 2 +- walker.c | 2 +- 9 files changed, 12 insertions(+), 11 deletions(-)
builtin/fsck.c +1 -1
@@ -638,7 +638,7 @@ static int fsck_cache_tree(struct cache_tree *it)static void mark_object_for_connectivity (const struct object_id *oid) { -struct object *obj =lookup_unknown_object (oid->hash); +struct object *obj =lookup_unknown_object (the_repository, oid->hash); obj->flags |=HAS_OBJ ; }
builtin/pack-objects.c +1 -1
@@ -2689,7 +2689,7 @@ static void add_objects_in_unpacked_packs(struct rev_info *revs)for (i =0 ; i < p->num_objects; i++) {nth_packed_object_oid (&oid, p, i); - o =lookup_unknown_object (oid.hash); + o =lookup_unknown_object (the_repository, oid.hash);if (!(o->flags &OBJECT_ADDED ))mark_in_pack_object (o, p, &in_pack); o->flags |=OBJECT_ADDED ;
http-push.c +1 -1
@@ -1429,7 +1429,7 @@ static void one_remote_ref(const char *refname)* may be required for updating server info later. */ if (repo->can_update_info_refs && !has_object_file (&ref->old_oid)) { - obj =lookup_unknown_object (ref->old_oid.hash); + obj =lookup_unknown_object (the_repository, ref->old_oid.hash);fprintf (stderr," fetch %s for %s\n" ,oid_to_hex (&ref->old_oid), refname);add_fetch_request (obj);
object.c +1 -1
@@ -177,7 +177,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 *lookup_unknown_object_the_repository (const unsigned char *sha1) {struct object *obj =lookup_object (the_repository, sha1);if (!obj)
object.h +2 -1
@@ -139,7 +139,8 @@ struct object *parse_object_or_die(const struct object_id *oid, const char *namestruct object *parse_object_buffer (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); +#define lookup_unknown_object (r, s) lookup_unknown_object_##r(s) +struct object *lookup_unknown_object_the_repository (const unsigned char *sha1);struct object_list *object_list_insert (struct object *item,struct object_list **list_p);
refs.c +1 -1
@@ -301,7 +301,7 @@ static int filter_refs(const char *refname, const struct object_id *oid,enum peel_status peel_object (const struct object_id *name,struct object_id *oid) { -struct object *o =lookup_unknown_object (name->hash); +struct object *o =lookup_unknown_object (the_repository, name->hash);if (o->type ==OBJ_NONE ) {int type =oid_object_info (the_repository, name,NULL );
t/helper/test-example-decorate.c +3 -3
@@ -26,8 +26,8 @@ int cmd__example_decorate(int argc, const char **argv)* Add 2 objects, one with a non-NULL decoration and one with a NULL * decoration. */ - one =lookup_unknown_object (one_oid.hash); - two =lookup_unknown_object (two_oid.hash); + one =lookup_unknown_object (the_repository, one_oid.hash); + two =lookup_unknown_object (the_repository, two_oid.hash); ret =add_decoration (&n, one, &decoration_a);if (ret)die ("BUG: when adding a brand-new object, NULL should be returned" );
@@ -56,7 +56,7 @@ int cmd__example_decorate(int argc, const char **argv) ret =lookup_decoration (&n, two);if (ret != &decoration_b)die ("BUG: lookup should return added declaration" ); - three =lookup_unknown_object (three_oid.hash); + three =lookup_unknown_object (the_repository, three_oid.hash); ret =lookup_decoration (&n, three);if (ret)die ("BUG: lookup for unknown object should return NULL" );
upload-pack.c +1 -1
@@ -971,7 +971,7 @@ static void receive_needs(void)static int mark_our_ref (const char *refname,const char *refname_full,const struct object_id *oid) { -struct object *o =lookup_unknown_object (oid->hash); +struct object *o =lookup_unknown_object (the_repository, oid->hash);if (ref_is_hidden (refname, refname_full)) { o->flags |=HIDDEN_REF ;
walker.c +1 -1
@@ -282,7 +282,7 @@ int walker_fetch(struct walker *walker, int targets, char **target,error ("Could not interpret response from server '%s' as something to pull" , target[i]); goto done; } -if (process (walker,lookup_unknown_object (oids[i].hash))) +if (process (walker,lookup_unknown_object (the_repository, oids[i].hash))) goto done; }
Signature · 1 line
2.17.0.582.gccdcbd54c44.dirty
Re: [PATCH 03/35] object: add repository argument to lookup_unknown_object
Quoted 7 lines · Stefan Beller
From: Jonathan Nieder <[email protected]>
Add a repository argument to allow callers of
lookup_unknown_objectto 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.
Quoted 5 lines
As with the previous commits, use a macro to catch callers passing a repositor other than
the_repositoryat compile time.The included coccinelle semantic patch will adapt any new callers in the diff produced by
make coccicheck.
I don't see any coccinelle change in this patch.
Perhaps it is in a later commit?
Thanks,
-Stolee
Quoted 144 lines
Signed-off-by Jonathan Nieder <[email protected]>Signed-off-by Stefan Beller <[email protected]>--- builtin/fsck.c | 2 +- builtin/pack-objects.c | 2 +- http-push.c | 2 +- object.c | 2 +- object.h | 3 ++- refs.c | 2 +- t/helper/test-example-decorate.c | 6 +++--- upload-pack.c | 2 +- walker.c | 2 +- 9 files changed, 12 insertions(+), 11 deletions(-)builtin/fsck.c +1
-1@@ -638,7 +638,7 @@ static int fsck_cache_tree(struct cache_tree *it)static void mark_object_for_connectivity (const struct object_id *oid) { -struct object *obj =lookup_unknown_object (oid->hash); +struct object *obj =lookup_unknown_object (the_repository, oid->hash); obj->flags |=HAS_OBJ ; }builtin/pack-objects.c +1
-1@@ -2689,7 +2689,7 @@ static void add_objects_in_unpacked_packs(struct rev_info *revs)for (i =0 ; i < p->num_objects; i++) {nth_packed_object_oid (&oid, p, i); - o =lookup_unknown_object (oid.hash); + o =lookup_unknown_object (the_repository, oid.hash);if (!(o->flags &OBJECT_ADDED ))mark_in_pack_object (o, p, &in_pack); o->flags |=OBJECT_ADDED ;http-push.c +1
-1@@ -1429,7 +1429,7 @@ static void one_remote_ref(const char *refname)* may be required for updating server info later. */ if (repo->can_update_info_refs && !has_object_file (&ref->old_oid)) { - obj =lookup_unknown_object (ref->old_oid.hash); + obj =lookup_unknown_object (the_repository, ref->old_oid.hash);fprintf (stderr," fetch %s for %s\n" ,oid_to_hex (&ref->old_oid), refname);add_fetch_request (obj);object.c +1
-1@@ -177,7 +177,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 *lookup_unknown_object_the_repository (const unsigned char *sha1) {struct object *obj =lookup_object (the_repository, sha1);if (!obj)object.h +2
-1@@ -139,7 +139,8 @@ struct object *parse_object_or_die(const struct object_id *oid, const char *namestruct object *parse_object_buffer (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); +#define lookup_unknown_object (r, s) lookup_unknown_object_##r(s) +struct object *lookup_unknown_object_the_repository (const unsigned char *sha1);struct object_list *object_list_insert (struct object *item,struct object_list **list_p);refs.c +1
-1@@ -301,7 +301,7 @@ static int filter_refs(const char *refname, const struct object_id *oid,enum peel_status peel_object (const struct object_id *name,struct object_id *oid) { -struct object *o =lookup_unknown_object (name->hash); +struct object *o =lookup_unknown_object (the_repository, name->hash);if (o->type ==OBJ_NONE ) {int type =oid_object_info (the_repository, name,NULL );t/helper/test-example-decorate.c +3
-3@@ -26,8 +26,8 @@ int cmd__example_decorate(int argc, const char **argv)* Add 2 objects, one with a non-NULL decoration and one with a NULL * decoration. */ - one =lookup_unknown_object (one_oid.hash); - two =lookup_unknown_object (two_oid.hash); + one =lookup_unknown_object (the_repository, one_oid.hash); + two =lookup_unknown_object (the_repository, two_oid.hash); ret =add_decoration (&n, one, &decoration_a);if (ret)die ("BUG: when adding a brand-new object, NULL should be returned" );@@ -56,7 +56,7 @@ int cmd__example_decorate(int argc, const char **argv) ret =lookup_decoration (&n, two);if (ret != &decoration_b)die ("BUG: lookup should return added declaration" ); - three =lookup_unknown_object (three_oid.hash); + three =lookup_unknown_object (the_repository, three_oid.hash); ret =lookup_decoration (&n, three);if (ret)die ("BUG: lookup for unknown object should return NULL" );upload-pack.c +1
-1@@ -971,7 +971,7 @@ static void receive_needs(void)static int mark_our_ref (const char *refname,const char *refname_full,const struct object_id *oid) { -struct object *o =lookup_unknown_object (oid->hash); +struct object *o =lookup_unknown_object (the_repository, oid->hash);if (ref_is_hidden (refname, refname_full)) { o->flags |=HIDDEN_REF ;walker.c +1
-1@@ -282,7 +282,7 @@ int walker_fetch(struct walker *walker, int targets, char **target,error ("Could not interpret response from server '%s' as something to pull" , target[i]); goto done; } -if (process (walker,lookup_unknown_object (oids[i].hash))) +if (process (walker,lookup_unknown_object (the_repository, oids[i].hash))) goto done; }
Re: [PATCH 03/35] object: add repository argument to lookup_unknown_object
In reply to Stefan Bellerobject.c void *object_as_type(struct object *obj, enum object_type type, int quiet) · line 180
Quoted 10 lines · Stefan Beller
object.c +1
-1@@ -177,7 +177,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 *lookup_unknown_object_the_repository (const unsigned char *sha1)
I'm looking at your branch and this function (with the _the_repository suffix) is still there. Did you forget to send a patch to convert this function?
Quoted 3 lines
object.c +0
-0{struct object *obj =lookup_object (the_repository, sha1);if (!obj)
Signature · 1 line
Duy
Re: [PATCH 03/35] object: add repository argument to lookup_unknown_object
Quoted 10 lines · Duy Nguyen
Quoted 8 lines · Stefan Beller
object.c +0
-0@@ -177,7 +177,7 @@ void *object_as_type(struct object *obj, enum object_type type, int quiet) } }
Quoted 6 lines
object.c void *object_as_type(struct object *obj, enum object_type type, int quiet) · line 180
Quoted 2 lines
object.c +1
-1-struct object *lookup_unknown_object (const unsigned char *sha1) +struct object *lookup_unknown_object_the_repository (const unsigned char *sha1)I'm looking at your branch and this function (with the
_the_repositorysuffix) is still there. Did you forget to send a patch to convert this function?
This and parse_commit and parse_commit_gently have not been converted.
I stopped with this series as soon as I hit the commit-graph code, which needs to be updated, too. I'll start redoing this series soon and will fix those conversions.
Re: [PATCH 03/35] object: add repository argument to lookup_unknown_object
Quoted 15 lines · Stefan Beller
Quoted 9 lines · Duy Nguyen
Quoted 8 lines · Stefan Beller
object.c +0
-0@@ -177,7 +177,7 @@ void *object_as_type(struct object *obj, enum object_type type, int quiet) } }Quoted 5 lines
object.c void *object_as_type(struct object *obj, enum object_type type, int quiet) · line 180
Quoted 2 lines
object.c +1
-1-struct object *lookup_unknown_object (const unsigned char *sha1) +struct object *lookup_unknown_object_the_repository (const unsigned char *sha1)I'm looking at your branch and this function (with the
_the_repositorysuffix) is still there. Did you forget to send a patch to convert this function?
Quoted 5 lines
This and
parse_commitandparse_commit_gentlyhave not been converted.I stopped with this series as soon as I hit the commit-graph code, which needs to be updated, too. I'll start redoing this series soon and will fix those conversions.
Yes, we are colliding a bit at the moment.
I'm planning to delay rerolling my patches until your last few series get merged.
Thanks,
-Stolee
PATCH 4/35 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.
Add the cocci patch that converted the callers.
--- builtin/fast-export.c | 3 ++- builtin/fsck.c | 6 ++++-- builtin/index-pack.c | 3 ++- builtin/unpack-objects.c | 3 ++- object.c | 5 +++-- object.h | 3 ++- ref-filter.c | 3 ++- 7 files changed, 17 insertions(+), 9 deletions(-)
builtin/fast-export.c +2 -1
@@ -245,7 +245,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 +4 -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));
@@ -522,7 +523,8 @@ static struct object *parse_loose_object(const struct object_id *oid,if (!contents && type !=OBJ_BLOB )die ("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 (!eaten)free (contents);
builtin/index-pack.c +2 -1
@@ -848,7 +848,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_the_repository(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
@@ -136,7 +136,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. **/ #define lookup_unknown_object (r, s) lookup_unknown_object_##r(s)
ref-filter.c +2 -1
@@ -806,7 +806,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.17.0.582.gccdcbd54c44.dirty
Re: [PATCH 04/35] object: add repository argument to parse_object_buffer
Quoted 9 lines · Stefan Beller
Add a repository argument to allow the callers of
parse_object_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.Add the cocci patch that converted the callers.
Again, I'm missing the cocci patch here.
Quoted 129 lines
Signed-off-by Jonathan Nieder <[email protected]>Signed-off-by Stefan Beller <[email protected]>--- builtin/fast-export.c | 3 ++- builtin/fsck.c | 6 ++++-- builtin/index-pack.c | 3 ++- builtin/unpack-objects.c | 3 ++- object.c | 5 +++-- object.h | 3 ++- ref-filter.c | 3 ++- 7 files changed, 17 insertions(+), 9 deletions(-)builtin/fast-export.c +2
-1@@ -245,7 +245,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 +4
-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));@@ -522,7 +523,8 @@ static struct object *parse_loose_object(const struct object_id *oid,if (!contents && type !=OBJ_BLOB )die ("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 (!eaten)free (contents);builtin/index-pack.c +2
-1@@ -848,7 +848,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_the_repository(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@@ -136,7 +136,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. **/ #define lookup_unknown_object (r, s) lookup_unknown_object_##r(s)ref-filter.c +2
-1@@ -806,7 +806,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;
PATCH 5/35 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
@@ -31,7 +31,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)
@@ -57,7 +57,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
@@ -115,7 +115,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.17.0.582.gccdcbd54c44.dirty
PATCH 6/35 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.
Add the cocci patch that converted the callers.
--- 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 | 2 +- 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, 22 insertions(+), 17 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
@@ -237,7 +237,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
@@ -808,7 +808,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 +1 -1
@@ -367,7 +367,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);
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
@@ -69,7 +69,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 */
@@ -1338,7 +1338,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.17.0.582.gccdcbd54c44.dirty
Re: [PATCH 06/35] blob: add repository argument to lookup_blob
Quoted 9 lines · Stefan Beller
Add a repository argument to allow the callers of
lookup_blobto 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.Add the cocci patch that converted the callers.
(this is the last time I'll point this out. I'll wait until I read to the end to see if the coccinelle patch is included in the series.)
Quoted 246 lines
Signed-off-by Jonathan Nieder <[email protected]>Signed-off-by Stefan Beller <[email protected]>--- 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 | 2 +- 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, 22 insertions(+), 17 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@@ -237,7 +237,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@@ -808,7 +808,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 +1
-1@@ -367,7 +367,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);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@@ -69,7 +69,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 */ @@ -1338,7 +1338,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; }
PATCH 7/35 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.
Add the cocci patch that converted the callers.
--- 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
@@ -379,7 +379,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
@@ -261,7 +261,7 @@ static int fill_commit_in_graph(struct commit *item, struct commit_graph *g, uin item->graph_pos = pos;hashcpy (oid.hash, commit_data); - item->tree =lookup_tree (&oid); + item->tree =lookup_tree (the_repository, &oid); date_high =get_be32 (commit_data + g->hash_len +8 ) &0x3 ; date_low =get_be32 (commit_data + g->hash_len +12 );
commit.c +1 -1
@@ -354,7 +354,7 @@ int parse_commit_buffer(struct commit *item, const void *buffer, unsigned long sif (get_sha1_hex (bufptr +5 , parent.hash) <0 )return error ("bad tree pointer in commit %s" ,oid_to_hex (&item->object.oid)); - item->tree =lookup_tree (&parent); + item->tree =lookup_tree (the_repository, &parent); bufptr += tree_entry_len +1 ;/* "tree " + "hex sha1" + "\n" */ pptr = &item->parents;
fsck.c +1 -1
@@ -360,7 +360,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
@@ -96,7 +96,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)
@@ -335,7 +335,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; }
@@ -2123,7 +2123,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
@@ -66,7 +66,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));
@@ -1312,7 +1312,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
@@ -397,7 +397,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.17.0.582.gccdcbd54c44.dirty
Re: [PATCH 07/35] tree: add repository argument to lookup_tree
Quoted 9 lines · Stefan Beller
Add a repository argument to allow the callers of
lookup_treeto 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.Add the cocci patch that converted the callers.
I don't see the cocci patch in diffstat. I don't need to see it, but this sentence probably should be dropped.
Quoted 24 lines
Signed-off-by Jonathan Nieder <[email protected]>Signed-off-by Stefan Beller <[email protected]>--- 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(-)
Signature · 1 line
Duy
PATCH 8/35 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;
@@ -823,7 +823,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 ;
@@ -997,7 +997,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
@@ -690,8 +690,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;
@@ -824,7 +826,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
@@ -622,7 +622,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
@@ -23,8 +23,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 );
@@ -36,7 +36,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
@@ -55,7 +55,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
@@ -2010,7 +2010,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... */
@@ -2367,7 +2368,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
@@ -1337,7 +1337,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 ;
@@ -1399,7 +1399,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 */
@@ -1627,8 +1628,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
@@ -2886,7 +2886,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
@@ -1217,13 +1217,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
@@ -489,7 +489,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;
@@ -551,7 +552,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 ;
@@ -661,7 +663,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
@@ -1481,7 +1481,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.17.0.582.gccdcbd54c44.dirty
PATCH 9/35 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/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 +++- notes-merge.c | 5 +++-- parse-options-cb.c | 2 +- remote.c | 4 ++-- revision.c | 4 ++-- sequencer.c | 6 +++--- sha1-name.c | 4 ++-- submodule.c | 10 +++++----- 25 files changed, 63 insertions(+), 49 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
@@ -301,7 +301,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
@@ -126,7 +126,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;
@@ -159,7 +160,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 ;
@@ -213,7 +214,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
@@ -695,7 +695,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
@@ -760,10 +760,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);
@@ -937,9 +940,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/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); exclude =get_merge_bases (a, b);while (exclude) {struct commit *commit =pop_commit (&exclude);
@@ -333,7 +333,7 @@ static int try_parent_shorthands(const char *arg)return 0 ; } - commit =lookup_commit_reference (&oid); + commit =lookup_commit_reference (the_repository, &oid);if (exclude_parent && exclude_parent >commit_list_count (commit->parents)) { *dotdot ='^' ;
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
@@ -34,14 +34,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)) {
@@ -67,7 +67,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
@@ -54,7 +54,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(
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
@@ -2058,13 +2058,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
@@ -1581,8 +1581,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
@@ -1047,7 +1047,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)) {
@@ -1370,7 +1370,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" ));
@@ -1824,7 +1824,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
@@ -810,7 +810,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) {
@@ -838,7 +838,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 +5 -5
@@ -516,8 +516,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
@@ -1800,9 +1800,9 @@ int merge_submodule(struct object_id *result, const char *path,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))) {MERGE_WARNING (path,"commits not present" );return 0 ; }
Signature · 1 line
2.17.0.582.gccdcbd54c44.dirty
PATCH 10/35 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
@@ -964,7 +964,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
@@ -241,7 +241,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;
@@ -527,7 +527,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 ; }
@@ -538,14 +538,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 ;
@@ -658,7 +658,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
@@ -51,7 +51,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)
@@ -373,7 +373,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; }
@@ -381,7 +381,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
@@ -53,7 +53,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
@@ -1256,7 +1257,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
@@ -147,7 +147,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))return NULL ;
sequencer.c +2 -2
@@ -543,7 +543,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
@@ -972,7 +972,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
@@ -352,7 +352,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 ;
@@ -256,7 +256,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",
@@ -621,7 +621,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 ; }
@@ -632,7 +633,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);
@@ -702,7 +704,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 ;
@@ -723,7 +725,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 ;
@@ -745,7 +747,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.17.0.582.gccdcbd54c44.dirty
Re: [PATCH 10/35] commit: add repository argument to lookup_commit
shallow.c int register_shallow(struct repository *r, const struct object_id *oid) · line 34
Quoted 10 lines · Stefan Beller
shallow.c +1
-1@@ -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);
This looks wrong. register_shallow() has struct repository argument 'r' and it should be used here instead.
If this is a mechanical conversion, I will also be happy that the switch from the_repo to r is done in a separate patch.
FYI I noticed this because I'm in a quest to kill the_index by passing 'struct index_state *' throughout library code, and sometimes I pass 'struct repository *' instead when I see that code uses more things that just the index. And I have started to replace the_repository in some places with a function argument.
If some of my patches come first while you have not finished repository conversion (very likely), you and I will have to pay attention to this more often.
Signature · 1 line
Duy
Re: [PATCH 10/35] commit: add repository argument to lookup_commit
Quoted 15 lines · Duy Nguyen
shallow.c int register_shallow(struct repository *r, const struct object_id *oid) · line 34
Quoted 10 lines · Stefan Beller
shallow.c +1
-1@@ -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);This looks wrong.
register_shallow()has struct repository argument 'r' and it should be used here instead.
Right.
Quoted 2 lines
If this is a mechanical conversion, I will also be happy that the switch from
the_repoto r is done in a separate patch.
This part of the code is not touched later in this series, so I'll fix it if a reroll is needed.
Quoted 9 lines
FYI I noticed this because I'm in a quest to kill
the_indexby passing 'structindex_state*' throughout library code, and sometimes I pass 'struct repository *' instead when I see that code uses more things that just the index. And I have started to replacethe_repositoryin some places with a function argument.If some of my patches come first while you have not finished repository conversion (very likely), you and I will have to pay attention to this more often.
Re: [PATCH 10/35] commit: add repository argument to lookup_commit
Quoted 17 lines · Stefan Beller
Quoted 15 lines · Duy Nguyen
shallow.c int register_shallow(struct repository *r, const struct object_id *oid) · line 34
Quoted 10 lines · Stefan Beller
shallow.c +1
-1@@ -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);This looks wrong.
register_shallow()has struct repository argument 'r' and it should be used here instead.
Quoted 7 lines
Right.
Quoted 2 lines
If this is a mechanical conversion, I will also be happy that the switch from
the_repoto r is done in a separate patch.This part of the code is not touched later in this series, so I'll fix it if a reroll is needed.
Yeah maybe at some point when lookup_commit can understand arbitrary repositories we can change this from the_repository to r. This patch is part of that mechanical change and has to be the_repository till lookup_commit has been fully converted.
Quoted 10 lines
Quoted 10 lines
FYI I noticed this because I'm in a quest to kill
the_indexby passing 'structindex_state*' throughout library code, and sometimes I pass 'struct repository *' instead when I see that code uses more things that just the index. And I have started to replacethe_repositoryin some places with a function argument.If some of my patches come first while you have not finished repository conversion (very likely), you and I will have to pay attention to this more often.
Signature · 1 line
Brandon Williams
PATCH 11/35 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
@@ -334,7 +334,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 parse_commit_buffer_the_repository (struct commit *item,const void *buffer,unsigned long size) {const char *tail = buffer;const char *bufptr = buffer;
@@ -416,7 +416,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); + ret =parse_commit_buffer (the_repository, item, buffer, size);if (save_commit_buffer && !ret) {set_commit_buffer (item, buffer, size);return 0 ;
commit.h +2 -1
@@ -72,7 +72,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); +#define parse_commit_buffer (r, i, b, s) parse_commit_buffer_##r(i, b, s) +int parse_commit_buffer_the_repository (struct commit *item,const void *buffer,unsigned long size);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)) +if (parse_commit_buffer (the_repository, commit, buffer, size))return NULL ;if (!get_cached_commit_buffer (commit,NULL )) {set_commit_buffer (commit, buffer, size);
sha1-file.c +1 -1
@@ -1780,7 +1780,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)) +if (parse_commit_buffer (the_repository, &c, buf, size))die ("corrupt commit" ); }
Signature · 1 line
2.17.0.582.gccdcbd54c44.dirty
PATCH 12/35 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.
The included coccinelle semantic patch will adapt any new callers in the diff produced by make coccicheck.
--- 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
@@ -249,7 +249,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;
@@ -418,7 +418,7 @@ int parse_commit_gently(struct commit *item, int quiet_on_missing) } ret =parse_commit_buffer (the_repository, item, buffer, size);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
@@ -85,7 +85,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))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.17.0.582.gccdcbd54c44.dirty
PATCH 13/35 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
@@ -256,7 +256,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) {
@@ -271,7 +271,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
@@ -92,7 +92,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))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.17.0.582.gccdcbd54c44.dirty
PATCH 14/35 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
@@ -2365,7 +2365,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
@@ -359,7 +359,7 @@ static void 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)die (_ ("bad mergetag in commit '%s'" ), ref);if (parse_tag_buffer (tag, extra->value, extra->len))
log-tree.c +1 -1
@@ -506,7 +506,7 @@ static void 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 ;/* 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
@@ -359,7 +359,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.17.0.582.gccdcbd54c44.dirty
PATCH 15/35 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
@@ -362,7 +362,7 @@ static void check_one_mergetag(struct commit *commit, tag =lookup_tag (the_repository, &tag_oid);if (!tag)die (_ ("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))die (_ ("malformed mergetag in commit '%s'" ), ref);/* iterate over new parents */
log-tree.c +1 -1
@@ -511,7 +511,7 @@ static void show_one_mergetag(struct commit *commit,return ;/* 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
@@ -1788,7 +1788,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.17.0.582.gccdcbd54c44.dirty
PATCH 16/35 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.
Add the cocci patch that converted the callers.
--- 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
@@ -395,7 +395,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
@@ -646,7 +646,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
@@ -26,7 +26,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
@@ -2184,7 +2184,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
@@ -1995,12 +1995,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 ;
@@ -934,7 +936,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);
@@ -1066,7 +1068,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.17.0.582.gccdcbd54c44.dirty
PATCH 17/35 object: add repository argument to parse_commit_gently
In reply to Stefan BellerAdd a repository argument to allow callers of parse_commit_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.
The included coccinelle semantic patch will adapt any new callers in the diff produced by make coccicheck.
--- commit.c | 2 +- commit.h | 5 +++-- revision.c | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-)
commit.c +1 -1
@@ -394,7 +394,7 @@ int parse_commit_buffer_the_repository(struct commit *item, const void *buffer,return 0 ; } -int parse_commit_gently (struct commit *item,int quiet_on_missing) +int parse_commit_gently_the_repository (struct commit *item,int quiet_on_missing) {enum object_type type;void *buffer;
commit.h +3 -2
@@ -74,10 +74,11 @@ struct commit *lookup_commit_or_die(const struct object_id *oid, const char *ref#define parse_commit_buffer (r, i, b, s) parse_commit_buffer_##r(i, b, s)int parse_commit_buffer_the_repository (struct commit *item,const void *buffer,unsigned long size); -int parse_commit_gently (struct commit *item,int quiet_on_missing); +#define parse_commit_gently (r, i, q) parse_commit_gently_##r(i, q) +int parse_commit_gently_the_repository (struct commit *item,int quiet_on_missing);static inline int parse_commit (struct commit *item) { -return parse_commit_gently (item,0 ); +return parse_commit_gently (the_repository, item,0 ); }void parse_commit_or_die (struct commit *item);
revision.c +2 -2
@@ -785,7 +785,7 @@ static int add_parents_to_list(struct rev_info *revs, struct commit *commit, parent = parent->next;if (p) p->object.flags |=UNINTERESTING ; -if (parse_commit_gently (p,1 ) <0 ) +if (parse_commit_gently (the_repository, p,1 ) <0 )continue ;if (p->parents)mark_parents_uninteresting (p);
@@ -813,7 +813,7 @@ static int add_parents_to_list(struct rev_info *revs, struct commit *commit,struct commit *p = parent->item;int gently = revs->ignore_missing_links || revs->exclude_promisor_objects; -if (parse_commit_gently (p, gently) <0 ) { +if (parse_commit_gently (the_repository, p, gently) <0 ) {if (revs->exclude_promisor_objects &&is_promisor_object (&p->object.oid)) {if (revs->first_parent_only)
Signature · 1 line
2.17.0.582.gccdcbd54c44.dirty
PATCH 18/35 commit: add repository argument to parse_commit
In reply to Stefan BellerAdd a repository argument to allow callers of parse_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.
--- blame.c | 4 ++-- builtin/checkout.c | 4 ++-- builtin/commit.c | 2 +- builtin/describe.c | 4 ++-- builtin/merge-base.c | 2 +- builtin/name-rev.c | 2 +- builtin/notes.c | 2 +- builtin/reflog.c | 2 +- builtin/show-branch.c | 4 ++-- commit-graph.c | 6 +++--- commit.c | 18 +++++++++--------- commit.h | 3 ++- fetch-pack.c | 6 +++--- fsck.c | 2 +- merge-recursive.c | 4 ++-- notes-utils.c | 2 +- remote.c | 2 +- revision.c | 7 +++---- sequencer.c | 16 ++++++++-------- sha1-name.c | 4 ++-- shallow.c | 4 ++-- tree.c | 2 +- walker.c | 2 +- 23 files changed, 52 insertions(+), 52 deletions(-)
blame.c +2 -2
@@ -1451,7 +1451,7 @@ static void pass_blame(struct blame_scoreboard *sb, struct blame_origin *origin,if (sg_origin[i])continue ; -if (parse_commit (p)) +if (parse_commit (the_repository, p))continue ; porigin =find (p, origin);if (!porigin)
@@ -1590,7 +1590,7 @@ void assign_blame(struct blame_scoreboard *sb, int opt)* so hold onto it in the meantime. */ blame_origin_incref (suspect); -parse_commit (commit); +parse_commit (the_repository, commit);if (sb->reverse || (!(commit->object.flags &UNINTERESTING ) && !(revs->max_age !=-1 && commit->date < revs->max_age)))
builtin/checkout.c +2 -2
@@ -402,7 +402,7 @@ static void describe_detached_head(const char *msg, struct commit *commit) {struct strbuf sb =STRBUF_INIT ; -if (!parse_commit (commit)) +if (!parse_commit (the_repository, commit))pp_commit_easy (CMIT_FMT_ONELINE , commit, &sb);if (print_sha1_ellipsis ()) { fprintf(stderr, "%s %s... %s\n", msg,
@@ -723,7 +723,7 @@ static void describe_one_orphan(struct strbuf *sb, struct commit *commit)strbuf_addstr (sb," " );strbuf_add_unique_abbrev (sb, &commit->object.oid,DEFAULT_ABBREV );strbuf_addch (sb,' ' ); -if (!parse_commit (commit)) +if (!parse_commit (the_repository, commit))pp_commit_easy (CMIT_FMT_ONELINE , commit, sb);strbuf_addch (sb,'\n' ); }
builtin/commit.c +1 -1
@@ -1482,7 +1482,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix) current_head =NULL ; else { current_head =lookup_commit_or_die (&oid,"HEAD" ); -if (parse_commit (current_head)) +if (parse_commit (the_repository, current_head))die (_ ("could not parse HEAD commit" )); } verbose =-1 ;/* unspecified */
builtin/describe.c +2 -2
@@ -254,7 +254,7 @@ static unsigned long finish_depth_computation( best->depth++;while (parents) {struct commit *p = parents->item; -parse_commit (p); +parse_commit (the_repository, p);if (!(p->object.flags &SEEN ))commit_list_insert_by_date (p, list); p->object.flags |= c->object.flags;
@@ -381,7 +381,7 @@ static void describe_commit(struct object_id *oid, struct strbuf *dst) }while (parents) {struct commit *p = parents->item; -parse_commit (p); +parse_commit (the_repository, p);if (!(p->object.flags &SEEN ))commit_list_insert_by_date (p, &list); p->object.flags |= c->object.flags;
builtin/merge-base.c +1 -1
@@ -127,7 +127,7 @@ static void add_one_commit(struct object_id *oid, struct rev_collect *revs) commit =lookup_commit (the_repository, oid);if (!commit || (commit->object.flags &TMP_MARK ) || -parse_commit (commit)) +parse_commit (the_repository, commit))return ;ALLOC_GROW (revs->commit, revs->nr +1 , revs->alloc);
builtin/name-rev.c +1 -1
@@ -87,7 +87,7 @@ static void name_rev(struct commit *commit,int parent_number =1 ;char *to_free =NULL ; -parse_commit (commit); +parse_commit (the_repository, commit);if (commit->date < cutoff)return ;
builtin/notes.c +1 -1
@@ -714,7 +714,7 @@ static int merge_commit(struct notes_merge_options *o)die (_ ("failed to read ref NOTES_MERGE_PARTIAL" )); else if (!(partial = lookup_commit_reference(the_repository, &oid)))die (_ ("could not find commit from NOTES_MERGE_PARTIAL." )); - else if (parse_commit(partial)) + else if (parse_commit(the_repository, partial)) die(_("could not parse commit from NOTES_MERGE_PARTIAL."));if (partial->parents)
builtin/reflog.c +1 -1
@@ -235,7 +235,7 @@ static void mark_reachable(struct expire_reflog_policy_cb *cb)struct commit *commit =pop_commit (&pending);if (commit->object.flags &REACHABLE )continue ; -if (parse_commit (commit)) +if (parse_commit (the_repository, commit))continue ; commit->object.flags |=REACHABLE ;if (commit->date < expire_limit) {
builtin/show-branch.c +2 -2
@@ -238,7 +238,7 @@ static void join_revs(struct commit_list **list_p, parents = parents->next;if ((this_flag & flags) == flags)continue ; -parse_commit (p); +parse_commit (the_repository, p);if (mark_seen (p, seen_p) && !still_interesting) extra--; p->object.flags |= flags;
@@ -835,7 +835,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)if (!commit)die (_ ("cannot find commit %s (%s)" ), ref_name[num_rev],oid_to_hex (&revkey)); -parse_commit (commit); +parse_commit (the_repository, commit);mark_seen (commit, &seen);/* rev#0 uses bit REV_SHIFT, rev#1 uses bit REV_SHIFT+1,
commit-graph.c +3 -3
@@ -371,7 +371,7 @@ static void write_graph_chunk_data(struct hashfile *f, int hash_len,int edge_value;uint32_t packedDate[2 ]; -parse_commit (*list); +parse_commit (the_repository, *list);hashwrite (f, (*list)->tree->object.oid.hash, hash_len); parent = (*list)->parents;
@@ -540,7 +540,7 @@ static void close_reachable(struct packed_oid_list *oids)for (i =0 ; i < oids->nr; i++) { commit =lookup_commit (the_repository, &oids->list[i]); -if (commit && !parse_commit (commit)) +if (commit && !parse_commit (the_repository, commit))add_missing_parents (oids, commit); }
@@ -659,7 +659,7 @@ void write_commit_graph(const char *obj_dir,continue ; commits.list[commits.nr] =lookup_commit (the_repository, &oids.list[i]); -parse_commit (commits.list[commits.nr]); +parse_commit (the_repository, commits.list[commits.nr]);for (parent = commits.list[commits.nr]->parents; parent; parent = parent->next)
commit.c +9 -9
@@ -69,7 +69,7 @@ struct commit *lookup_commit_reference_by_name(const char *name)if (get_oid_committish (name, &oid))return NULL ; commit =lookup_commit_reference (the_repository, &oid); -if (parse_commit (commit)) +if (parse_commit (the_repository, commit))return NULL ;return commit; }
@@ -428,7 +428,7 @@ int parse_commit_gently_the_repository(struct commit *item, int quiet_on_missingvoid parse_commit_or_die (struct commit *item) { -if (parse_commit (item)) +if (parse_commit (the_repository, item))die ("unable to parse commit %s" , item ?oid_to_hex (&item->object.oid) :"(null)" ); }
@@ -533,7 +533,7 @@ struct commit *pop_most_recent_commit(struct commit_list **list,while (parents) {struct commit *commit = parents->item; -if (!parse_commit (commit) && !(commit->object.flags & mark)) { +if (!parse_commit (the_repository, commit) && !(commit->object.flags & mark)) { commit->object.flags |= mark;commit_list_insert_by_date (commit, list); }
@@ -830,7 +830,7 @@ static struct commit_list *paint_down_to_common(struct commit *one, int n, struc parents = parents->next;if ((p->object.flags & flags) == flags)continue ; -if (parse_commit (p)) +if (parse_commit (the_repository, p))return NULL ; p->object.flags |= flags;prio_queue_put (&queue, p);
@@ -856,10 +856,10 @@ static struct commit_list *merge_bases_many(struct commit *one, int n, struct coreturn commit_list_insert (one, &result); } -if (parse_commit (one)) +if (parse_commit (the_repository, one))return NULL ;for (i =0 ; i < n; i++) { -if (parse_commit (twos[i])) +if (parse_commit (the_repository, twos[i]))return NULL ; }
@@ -918,7 +918,7 @@ static int remove_redundant(struct commit **array, int cnt)ALLOC_ARRAY (filled_index, cnt -1 );for (i =0 ; i < cnt; i++) -parse_commit (array[i]); +parse_commit (the_repository, array[i]);for (i =0 ; i < cnt; i++) {struct commit_list *common;
@@ -1041,10 +1041,10 @@ int in_merge_bases_many(struct commit *commit, int nr_reference, struct commit *struct commit_list *bases;int ret =0 , i; -if (parse_commit (commit)) +if (parse_commit (the_repository, commit))return ret;for (i =0 ; i < nr_reference; i++) -if (parse_commit (reference[i])) +if (parse_commit (the_repository, reference[i]))return ret; bases =paint_down_to_common (commit, nr_reference, reference);
commit.h +2 -1
@@ -76,7 +76,8 @@ struct commit *lookup_commit_or_die(const struct object_id *oid, const char *refint parse_commit_buffer_the_repository (struct commit *item,const void *buffer,unsigned long size);#define parse_commit_gently (r, i, q) parse_commit_gently_##r(i, q)int parse_commit_gently_the_repository (struct commit *item,int quiet_on_missing); -static inline int parse_commit (struct commit *item) +#define parse_commit (r, i) parse_commit_##r(i) +static inline int parse_commit_the_repository (struct commit *item) {return parse_commit_gently (the_repository, item,0 ); }
fetch-pack.c +3 -3
@@ -114,7 +114,7 @@ static void rev_list_push(struct commit *commit, int mark)if (!(commit->object.flags & mark)) { commit->object.flags |= mark; -if (parse_commit (commit)) +if (parse_commit (the_repository, commit))return ;prio_queue_put (&rev_list, commit);
@@ -178,7 +178,7 @@ static void mark_common(struct commit *commit,if (!ancestors_only && !(o->flags &POPPED )) non_common_revs--;if (!o->parsed && !dont_parse) -if (parse_commit (commit)) +if (parse_commit (the_repository, commit))return ; for (parents = commit->parents;
@@ -205,7 +205,7 @@ static const struct object_id *get_rev(void)return NULL ; commit =prio_queue_get (&rev_list); -parse_commit (commit); +parse_commit (the_repository, commit); parents = commit->parents; commit->object.flags |=POPPED ;
fsck.c +1 -1
@@ -393,7 +393,7 @@ static int fsck_walk_commit(struct commit *commit, void *data, struct fsck_optioint result;const char *name; -if (parse_commit (commit)) +if (parse_commit (the_repository, commit))return -1 ; name =get_object_name (options, &commit->object);
merge-recursive.c +2 -2
@@ -236,7 +236,7 @@ static void output_commit_title(struct merge_options *o, struct commit *commit)strbuf_add_unique_abbrev (&o->obuf, &commit->object.oid,DEFAULT_ABBREV );strbuf_addch (&o->obuf,' ' ); -if (parse_commit (commit) !=0 ) +if (parse_commit (the_repository, commit) !=0 )strbuf_addstr (&o->obuf,_ ("(bad commit)\n" ));else {const char *title;
@@ -2193,7 +2193,7 @@ static struct commit *get_ref(const struct object_id *oid, const char *name)return make_virtual_commit ((struct tree *)object, name);if (object->type !=OBJ_COMMIT )return NULL ; -if (parse_commit ((struct commit *)object)) +if (parse_commit (the_repository, (struct commit *)object))return NULL ;return (struct commit *)object; }
notes-utils.c +1 -1
@@ -22,7 +22,7 @@ void create_notes_commit(struct notes_tree *t, struct commit_list *parents,if (!read_ref (t->ref, &parent_oid)) {struct commit *parent =lookup_commit (the_repository, &parent_oid); -if (parse_commit (parent)) +if (parse_commit (the_repository, parent))die ("Failed to find/parse commit %s" , t->ref);commit_list_insert (parent, &parents); }
remote.c +1 -1
@@ -2007,7 +2007,7 @@ int ref_newer(const struct object_id *new_oid, const struct object_id *old_oid)return 0 ; new_commit = (struct commit *) o; -if (parse_commit (new_commit) <0 ) +if (parse_commit (the_repository, new_commit) <0 )return 0 ; used = list =NULL ;
revision.c +3 -4
@@ -258,8 +258,7 @@ static struct commit *handle_commit(struct rev_info *revs,*/ if (object->type ==OBJ_COMMIT ) {struct commit *commit = (struct commit *)object; - -if (parse_commit (commit) <0 ) +if (parse_commit (the_repository, commit) <0 )die ("unable to parse commit %s" , name);if (flags &UNINTERESTING ) {mark_parents_uninteresting (commit);
@@ -673,7 +672,7 @@ static void try_to_simplify_commit(struct rev_info *revs, struct commit *commit) ts->treesame[0 ] =1 ; } } -if (parse_commit (p) <0 ) +if (parse_commit (the_repository, p) <0 )die ("cannot simplify commit %s (because of %s)" ,oid_to_hex (&commit->object.oid),oid_to_hex (&p->object.oid));
@@ -706,7 +705,7 @@ static void try_to_simplify_commit(struct rev_info *revs, struct commit *commit)* IOW, we pretend this parent is a * "root" commit. */ -if (parse_commit (p) <0 ) +if (parse_commit (the_repository, p) <0 )die ("cannot simplify commit %s (invalid %s)" ,oid_to_hex (&commit->object.oid),oid_to_hex (&p->object.oid));
sequencer.c +8 -8
@@ -553,7 +553,7 @@ static int is_index_unchanged(void)* the commit is invalid, parse_commit() will complain. So * there is nothing for us to say here. Just return failure. */ -if (parse_commit (head_commit)) +if (parse_commit (the_repository, head_commit))return -1 ;if (!active_cache_tree)
@@ -975,7 +975,7 @@ void print_commit_summary(const char *prefix, const struct object_id *oid, commit =lookup_commit (the_repository, oid);if (!commit)die (_ ("couldn't look up newly created commit" )); -if (parse_commit (commit)) +if (parse_commit (the_repository, commit))die (_ ("could not parse newly created commit" ));strbuf_addstr (&format,"format:%h] %s" );
@@ -1054,7 +1054,7 @@ static int parse_head(struct commit **head)warning (_ ("HEAD %s is not a commit!" ),oid_to_hex (&oid)); } -if (parse_commit (current_head)) +if (parse_commit (the_repository, current_head))return error (_ ("could not parse HEAD commit" )); } *head = current_head;
@@ -1213,12 +1213,12 @@ static int is_original_commit_empty(struct commit *commit) {const struct object_id *ptree_oid; -if (parse_commit (commit)) +if (parse_commit (the_repository, commit))return error (_ ("could not parse commit %s" ),oid_to_hex (&commit->object.oid));if (commit->parents) {struct commit *parent = commit->parents->item; -if (parse_commit (parent)) +if (parse_commit (the_repository, parent))return error (_ ("could not parse parent commit %s" ),oid_to_hex (&parent->object.oid)); ptree_oid = &parent->tree->object.oid;
@@ -1533,7 +1533,7 @@ static int do_pick_commit(enum todo_command command, struct commit *commit, msg_file =NULL ; goto fast_forward_edit; } -if (parent &&parse_commit (parent) <0 ) +if (parent &&parse_commit (the_repository, parent) <0 )/* TRANSLATORS: The first %s will be a "todo" command like "revert" or "pick", the second %s a SHA1. */ return error(_("%s: cannot parse parent commit %s"),
@@ -3301,7 +3301,7 @@ int skip_unnecessary_picks(void)continue ;if (item->command !=TODO_PICK )break ; -if (parse_commit (item->commit)) { +if (parse_commit (the_repository, item->commit)) {todo_list_release (&todo_list);return error (_ ("could not parse commit '%s'" ),oid_to_hex (&item->commit->object.oid));
@@ -3429,7 +3429,7 @@ int rearrange_squash(void) *commit_todo_item_at (&commit_todo, item->commit) = item; -parse_commit (item->commit); +parse_commit (the_repository, item->commit); commit_buffer =get_commit_buffer (item->commit,NULL );find_commit_subject (commit_buffer, &subject);format_subject (&buf, subject," " );
sha1-name.c +2 -2
@@ -813,7 +813,7 @@ static int get_parent(const char *name, int len,if (ret)return ret; commit =lookup_commit_reference (the_repository, &oid); -if (parse_commit (commit)) +if (parse_commit (the_repository, commit))return -1 ;if (!idx) {oidcpy (result, &commit->object.oid);
@@ -845,7 +845,7 @@ static int get_nth_ancestor(const char *name, int len,return -1 ;while (generation--) { -if (parse_commit (commit) || !commit->parents) +if (parse_commit (the_repository, commit) || !commit->parents)return -1 ; commit = commit->parents->item; }
shallow.c +2 -2
@@ -207,7 +207,7 @@ struct commit_list *get_shallow_commits_by_rev_list(int ac, const char **av,struct commit *c = p->item;struct commit_list *parent; -if (parse_commit (c)) +if (parse_commit (the_repository, c))die ("unable to parse commit %s" ,oid_to_hex (&c->object.oid));
@@ -530,7 +530,7 @@ static void paint_down(struct paint_info *info, const struct object_id *oid,if (c->object.flags &BOTTOM )continue ; -if (parse_commit (c)) +if (parse_commit (the_repository, c))die ("unable to parse commit %s" ,oid_to_hex (&c->object.oid));
tree.c +1 -1
@@ -107,7 +107,7 @@ static int read_tree_1(struct tree *tree, struct strbuf *base,oid_to_hex (entry.oid), base->buf, entry.path); -if (parse_commit (commit)) +if (parse_commit (the_repository, commit))die ("Invalid commit %s in submodule path %s%s" ,oid_to_hex (entry.oid), base->buf, entry.path);
walker.c +1 -1
@@ -78,7 +78,7 @@ static int process_commit(struct walker *walker, struct commit *commit) {struct commit_list *parents; -if (parse_commit (commit)) +if (parse_commit (the_repository, commit))return -1 ;while (complete && complete->item->date >= commit->date) {
Signature · 1 line
2.17.0.582.gccdcbd54c44.dirty
PATCH 19/35 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
@@ -115,8 +115,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.17.0.582.gccdcbd54c44.dirty
PATCH 20/35 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
@@ -110,8 +110,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.17.0.582.gccdcbd54c44.dirty
PATCH 21/35 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.17.0.582.gccdcbd54c44.dirty
PATCH 22/35 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.17.0.582.gccdcbd54c44.dirty
PATCH 23/35 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
@@ -52,13 +52,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
@@ -53,8 +53,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.17.0.582.gccdcbd54c44.dirty
PATCH 24/35 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.17.0.582.gccdcbd54c44.dirty
PATCH 25/35 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.17.0.582.gccdcbd54c44.dirty
PATCH 26/35 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
@@ -335,7 +335,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 parse_commit_buffer (struct repository *r,struct commit *item,const void *buffer,unsigned long size) {const char *tail = buffer;const char *bufptr = buffer;
@@ -355,11 +355,11 @@ int parse_commit_buffer_the_repository(struct commit *item, const void *buffer,if (get_sha1_hex (bufptr +5 , parent.hash) <0 )return error ("bad tree pointer in commit %s" ,oid_to_hex (&item->object.oid)); - item->tree =lookup_tree (the_repository, &parent); + item->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;
@@ -374,7 +374,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; }
@@ -382,7 +382,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
@@ -71,8 +71,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) parse_commit_buffer_##r(i, b, s) -int parse_commit_buffer_the_repository (struct commit *item,const void *buffer,unsigned long size); +int parse_commit_buffer (struct repository *r,struct commit *item,const void *buffer,unsigned long size);#define parse_commit_gently (r, i, q) parse_commit_gently_##r(i, q)int parse_commit_gently_the_repository (struct commit *item,int quiet_on_missing);#define parse_commit (r, i) parse_commit_##r(i)
Signature · 1 line
2.17.0.582.gccdcbd54c44.dirty
PATCH 27/35 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.17.0.582.gccdcbd54c44.dirty
Re: [PATCH 27/35] commit-slabs: remove realloc counter outside of slab struct
Quoted 7 lines · Stefan Beller
The 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.
It's worth noting that this patch is different from the other mechanical patches. I do agree that we should remove this unused portion of the slab API. Likely this was built for testing purposes.
CC'ing Junio, who I found introduced this in a84b794ad "commit-slab: introduce a macro to define a slab for new type". Looking at that diff, the realloc portion did not appear to exist in the previous in-degree-specific version of slabs.
Quoted 27 lines
Signed-off-by Stefan Beller <[email protected]>--- 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 ; \
PATCH 28/35 commit.c: migrate the commit buffer to the parsed object store
In reply to Stefan Beller--- commit.c | 29 +++++++++++++++++++++++------ commit.h | 2 ++ object.c | 5 +++++ object.h | 2 ++ 4 files changed, 32 insertions(+), 6 deletions(-)
commit.c +23 -6
@@ -248,18 +248,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 ;
@@ -291,14 +305,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 ;
@@ -318,7 +334,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 +2 -0
@@ -81,6 +81,8 @@ static inline int parse_commit_the_repository(struct commit *item) }void parse_commit_or_die (struct commit *item); +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; }
@@ -538,6 +540,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 +2 -0
@@ -22,6 +22,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.17.0.582.gccdcbd54c44.dirty
Re: [PATCH 28/35] commit.c: migrate the commit buffer to the parsed object store
Quoted 13 lines · Stefan Beller
Signed-off-by Stefan Beller <[email protected]>--- commit.c | 29 +++++++++++++++++++++++------ commit.h | 2 ++ object.c | 5 +++++ object.h | 2 ++ 4 files changed, 32 insertions(+), 6 deletions(-)commit.c +0
-0
commit.c struct commit_buffer { · line 250
Quoted 3 lines
commit.c +0
-0@@ -248,18 +248,32 @@ struct commit_buffer {unsigned long size; }; define_commit_slab(buffer_slab, struct commit_buffer);
struct buffer_slab is defined locally here...
commit.h static inline int parse_commit_the_repository(struct commit *item) · line 84
Quoted 9 lines
commit.h +1
-0@@ -81,6 +81,8 @@ static inline int parse_commit_the_repository(struct commit *item) }void parse_commit_or_die (struct commit *item); +struct buffer_slab *allocate_commit_buffer_slab (void );
So you would need a forward declaration of struct buffer_slab in commit.h before it's referenced here?
object.h struct parsed_object_pool { · line 26
Quoted 10 lines
object.h +2
-0@@ -22,6 +22,8 @@ struct parsed_object_pool {char *alternate_shallow_file;int commit_graft_prepared; + +struct buffer_slab *buffer_slab;
and maybe here as well
Quoted 6 lines
object.h +0
-1};struct parsed_object_pool *parsed_object_pool_new (void ); --2.17.0.582.gccdcbd54c44.dirty
Signature · 1 line
Duy
Re: [PATCH 28/35] commit.c: migrate the commit buffer to the parsed object store
Quoted 4 lines · Duy Nguyen
Quoted 1 line
define_commit_slab(buffer_slab, struct commit_buffer);struct
buffer_slabis defined locally here...
...
Quoted 4 lines
Quoted 1 line
+struct
buffer_slab*allocate_commit_buffer_slab(void);So you would need a forward declaration of struct
buffer_slabincommit.hbefore it's referenced here?
Will do so in a resend; as well as in object.h
PATCH 29/35 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
@@ -262,10 +262,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
@@ -87,8 +87,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.17.0.582.gccdcbd54c44.dirty
PATCH 30/35 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
@@ -270,10 +270,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
@@ -93,8 +93,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.17.0.582.gccdcbd54c44.dirty
PATCH 31/35 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_the_repository(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)) +if (parse_commit_buffer (r, commit, buffer, size))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
@@ -137,8 +137,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. **/ #define lookup_unknown_object (r, s) lookup_unknown_object_##r(s)
Signature · 1 line
2.17.0.582.gccdcbd54c44.dirty
PATCH 32/35 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
@@ -123,8 +123,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.17.0.582.gccdcbd54c44.dirty
PATCH 33/35 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.17.0.582.gccdcbd54c44.dirty
PATCH 34/35 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
@@ -23,16 +23,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
@@ -57,9 +57,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.17.0.582.gccdcbd54c44.dirty
PATCH 35/35 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
@@ -35,9 +35,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
@@ -54,9 +54,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.17.0.582.gccdcbd54c44.dirty
Quoted 6 lines · Stefan Beller
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.candfetch-pack.cintroduce new calls of functions that would want to take a repository struct in the object-store-grafts series)
Quoted 6 lines
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 convertparse_commit, too. But that requires the conversion of the new commit graph. Maybe we need to split this series into 2.
I'll take a look at this series tomorrow. I've been working in ds/commit-graph-fsck to make many of the methods take a 'struct commit_graph *' parameter, which could easily be 'r->commit_graph' for a 'struct the_repository *r' instead of the global 'commit_graph'. Those graph-local methods will make the transformation to be repo-local a lot easier. (There still may be some need to insert a repository, though.)
Since you are working on the commit-slab stuff in this patch, I'll (continue to) delay my patch series on using the commit-slab for generation numbers to avoid collisions with your work.
Thanks,
-Stolee
Quoted 30 lines · Derrick Stolee
Quoted 11 lines · Stefan Beller
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
andfetch-pack.cintroduce new calls of functions that would want to take a repository struct
in the object-store-grafts series)Quoted 9 lines
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 convertparse_commit, too.
But that requires the conversion of the new commit graph. Maybe we need to split this series into 2.I'll take a look at this series tomorrow. I've been working in ds/commit-graph-fsck to make many of the methods take a 'struct
commit_graph*' parameter, which could easily be 'r->commit_graph' for a 'structthe_repository*r' instead of the global 'commit_graph'. Those graph-local methods will make the transformation to be repo-local a lot easier. (There still may be some need to insert a repository, though.)
Quoted 3 lines
Since you are working on the commit-slab stuff in this patch, I'll (continue to) delay my patch series on using the commit-slab for generation numbers to avoid collisions with your work.
This series touches the commit slabs in the last few commits only. I don't think there will be huge conflicts, as all I had to do was move the definition from a global to inside the parsed object store.
Quoted 29 lines · Stefan Beller
Quoted 28 lines · Derrick Stolee
Quoted 10 lines · Stefan Beller
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
andfetch-pack.cintroduce new calls of functions that would want to take a repository struct
in the object-store-grafts series)Quoted 9 lines
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 convertparse_commit, too.
But that requires the conversion of the new commit graph. Maybe we need to split this series into 2.I'll take a look at this series tomorrow. I've been working in ds/commit-graph-fsck to make many of the methods take a 'struct
commit_graph*' parameter, which could easily be 'r->commit_graph' for a 'structthe_repository*r' instead of the global 'commit_graph'. Those graph-local methods will make the transformation to be repo-local a lot easier. (There still may be some need to insert a repository, though.)
Quoted 6 lines
Quoted 3 lines
Since you are working on the commit-slab stuff in this patch, I'll (continue to) delay my patch series on using the commit-slab for generation numbers to avoid collisions with your work.
This series touches the commit slabs in the last few commits only. I don't think there will be huge conflicts, as all I had to do was move the definition from a global to inside the parsed object store.
I went through the whole series and didn't find any issue with the code. The commit messages reference coccinelle scripts that I never saw, so those should be struck from the messages.
If anyone else plans to review, these two commits are worth special attention compared to the others:
[PATCH 27/35] commit-slabs: remove realloc counter outside of slab struct [PATCH 28/35] commit.c: migrate the commit buffer to the parsed object store
I found no issue with them, but they do actually change behavior slightly as opposed to the other commits which have no change other than to relax the dependence on the_repository as a global. I also like the pattern of storing the slabs inside the parsed object structure in the_repository. I'll use a similar pattern when looking into using slabs for generation number.
For Junio: I know this will conflict with ds/commit-graph-fsck (specifically, I add new references to lookup_commit() and manipulate parse_commit_gently()). If this series is ready to be queued quickly, I can rebase my v4 onto these commits as they are placed into 'pu' (and please eject ds/commit-graph-fsck at that time).
Thanks,
-Stolee
Hi Derrick,
Quoted 3 lines
I went through the whole series and didn't find any issue with the code. The commit messages reference coccinelle scripts that I never saw, so those should be struck from the messages.
I fixed this locally. I'll wait for more reviews to resend though.
Quoted 6 lines
If anyone else plans to review, these two commits are worth special attention compared to the others:
[PATCH 27/35] commit-slabs: remove realloc counter outside of slab struct [PATCH 28/35]
commit.c: migrate the commit buffer to the parsed object store
Thanks for pointing these out! patch 27 might even go on top of nd/commit-slab-to-util.
v2 cover object-store: lookup_commit
In reply to Stefan Beller* 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 (31):
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 | 6 ++-- builtin/diff.c | 5 +-- builtin/fast-export.c | 12 ++++--- builtin/fetch.c | 9 +++-- builtin/fmt-merge-msg.c | 5 +-- builtin/fsck.c | 16 +++++---- builtin/grep.c | 3 +- builtin/index-pack.c | 5 +-- builtin/log.c | 7 ++-- builtin/merge-base.c | 7 ++-- builtin/merge-tree.c | 3 +- builtin/name-rev.c | 6 ++-- builtin/notes.c | 3 +- builtin/pack-objects.c | 2 +- builtin/prune.c | 2 +- builtin/pull.c | 15 +++++--- builtin/reflog.c | 12 ++++--- builtin/replace.c | 4 +-- builtin/reset.c | 4 +-- 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 | 5 +-- cache-tree.c | 3 +- commit-graph.c | 14 ++++---- commit-slab-impl.h | 3 -- commit.c | 77 +++++++++++++++++++++++++--------------- commit.h | 18 ++++++---- fast-import.c | 6 ++-- fetch-pack.c | 25 +++++++------ fsck.c | 4 +-- http-backend.c | 2 +- http-push.c | 10 +++--- line-log.c | 2 +- list-objects.c | 4 +-- log-tree.c | 6 ++-- merge-recursive.c | 9 ++--- notes-cache.c | 3 +- notes-merge.c | 5 +-- notes-utils.c | 4 ++- object.c | 59 ++++++++++++++++-------------- object.h | 13 ++++--- parse-options-cb.c | 2 +- pretty.c | 2 +- reachable.c | 8 ++--- ref-filter.c | 9 +++-- refs.c | 2 +- remote.c | 19 +++++----- revision.c | 12 +++---- sequencer.c | 14 ++++---- server-info.c | 2 +- sha1-file.c | 4 +-- sha1-name.c | 23 ++++++------ shallow.c | 30 ++++++++++------ submodule.c | 10 +++--- tag.c | 27 +++++++------- tag.h | 7 ++-- tree.c | 14 ++++---- tree.h | 2 +- upload-pack.c | 4 +-- walker.c | 9 +++-- wt-status.c | 2 +- 76 files changed, 400 insertions(+), 297 deletions(-)
Signature · 1 line
2.18.0.rc1.244.gcf134e6275-goog
PATCH v2 1/31 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
@@ -231,7 +231,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 ;
@@ -403,7 +403,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,
@@ -762,7 +762,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
@@ -53,7 +53,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 ; }
@@ -1295,7 +1296,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
@@ -110,7 +110,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
@@ -568,7 +568,7 @@ static int get_reachable_list(struct object_array *src,if (namebuf[40 ] !='\n' ||get_oid_hex (namebuf, &sha1))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.rc1.244.gcf134e6275-goog
PATCH v2 2/31 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 | 6 ++++-- builtin/index-pack.c | 3 ++- builtin/unpack-objects.c | 3 ++- object.c | 5 +++-- object.h | 3 ++- ref-filter.c | 3 ++- 7 files changed, 17 insertions(+), 9 deletions(-)
builtin/fast-export.c +2 -1
@@ -245,7 +245,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 +4 -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));
@@ -522,7 +523,8 @@ static struct object *parse_loose_object(const struct object_id *oid,if (!contents && type !=OBJ_BLOB )die ("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 (!eaten)free (contents);
builtin/index-pack.c +2 -1
@@ -848,7 +848,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
@@ -136,7 +136,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
@@ -806,7 +806,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.rc1.244.gcf134e6275-goog
PATCH v2 3/31 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
@@ -31,7 +31,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)
@@ -57,7 +57,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
@@ -115,7 +115,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.rc1.244.gcf134e6275-goog
PATCH v2 4/31 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 | 2 +- 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, 22 insertions(+), 17 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
@@ -237,7 +237,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
@@ -808,7 +808,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 +1 -1
@@ -367,7 +367,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);
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
@@ -69,7 +69,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 */
@@ -1338,7 +1338,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.rc1.244.gcf134e6275-goog
PATCH v2 5/31 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
@@ -379,7 +379,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
@@ -261,7 +261,7 @@ static int fill_commit_in_graph(struct commit *item, struct commit_graph *g, uin item->graph_pos = pos;hashcpy (oid.hash, commit_data); - item->tree =lookup_tree (&oid); + item->tree =lookup_tree (the_repository, &oid); date_high =get_be32 (commit_data + g->hash_len +8 ) &0x3 ; date_low =get_be32 (commit_data + g->hash_len +12 );
commit.c +1 -1
@@ -354,7 +354,7 @@ int parse_commit_buffer(struct commit *item, const void *buffer, unsigned long sif (get_sha1_hex (bufptr +5 , parent.hash) <0 )return error ("bad tree pointer in commit %s" ,oid_to_hex (&item->object.oid)); - item->tree =lookup_tree (&parent); + item->tree =lookup_tree (the_repository, &parent); bufptr += tree_entry_len +1 ;/* "tree " + "hex sha1" + "\n" */ pptr = &item->parents;
fsck.c +1 -1
@@ -360,7 +360,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
@@ -96,7 +96,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)
@@ -335,7 +335,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; }
@@ -2123,7 +2123,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
@@ -66,7 +66,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));
@@ -1312,7 +1312,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
@@ -397,7 +397,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.rc1.244.gcf134e6275-goog
Re: [PATCH v2 05/31] tree: add repository argument to lookup_tree
fsck.c
Quoted 28 lines · Stefan Beller
commit-graph.c +1
-1@@ -261,7 +261,7 @@ static int fill_commit_in_graph(struct commit *item, struct commit_graph *g, uin item->graph_pos = pos;hashcpy (oid.hash, commit_data); - item->tree =lookup_tree (&oid); + item->tree =lookup_tree (the_repository, &oid); date_high =get_be32 (commit_data + g->hash_len +8 ) &0x3 ; date_low =get_be32 (commit_data + g->hash_len +12 );commit.c +1
-1@@ -354,7 +354,7 @@ int parse_commit_buffer(struct commit *item, const void *buffer, unsigned long sif (get_sha1_hex (bufptr +5 , parent.hash) <0 )return error ("bad tree pointer in commit %s" ,oid_to_hex (&item->object.oid)); - item->tree =lookup_tree (&parent); + item->tree =lookup_tree (the_repository, &parent); bufptr += tree_entry_len +1 ;/* "tree " + "hex sha1" + "\n" */ pptr = &item->parents;fsck.c +0
-0
I'm a bit late here, but you don't have ds/lazy-load-trees merged in your history, so this will conflict with 'master'. I caught this as I was trying to merge ds/generation-numbers with your branch.
The 'tree' member of 'struct commit' was renamed to 'maybe_tree'.
Thanks,
-Stolee
Re: [PATCH v2 05/31] tree: add repository argument to lookup_tree
Quoted 31 lines · Derrick Stolee
Quoted 19 lines · Stefan Beller
commit-graph.c +1
-1@@ -261,7 +261,7 @@ static int fill_commit_in_graph(struct commit *item, struct commit_graph *g, uin item->graph_pos = pos; hashcpy(oid.hash, commit_data); - item->tree = lookup_tree(&oid); + item->tree = lookup_tree(the_repository, &oid); date_high = get_be32(commit_data + g->hash_len + 8) & 0x3; date_low = get_be32(commit_data + g->hash_len + 12);commit.c +0
-0@@ -354,7 +354,7 @@ int parse_commit_buffer(struct commit *item,const void *buffer, unsigned long s
if (get_sha1_hex(bufptr + 5, parent.hash)< 0)Quoted 8 lines
return
error("bad tree pointer in commit %s", oid_to_hex(&item->object.oid));
-item->tree=lookup_tree(&parent);
+item->tree=lookup_tree(the_repository, &parent); bufptr +=tree_entry_len+ 1; /* "tree " + "hex sha1" + "\n" */ pptr =&item->parents;
diff --gita/fsck.cb/fsck.c
index2d372f2a3f3..b07abb9796c100644I'm a bit late here, but you don't have ds/lazy-load-trees merged in your history, so this will conflict with 'master'. I caught this as I was trying to merge ds/generation-numbers with your branch.
Quoted 1 line
The 'tree' member of 'struct commit' was renamed to '
maybe_tree'.
Resolving the merge was not very simple. I have a working merge available on GitHub [1] as commit 99a899f7c12ef73840dbe79c71acb11034d707dd.
Thanks,
-Stolee
[1] https://github.com/derrickstolee/git/commits/generation-numbers-object-store
Re: [PATCH v2 05/31] tree: add repository argument to lookup_tree
Quoted 4 lines · Derrick Stolee
Quoted 1 line
The 'tree' member of 'struct commit' was renamed to '
maybe_tree'.Resolving the merge was not very simple. I have a working merge available on GitHub [1] as commit
99a899f7c12ef73840dbe79c71acb11034d707dd.
Thanks for pointing this out and resolving the merge. ds/generation-numbers seems to be cooking in next for longer already, so I might just rebase this series on top of that as well.
Thanks for the heads up!
Stefan
PATCH v2 6/31 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;
@@ -823,7 +823,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 ;
@@ -997,7 +997,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
@@ -690,8 +690,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;
@@ -824,7 +826,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
@@ -622,7 +622,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
@@ -23,8 +23,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 );
@@ -36,7 +36,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
@@ -55,7 +55,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
@@ -2010,7 +2010,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... */
@@ -2367,7 +2368,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
@@ -1337,7 +1337,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 ;
@@ -1399,7 +1399,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 */
@@ -1627,8 +1628,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
@@ -2886,7 +2886,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
@@ -1217,13 +1217,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
@@ -489,7 +489,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;
@@ -551,7 +552,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 ;
@@ -661,7 +663,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
@@ -1481,7 +1481,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.rc1.244.gcf134e6275-goog
PATCH v2 7/31 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/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 +++- notes-merge.c | 5 +++-- parse-options-cb.c | 2 +- remote.c | 4 ++-- revision.c | 4 ++-- sequencer.c | 6 +++--- sha1-name.c | 4 ++-- submodule.c | 10 +++++----- 25 files changed, 63 insertions(+), 49 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
@@ -301,7 +301,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
@@ -126,7 +126,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;
@@ -159,7 +160,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 ;
@@ -213,7 +214,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
@@ -695,7 +695,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
@@ -760,10 +760,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);
@@ -937,9 +940,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/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); exclude =get_merge_bases (a, b);while (exclude) {struct commit *commit =pop_commit (&exclude);
@@ -333,7 +333,7 @@ static int try_parent_shorthands(const char *arg)return 0 ; } - commit =lookup_commit_reference (&oid); + commit =lookup_commit_reference (the_repository, &oid);if (exclude_parent && exclude_parent >commit_list_count (commit->parents)) { *dotdot ='^' ;
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
@@ -34,14 +34,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)) {
@@ -67,7 +67,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
@@ -54,7 +54,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(
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
@@ -2058,13 +2058,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
@@ -1581,8 +1581,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
@@ -1047,7 +1047,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)) {
@@ -1370,7 +1370,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" ));
@@ -1824,7 +1824,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
@@ -810,7 +810,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) {
@@ -838,7 +838,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 +5 -5
@@ -516,8 +516,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
@@ -1800,9 +1800,9 @@ int merge_submodule(struct object_id *result, const char *path,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))) {MERGE_WARNING (path,"commits not present" );return 0 ; }
Signature · 1 line
2.18.0.rc1.244.gcf134e6275-goog
PATCH v2 8/31 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
@@ -964,7 +964,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
@@ -241,7 +241,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;
@@ -527,7 +527,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 ; }
@@ -538,14 +538,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 ;
@@ -658,7 +658,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
@@ -51,7 +51,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)
@@ -373,7 +373,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; }
@@ -381,7 +381,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
@@ -53,7 +53,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
@@ -1256,7 +1257,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
@@ -147,7 +147,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))return NULL ;
sequencer.c +2 -2
@@ -543,7 +543,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
@@ -972,7 +972,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
@@ -352,7 +352,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 ;
@@ -256,7 +256,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",
@@ -621,7 +621,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 ; }
@@ -632,7 +633,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);
@@ -702,7 +704,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 ;
@@ -723,7 +725,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 ;
@@ -745,7 +747,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.rc1.244.gcf134e6275-goog
PATCH v2 9/31 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
@@ -334,7 +334,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 parse_commit_buffer_the_repository (struct commit *item,const void *buffer,unsigned long size) {const char *tail = buffer;const char *bufptr = buffer;
@@ -416,7 +416,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); + ret =parse_commit_buffer (the_repository, item, buffer, size);if (save_commit_buffer && !ret) {set_commit_buffer (item, buffer, size);return 0 ;
commit.h +2 -1
@@ -72,7 +72,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); +#define parse_commit_buffer (r, i, b, s) parse_commit_buffer_##r(i, b, s) +int parse_commit_buffer_the_repository (struct commit *item,const void *buffer,unsigned long size);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)) +if (parse_commit_buffer (the_repository, commit, buffer, size))return NULL ;if (!get_cached_commit_buffer (commit,NULL )) {set_commit_buffer (commit, buffer, size);
sha1-file.c +1 -1
@@ -1780,7 +1780,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)) +if (parse_commit_buffer (the_repository, &c, buf, size))die ("corrupt commit" ); }
Signature · 1 line
2.18.0.rc1.244.gcf134e6275-goog
PATCH v2 10/31 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
@@ -249,7 +249,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;
@@ -418,7 +418,7 @@ int parse_commit_gently(struct commit *item, int quiet_on_missing) } ret =parse_commit_buffer (the_repository, item, buffer, size);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
@@ -85,7 +85,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))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.rc1.244.gcf134e6275-goog
PATCH v2 11/31 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
@@ -256,7 +256,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) {
@@ -271,7 +271,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
@@ -92,7 +92,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))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.rc1.244.gcf134e6275-goog
PATCH v2 12/31 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
@@ -2365,7 +2365,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
@@ -359,7 +359,7 @@ static void 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)die (_ ("bad mergetag in commit '%s'" ), ref);if (parse_tag_buffer (tag, extra->value, extra->len))
log-tree.c +1 -1
@@ -506,7 +506,7 @@ static void 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 ;/* 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
@@ -359,7 +359,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.rc1.244.gcf134e6275-goog
PATCH v2 13/31 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
@@ -362,7 +362,7 @@ static void check_one_mergetag(struct commit *commit, tag =lookup_tag (the_repository, &tag_oid);if (!tag)die (_ ("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))die (_ ("malformed mergetag in commit '%s'" ), ref);/* iterate over new parents */
log-tree.c +1 -1
@@ -511,7 +511,7 @@ static void show_one_mergetag(struct commit *commit,return ;/* 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
@@ -1788,7 +1788,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.rc1.244.gcf134e6275-goog
PATCH v2 14/31 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
@@ -395,7 +395,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
@@ -646,7 +646,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
@@ -26,7 +26,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
@@ -2184,7 +2184,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
@@ -1995,12 +1995,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 ;
@@ -934,7 +936,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);
@@ -1066,7 +1068,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.rc1.244.gcf134e6275-goog
PATCH v2 15/31 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
@@ -115,8 +115,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.rc1.244.gcf134e6275-goog
PATCH v2 16/31 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
@@ -110,8 +110,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.rc1.244.gcf134e6275-goog
PATCH v2 17/31 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.rc1.244.gcf134e6275-goog
PATCH v2 18/31 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.rc1.244.gcf134e6275-goog
PATCH v2 19/31 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
@@ -52,13 +52,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
@@ -53,8 +53,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.rc1.244.gcf134e6275-goog
PATCH v2 20/31 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.rc1.244.gcf134e6275-goog
PATCH v2 21/31 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.rc1.244.gcf134e6275-goog
PATCH v2 22/31 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
@@ -335,7 +335,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 parse_commit_buffer (struct repository *r,struct commit *item,const void *buffer,unsigned long size) {const char *tail = buffer;const char *bufptr = buffer;
@@ -355,11 +355,11 @@ int parse_commit_buffer_the_repository(struct commit *item, const void *buffer,if (get_sha1_hex (bufptr +5 , parent.hash) <0 )return error ("bad tree pointer in commit %s" ,oid_to_hex (&item->object.oid)); - item->tree =lookup_tree (the_repository, &parent); + item->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;
@@ -374,7 +374,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; }
@@ -382,7 +382,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
@@ -71,8 +71,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) parse_commit_buffer_##r(i, b, s) -int parse_commit_buffer_the_repository (struct commit *item,const void *buffer,unsigned long size); +int parse_commit_buffer (struct repository *r,struct commit *item,const void *buffer,unsigned long size);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.rc1.244.gcf134e6275-goog
PATCH v2 23/31 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.rc1.244.gcf134e6275-goog
PATCH v2 24/31 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
@@ -248,18 +248,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 ;
@@ -291,14 +305,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 ;
@@ -318,7 +334,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
@@ -79,6 +79,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; }
@@ -538,6 +540,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.rc1.244.gcf134e6275-goog
PATCH v2 25/31 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
@@ -262,10 +262,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
@@ -87,8 +87,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.rc1.244.gcf134e6275-goog
PATCH v2 26/31 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
@@ -270,10 +270,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
@@ -93,8 +93,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.rc1.244.gcf134e6275-goog
PATCH v2 27/31 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)) +if (parse_commit_buffer (r, commit, buffer, size))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
@@ -139,8 +139,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.rc1.244.gcf134e6275-goog
PATCH v2 28/31 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
@@ -125,8 +125,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.rc1.244.gcf134e6275-goog
PATCH v2 29/31 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.rc1.244.gcf134e6275-goog
PATCH v2 30/31 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
@@ -23,16 +23,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
@@ -57,9 +57,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.rc1.244.gcf134e6275-goog
PATCH v2 31/31 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
@@ -35,9 +35,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
@@ -54,9 +54,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.rc1.244.gcf134e6275-goog