configure: Detect linking style for HP aCC on HP-UX
[gitweb.git] / commit.c
index a5333c7ac6c373a13f9298b36be5ff94a90a3e3f..8fa1883c61c580578a755cdf2da009203d8d386e 100644 (file)
--- a/commit.c
+++ b/commit.c
@@ -340,15 +340,21 @@ void free_commit_buffer(struct parsed_object_pool *pool, struct commit *commit)
        }
 }
 
-struct tree *get_commit_tree(const struct commit *commit)
+static inline void set_commit_tree(struct commit *c, struct tree *t)
+{
+       c->maybe_tree = t;
+}
+
+struct tree *repo_get_commit_tree(struct repository *r,
+                                 const struct commit *commit)
 {
        if (commit->maybe_tree || !commit->object.parsed)
                return commit->maybe_tree;
 
-       if (commit->graph_pos == COMMIT_NOT_FROM_GRAPH)
-               BUG("commit has NULL tree, but was not loaded from commit-graph");
+       if (commit->graph_pos != COMMIT_NOT_FROM_GRAPH)
+               return get_commit_tree_in_graph(r, commit);
 
-       return get_commit_tree_in_graph(the_repository, commit);
+       return NULL;
 }
 
 struct object_id *get_commit_tree_oid(const struct commit *commit)
@@ -358,7 +364,7 @@ struct object_id *get_commit_tree_oid(const struct commit *commit)
 
 void release_commit_memory(struct parsed_object_pool *pool, struct commit *c)
 {
-       c->maybe_tree = NULL;
+       set_commit_tree(c, NULL);
        c->index = 0;
        free_commit_buffer(pool, c);
        free_commit_list(c->parents);
@@ -406,7 +412,7 @@ int parse_commit_buffer(struct repository *r, struct commit *item, const void *b
        if (get_oid_hex(bufptr + 5, &parent) < 0)
                return error("bad tree pointer in commit %s",
                             oid_to_hex(&item->object.oid));
-       item->maybe_tree = lookup_tree(r, &parent);
+       set_commit_tree(item, lookup_tree(r, &parent));
        bufptr += tree_entry_len + 1; /* "tree " + "hex sha1" + "\n" */
        pptr = &item->parents;