diff options
Diffstat (limited to 'tree.c')
-rw-r--r-- | tree.c | 24 |
1 files changed, 13 insertions, 11 deletions
@@ -5,12 +5,13 @@ #include "blob.h" #include "commit.h" #include "tag.h" +#include "alloc.h" #include "tree-walk.h" const char *tree_type = "tree"; static int read_one_entry_opt(struct index_state *istate, - const unsigned char *sha1, + const struct object_id *oid, const char *base, int baselen, const char *pathname, unsigned mode, int stage, int opt) @@ -31,16 +32,16 @@ static int read_one_entry_opt(struct index_state *istate, ce->ce_namelen = baselen + len; memcpy(ce->name, base, baselen); memcpy(ce->name + baselen, pathname, len+1); - hashcpy(ce->oid.hash, sha1); + oidcpy(&ce->oid, oid); return add_index_entry(istate, ce, opt); } -static int read_one_entry(const unsigned char *sha1, struct strbuf *base, +static int read_one_entry(const struct object_id *oid, struct strbuf *base, const char *pathname, unsigned mode, int stage, void *context) { struct index_state *istate = context; - return read_one_entry_opt(istate, sha1, base->buf, base->len, pathname, + return read_one_entry_opt(istate, oid, base->buf, base->len, pathname, mode, stage, ADD_CACHE_OK_TO_ADD|ADD_CACHE_SKIP_DFCHECK); } @@ -49,12 +50,12 @@ static int read_one_entry(const unsigned char *sha1, struct strbuf *base, * This is used when the caller knows there is no existing entries at * the stage that will conflict with the entry being added. */ -static int read_one_entry_quick(const unsigned char *sha1, struct strbuf *base, +static int read_one_entry_quick(const struct object_id *oid, struct strbuf *base, const char *pathname, unsigned mode, int stage, void *context) { struct index_state *istate = context; - return read_one_entry_opt(istate, sha1, base->buf, base->len, pathname, + return read_one_entry_opt(istate, oid, base->buf, base->len, pathname, mode, stage, ADD_CACHE_JUST_APPEND); } @@ -83,7 +84,7 @@ static int read_tree_1(struct tree *tree, struct strbuf *base, continue; } - switch (fn(entry.oid->hash, base, + switch (fn(entry.oid, base, entry.path, entry.mode, stage, context)) { case 0: continue; @@ -109,7 +110,7 @@ static int read_tree_1(struct tree *tree, struct strbuf *base, oid_to_hex(entry.oid), base->buf, entry.path); - oidcpy(&oid, &commit->tree->object.oid); + oidcpy(&oid, get_commit_tree_oid(commit)); } else continue; @@ -196,7 +197,8 @@ struct tree *lookup_tree(const struct object_id *oid) { struct object *obj = lookup_object(oid->hash); if (!obj) - return create_object(oid->hash, alloc_tree_node()); + return create_object(the_repository, oid->hash, + alloc_tree_node(the_repository)); return object_as_type(obj, OBJ_TREE, 0); } @@ -219,7 +221,7 @@ int parse_tree_gently(struct tree *item, int quiet_on_missing) if (item->object.parsed) return 0; - buffer = read_sha1_file(item->object.oid.hash, &type, &size); + buffer = read_object_file(&item->object.oid, &type, &size); if (!buffer) return quiet_on_missing ? -1 : error("Could not read %s", @@ -248,7 +250,7 @@ struct tree *parse_tree_indirect(const struct object_id *oid) if (obj->type == OBJ_TREE) return (struct tree *) obj; else if (obj->type == OBJ_COMMIT) - obj = &(((struct commit *) obj)->tree->object); + obj = &(get_commit_tree(((struct commit *)obj))->object); else if (obj->type == OBJ_TAG) obj = ((struct tag *) obj)->tagged; else |