commit: add generation number to struct commit
[gitweb.git] / tree.c
diff --git a/tree.c b/tree.c
index dd69423d9a3c1e1b9dd83df729ede543bfedc90a..dec53f3ecae066aa8f9389fad836a75873df1a7f 100644 (file)
--- a/tree.c
+++ b/tree.c
@@ -109,7 +109,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;
@@ -234,8 +234,7 @@ int parse_tree_gently(struct tree *item, int quiet_on_missing)
 
 void free_tree_buffer(struct tree *tree)
 {
-       free(tree->buffer);
-       tree->buffer = NULL;
+       FREE_AND_NULL(tree->buffer);
        tree->size = 0;
        tree->object.parsed = 0;
 }
@@ -249,7 +248,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