treewide: rename tree to maybe_tree
authorDerrick Stolee <dstolee@microsoft.com>
Fri, 6 Apr 2018 19:09:32 +0000 (19:09 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 11 Apr 2018 01:47:16 +0000 (10:47 +0900)
Using the commit-graph file to walk commit history removes the large
cost of parsing commits during the walk. This exposes a performance
issue: lookup_tree() takes a large portion of the computation time,
even when Git never uses those trees.

In anticipation of lazy-loading these trees, rename the 'tree' member
of struct commit to 'maybe_tree'. This serves two purposes: it hints
at the future role of possibly being NULL even if the commit has a
valid tree, and it allows for unambiguous transformation from simple
member access (i.e. commit->maybe_tree) to method access.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
24 files changed:
blame.c
builtin/checkout.c
builtin/diff.c
builtin/fast-export.c
builtin/log.c
builtin/reflog.c
commit-graph.c
commit.c
commit.h
fsck.c
http-push.c
line-log.c
list-objects.c
log-tree.c
merge-recursive.c
notes-merge.c
packfile.c
pretty.c
ref-filter.c
revision.c
sequencer.c
sha1_name.c
tree.c
walker.c
diff --git a/blame.c b/blame.c
index 200e0ad9a299adb13982cdc27cb6e9a768560f58..b78e649cacf4eb6156d509e334dcded50a84cdef 100644 (file)
--- a/blame.c
+++ b/blame.c
@@ -553,10 +553,10 @@ static struct blame_origin *find_origin(struct commit *parent,
        diff_setup_done(&diff_opts);
 
        if (is_null_oid(&origin->commit->object.oid))
-               do_diff_cache(&parent->tree->object.oid, &diff_opts);
+               do_diff_cache(&parent->maybe_tree->object.oid, &diff_opts);
        else
-               diff_tree_oid(&parent->tree->object.oid,
-                             &origin->commit->tree->object.oid,
+               diff_tree_oid(&parent->maybe_tree->object.oid,
+                             &origin->commit->maybe_tree->object.oid,
                              "", &diff_opts);
        diffcore_std(&diff_opts);
 
@@ -622,10 +622,10 @@ static struct blame_origin *find_rename(struct commit *parent,
        diff_setup_done(&diff_opts);
 
        if (is_null_oid(&origin->commit->object.oid))
-               do_diff_cache(&parent->tree->object.oid, &diff_opts);
+               do_diff_cache(&parent->maybe_tree->object.oid, &diff_opts);
        else
-               diff_tree_oid(&parent->tree->object.oid,
-                             &origin->commit->tree->object.oid,
+               diff_tree_oid(&parent->maybe_tree->object.oid,
+                             &origin->commit->maybe_tree->object.oid,
                              "", &diff_opts);
        diffcore_std(&diff_opts);
 
@@ -1257,10 +1257,10 @@ static void find_copy_in_parent(struct blame_scoreboard *sb,
                diff_opts.flags.find_copies_harder = 1;
 
        if (is_null_oid(&target->commit->object.oid))
-               do_diff_cache(&parent->tree->object.oid, &diff_opts);
+               do_diff_cache(&parent->maybe_tree->object.oid, &diff_opts);
        else
-               diff_tree_oid(&parent->tree->object.oid,
-                             &target->commit->tree->object.oid,
+               diff_tree_oid(&parent->maybe_tree->object.oid,
+                             &target->commit->maybe_tree->object.oid,
                              "", &diff_opts);
 
        if (!diff_opts.flags.find_copies_harder)
index a52af2e50705312a6d42df8667bbe4f5dfab8c86..ca6aa297941f240262745b2c9baa3a35a60eb74b 100644 (file)
@@ -484,7 +484,7 @@ static int merge_working_tree(const struct checkout_opts *opts,
 
        resolve_undo_clear();
        if (opts->force) {
-               ret = reset_tree(new_branch_info->commit->tree, opts, 1, writeout_error);
+               ret = reset_tree(new_branch_info->commit->maybe_tree, opts, 1, writeout_error);
                if (ret)
                        return ret;
        } else {
@@ -570,18 +570,18 @@ static int merge_working_tree(const struct checkout_opts *opts,
                        o.verbosity = 0;
                        work = write_tree_from_memory(&o);
 
-                       ret = reset_tree(new_branch_info->commit->tree, opts, 1,
+                       ret = reset_tree(new_branch_info->commit->maybe_tree, opts, 1,
                                         writeout_error);
                        if (ret)
                                return ret;
                        o.ancestor = old_branch_info->name;
                        o.branch1 = new_branch_info->name;
                        o.branch2 = "local";
-                       ret = merge_trees(&o, new_branch_info->commit->tree, work,
-                               old_branch_info->commit->tree, &result);
+                       ret = merge_trees(&o, new_branch_info->commit->maybe_tree, work,
+                               old_branch_info->commit->maybe_tree, &result);
                        if (ret < 0)
                                exit(128);
-                       ret = reset_tree(new_branch_info->commit->tree, opts, 0,
+                       ret = reset_tree(new_branch_info->commit->maybe_tree, opts, 0,
                                         writeout_error);
                        strbuf_release(&o.obuf);
                        if (ret)
@@ -1002,7 +1002,7 @@ static int parse_branchname_arg(int argc, const char **argv,
                *source_tree = parse_tree_indirect(rev);
        } else {
                parse_commit_or_die(new_branch_info->commit);
-               *source_tree = new_branch_info->commit->tree;
+               *source_tree = new_branch_info->commit->maybe_tree;
        }
 
        if (!*source_tree)                   /* case (1): want a tree */
index 16bfb22f7381ee8e6967ab836686c5def7cff892..34f18a5f3f5c8982a2297119ac67583720a2bbb3 100644 (file)
@@ -398,7 +398,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
                if (!obj)
                        die(_("invalid object '%s' given."), name);
                if (obj->type == OBJ_COMMIT)
-                       obj = &((struct commit *)obj)->tree->object;
+                       obj = &((struct commit *)obj)->maybe_tree->object;
 
                if (obj->type == OBJ_TREE) {
                        obj->flags |= flags;
index 27b2cc138e67c013adbee3cbe152ca48c3d82ff5..91e526b30d28303c76a957a7df44d5592b586d0d 100644 (file)
@@ -578,11 +578,11 @@ static void handle_commit(struct commit *commit, struct rev_info *rev,
            get_object_mark(&commit->parents->item->object) != 0 &&
            !full_tree) {
                parse_commit_or_die(commit->parents->item);
-               diff_tree_oid(&commit->parents->item->tree->object.oid,
-                             &commit->tree->object.oid, "", &rev->diffopt);
+               diff_tree_oid(&commit->parents->item->maybe_tree->object.oid,
+                             &commit->maybe_tree->object.oid, "", &rev->diffopt);
        }
        else
-               diff_root_tree_oid(&commit->tree->object.oid,
+               diff_root_tree_oid(&commit->maybe_tree->object.oid,
                                   "", &rev->diffopt);
 
        /* Export the referenced blobs, and remember the marks. */
index 46b4ca13e5c11ff43c15d80e618914e671ff17a0..a1fbc608bc242436eaa1561df43063a1c7c1d6aa 100644 (file)
@@ -1064,8 +1064,8 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
 
        diff_setup_done(&opts);
 
-       diff_tree_oid(&origin->tree->object.oid,
-                     &head->tree->object.oid,
+       diff_tree_oid(&origin->maybe_tree->object.oid,
+                     &head->maybe_tree->object.oid,
                      "", &opts);
        diffcore_std(&opts);
        diff_flush(&opts);
index ac3dcd7a51170cd9146d044f6ab70203e6591507..29d80a35a13198cd3b4d8d0b0c19e28fd078bf30 100644 (file)
@@ -153,7 +153,7 @@ static int commit_is_complete(struct commit *commit)
                for (i = 0; i < found.nr; i++) {
                        struct commit *c =
                                (struct commit *)found.objects[i].item;
-                       if (!tree_is_complete(&c->tree->object.oid)) {
+                       if (!tree_is_complete(&c->maybe_tree->object.oid)) {
                                is_incomplete = 1;
                                c->object.flags |= INCOMPLETE;
                        }
index 3ff8c84c0e4438e5367c4e2a2911917f9cc84102..49c622c5569f53edcc94e591892191067629a0a6 100644 (file)
@@ -258,7 +258,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->maybe_tree = lookup_tree(&oid);
 
        date_high = get_be32(commit_data + g->hash_len + 8) & 0x3;
        date_low = get_be32(commit_data + g->hash_len + 12);
@@ -369,7 +369,7 @@ static void write_graph_chunk_data(struct hashfile *f, int hash_len,
                uint32_t packedDate[2];
 
                parse_commit(*list);
-               hashwrite(f, (*list)->tree->object.oid.hash, hash_len);
+               hashwrite(f, (*list)->maybe_tree->object.oid.hash, hash_len);
 
                parent = (*list)->parents;
 
index 3e39c86abf885f82ed70cbd5b8212a5436820952..fbc092808cb3ddfecc82abc4873e941331a31888 100644 (file)
--- a/commit.c
+++ b/commit.c
@@ -335,7 +335,7 @@ int parse_commit_buffer(struct commit *item, const void *buffer, unsigned long s
        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(&parent);
+       item->maybe_tree = lookup_tree(&parent);
        bufptr += tree_entry_len + 1; /* "tree " + "hex sha1" + "\n" */
        pptr = &item->parents;
 
index e57ae4b58380cce6192cc6489682838677f048ce..c4d6e6e06465904d79da70662ede18cccf00621d 100644 (file)
--- a/commit.h
+++ b/commit.h
@@ -22,7 +22,7 @@ struct commit {
        unsigned int index;
        timestamp_t date;
        struct commit_list *parents;
-       struct tree *tree;
+       struct tree *maybe_tree;
        uint32_t graph_pos;
 };
 
diff --git a/fsck.c b/fsck.c
index 5c8c12dde381912eccf59bbf3ed8c774344809b8..3228ca5beeaed5ffc8fff8821118591e4ff31259 100644 (file)
--- a/fsck.c
+++ b/fsck.c
@@ -396,9 +396,9 @@ static int fsck_walk_commit(struct commit *commit, void *data, struct fsck_optio
 
        name = get_object_name(options, &commit->object);
        if (name)
-               put_object_name(options, &commit->tree->object, "%s:", name);
+               put_object_name(options, &commit->maybe_tree->object, "%s:", name);
 
-       result = options->walk((struct object *)commit->tree, OBJ_TREE, data, options);
+       result = options->walk((struct object *)commit->maybe_tree, OBJ_TREE, data, options);
        if (result < 0)
                return result;
        res = result;
@@ -772,7 +772,7 @@ static int fsck_commit_buffer(struct commit *commit, const char *buffer,
        err = fsck_ident(&buffer, &commit->object, options);
        if (err)
                return err;
-       if (!commit->tree) {
+       if (!commit->maybe_tree) {
                err = report(options, &commit->object, FSCK_MSG_BAD_TREE, "could not load commit's tree %s", sha1_to_hex(tree_sha1));
                if (err)
                        return err;
index 7dcd9daf62cf07e1cc43022fde17607cef6dc147..d83479f32f4cfa7fdc66620a2abe703733f8a8f6 100644 (file)
@@ -1330,7 +1330,7 @@ static int get_delta(struct rev_info *revs, struct remote_lock *lock)
        int count = 0;
 
        while ((commit = get_revision(revs)) != NULL) {
-               p = process_tree(commit->tree, p);
+               p = process_tree(commit->maybe_tree, p);
                commit->object.flags |= LOCAL;
                if (!(commit->object.flags & UNINTERESTING))
                        count += add_send_request(&commit->object, lock);
index cdc2257db56f7d68412bb456e91854a9e9aa5cd5..e714969ca22e860b4f685fe36e9b245f52848e5f 100644 (file)
@@ -817,8 +817,8 @@ static void queue_diffs(struct line_log_data *range,
        assert(commit);
 
        DIFF_QUEUE_CLEAR(&diff_queued_diff);
-       diff_tree_oid(parent ? &parent->tree->object.oid : NULL,
-                     &commit->tree->object.oid, "", opt);
+       diff_tree_oid(parent ? &parent->maybe_tree->object.oid : NULL,
+                     &commit->maybe_tree->object.oid, "", opt);
        if (opt->detect_rename) {
                filter_diffs_for_paths(range, 1);
                if (diff_might_be_rename())
index 168bef688a89489a9d88d3e1f773483dbc1c8860..bfd09f545c971e001ffe3d48aa79a893784b67ed 100644 (file)
@@ -195,7 +195,7 @@ static void mark_edge_parents_uninteresting(struct commit *commit,
                struct commit *parent = parents->item;
                if (!(parent->object.flags & UNINTERESTING))
                        continue;
-               mark_tree_uninteresting(parent->tree);
+               mark_tree_uninteresting(parent->maybe_tree);
                if (revs->edge_hint && !(parent->object.flags & SHOWN)) {
                        parent->object.flags |= SHOWN;
                        show_edge(parent);
@@ -212,7 +212,7 @@ void mark_edges_uninteresting(struct rev_info *revs, show_edge_fn show_edge)
                struct commit *commit = list->item;
 
                if (commit->object.flags & UNINTERESTING) {
-                       mark_tree_uninteresting(commit->tree);
+                       mark_tree_uninteresting(commit->maybe_tree);
                        if (revs->edge_hint_aggressive && !(commit->object.flags & SHOWN)) {
                                commit->object.flags |= SHOWN;
                                show_edge(commit);
@@ -227,7 +227,7 @@ void mark_edges_uninteresting(struct rev_info *revs, show_edge_fn show_edge)
                        struct commit *commit = (struct commit *)obj;
                        if (obj->type != OBJ_COMMIT || !(obj->flags & UNINTERESTING))
                                continue;
-                       mark_tree_uninteresting(commit->tree);
+                       mark_tree_uninteresting(commit->maybe_tree);
                        if (!(obj->flags & SHOWN)) {
                                obj->flags |= SHOWN;
                                show_edge(commit);
@@ -300,8 +300,8 @@ static void do_traverse(struct rev_info *revs,
                 * an uninteresting boundary commit may not have its tree
                 * parsed yet, but we are not going to show them anyway
                 */
-               if (commit->tree)
-                       add_pending_tree(revs, commit->tree);
+               if (commit->maybe_tree)
+                       add_pending_tree(revs, commit->maybe_tree);
                show_commit(commit, show_data);
 
                if (revs->tree_blobs_in_commit_order)
index bdf23c5f7b89eda2997057285d1fff64acb0d30c..99499af57c102f1d84f5c44ff0565a463f4486e5 100644 (file)
@@ -806,7 +806,7 @@ static int log_tree_diff(struct rev_info *opt, struct commit *commit, struct log
                return 0;
 
        parse_commit_or_die(commit);
-       oid = &commit->tree->object.oid;
+       oid = &commit->maybe_tree->object.oid;
 
        /* Root commit? */
        parents = get_saved_parents(opt, commit);
@@ -831,7 +831,7 @@ static int log_tree_diff(struct rev_info *opt, struct commit *commit, struct log
                         * we merged _in_.
                         */
                        parse_commit_or_die(parents->item);
-                       diff_tree_oid(&parents->item->tree->object.oid,
+                       diff_tree_oid(&parents->item->maybe_tree->object.oid,
                                      oid, "", &opt->diffopt);
                        log_tree_diff_flush(opt);
                        return !opt->loginfo;
@@ -846,7 +846,7 @@ static int log_tree_diff(struct rev_info *opt, struct commit *commit, struct log
                struct commit *parent = parents->item;
 
                parse_commit_or_die(parent);
-               diff_tree_oid(&parent->tree->object.oid,
+               diff_tree_oid(&parent->maybe_tree->object.oid,
                              oid, "", &opt->diffopt);
                log_tree_diff_flush(opt);
 
index 6ff971f9a2a8e251b8762d75214697698e2d1ce6..0f75d75d1788aeba20d71347115add5ac1f5afdd 100644 (file)
@@ -101,7 +101,7 @@ static struct commit *make_virtual_commit(struct tree *tree, const char *comment
        struct commit *commit = alloc_commit_node();
 
        set_merge_remote_desc(commit, comment, (struct object *)commit);
-       commit->tree = tree;
+       commit->maybe_tree = tree;
        commit->object.parsed = 1;
        return commit;
 }
@@ -2154,7 +2154,8 @@ int merge_recursive(struct merge_options *o,
                read_cache();
 
        o->ancestor = "merged common ancestors";
-       clean = merge_trees(o, h1->tree, h2->tree, merged_common_ancestors->tree,
+       clean = merge_trees(o, h1->maybe_tree, h2->maybe_tree,
+                           merged_common_ancestors->maybe_tree,
                            &mrtree);
        if (clean < 0) {
                flush_output(o);
index c09c5e0e474a30b0a8bf3d91063c8bbc61e63557..1d3edc89425d99a537c750766cd0d1c81760f0de 100644 (file)
@@ -600,14 +600,14 @@ int notes_merge(struct notes_merge_options *o,
                        printf("No merge base found; doing history-less merge\n");
        } else if (!bases->next) {
                base_oid = &bases->item->object.oid;
-               base_tree_oid = &bases->item->tree->object.oid;
+               base_tree_oid = &bases->item->maybe_tree->object.oid;
                if (o->verbosity >= 4)
                        printf("One merge base found (%.7s)\n",
                               oid_to_hex(base_oid));
        } else {
                /* TODO: How to handle multiple merge-bases? */
                base_oid = &bases->item->object.oid;
-               base_tree_oid = &bases->item->tree->object.oid;
+               base_tree_oid = &bases->item->maybe_tree->object.oid;
                if (o->verbosity >= 3)
                        printf("Multiple merge bases found. Using the first "
                                "(%.7s)\n", oid_to_hex(base_oid));
@@ -634,8 +634,8 @@ int notes_merge(struct notes_merge_options *o,
                goto found_result;
        }
 
-       result = merge_from_diffs(o, base_tree_oid, &local->tree->object.oid,
-                                 &remote->tree->object.oid, local_tree);
+       result = merge_from_diffs(o, base_tree_oid, &local->maybe_tree->object.oid,
+                                 &remote->maybe_tree->object.oid, local_tree);
 
        if (result != 0) { /* non-trivial merge (with or without conflicts) */
                /* Commit (partial) result */
index b1d33b646a030865b8ff65028cbf360465ed029b..3eb9c4a36e66faf5fd22c8287ea14fd01ee95a79 100644 (file)
@@ -1925,7 +1925,7 @@ static int add_promisor_object(const struct object_id *oid,
                struct commit *commit = (struct commit *) obj;
                struct commit_list *parents = commit->parents;
 
-               oidset_insert(set, &commit->tree->object.oid);
+               oidset_insert(set, &commit->maybe_tree->object.oid);
                for (; parents; parents = parents->next)
                        oidset_insert(set, &parents->item->object.oid);
        } else if (obj->type == OBJ_TAG) {
index f7ce4902301490d73bdd79bd396cf7bbe5f893ea..42095ea495a6412d9254eb33199fc68b168f4dd2 100644 (file)
--- a/pretty.c
+++ b/pretty.c
@@ -1161,10 +1161,10 @@ static size_t format_commit_one(struct strbuf *sb, /* in UTF-8 */
                strbuf_addstr(sb, diff_get_color(c->auto_color, DIFF_RESET));
                return 1;
        case 'T':               /* tree hash */
-               strbuf_addstr(sb, oid_to_hex(&commit->tree->object.oid));
+               strbuf_addstr(sb, oid_to_hex(&commit->maybe_tree->object.oid));
                return 1;
        case 't':               /* abbreviated tree hash */
-               strbuf_add_unique_abbrev(sb, commit->tree->object.oid.hash,
+               strbuf_add_unique_abbrev(sb, commit->maybe_tree->object.oid.hash,
                                         c->pretty_ctx->abbrev);
                return 1;
        case 'P':               /* parent hashes */
index 99a45beb14ea881390051a94f7254732446ace77..a59654cfd372dbe097cc3daa22e0c87af046bfa1 100644 (file)
@@ -815,7 +815,7 @@ static void grab_commit_values(struct atom_value *val, int deref, struct object
                if (deref)
                        name++;
                if (!strcmp(name, "tree")) {
-                       v->s = xstrdup(oid_to_hex(&commit->tree->object.oid));
+                       v->s = xstrdup(oid_to_hex(&commit->maybe_tree->object.oid));
                }
                else if (!strcmp(name, "numparent")) {
                        v->value = commit_list_count(commit->parents);
index 5c1cb7277c2fef11c473fbb3f6a9c04e0d83ca70..f61d1c930789b3d22ceed6cbbb63d393a9e0e0d3 100644 (file)
@@ -439,8 +439,8 @@ static void file_change(struct diff_options *options,
 static int rev_compare_tree(struct rev_info *revs,
                            struct commit *parent, struct commit *commit)
 {
-       struct tree *t1 = parent->tree;
-       struct tree *t2 = commit->tree;
+       struct tree *t1 = parent->maybe_tree;
+       struct tree *t2 = commit->maybe_tree;
 
        if (!t1)
                return REV_TREE_NEW;
@@ -476,7 +476,7 @@ static int rev_compare_tree(struct rev_info *revs,
 static int rev_same_tree_as_empty(struct rev_info *revs, struct commit *commit)
 {
        int retval;
-       struct tree *t1 = commit->tree;
+       struct tree *t1 = commit->maybe_tree;
 
        if (!t1)
                return 0;
@@ -614,7 +614,7 @@ static void try_to_simplify_commit(struct rev_info *revs, struct commit *commit)
        if (!revs->prune)
                return;
 
-       if (!commit->tree)
+       if (!commit->maybe_tree)
                return;
 
        if (!commit->parents) {
index 6ca4499d23e74d745ee49bec0012df984bf09ec9..9269607a485eae0dee11304a4e0d54ef57e88d0f 100644 (file)
@@ -501,8 +501,8 @@ static int do_recursive_merge(struct commit *base, struct commit *next,
        o.show_rename_progress = 1;
 
        head_tree = parse_tree_indirect(head);
-       next_tree = next ? next->tree : empty_tree();
-       base_tree = base ? base->tree : empty_tree();
+       next_tree = next ? next->maybe_tree : empty_tree();
+       base_tree = base ? base->maybe_tree : empty_tree();
 
        for (xopt = opts->xopts; xopt != opts->xopts + opts->xopts_nr; xopt++)
                parse_merge_opt(&o, *xopt);
@@ -562,7 +562,7 @@ static int is_index_unchanged(void)
                        return error(_("unable to update cache tree"));
 
        return !oidcmp(&active_cache_tree->oid,
-                      &head_commit->tree->object.oid);
+                      &head_commit->maybe_tree->object.oid);
 }
 
 static int write_author_script(const char *message)
@@ -1119,7 +1119,7 @@ static int try_to_commit(struct strbuf *msg, const char *author,
        }
 
        if (!(flags & ALLOW_EMPTY) && !oidcmp(current_head ?
-                                             &current_head->tree->object.oid :
+                                             &current_head->maybe_tree->object.oid :
                                              &empty_tree_oid, &tree)) {
                res = 1; /* run 'git commit' to display error message */
                goto out;
@@ -1217,12 +1217,12 @@ static int is_original_commit_empty(struct commit *commit)
                if (parse_commit(parent))
                        return error(_("could not parse parent commit %s"),
                                oid_to_hex(&parent->object.oid));
-               ptree_oid = &parent->tree->object.oid;
+               ptree_oid = &parent->maybe_tree->object.oid;
        } else {
                ptree_oid = the_hash_algo->empty_tree; /* commit is root */
        }
 
-       return !oidcmp(ptree_oid, &commit->tree->object.oid);
+       return !oidcmp(ptree_oid, &commit->maybe_tree->object.oid);
 }
 
 /*
index e7c18ffc26daf1962f90da9ff5c16cc608149d9d..6ca2a2de37e2ad75d6a7dd4d64cd967734bad157 100644 (file)
@@ -896,7 +896,7 @@ struct object *peel_to_type(const char *name, int namelen,
                if (o->type == OBJ_TAG)
                        o = ((struct tag*) o)->tagged;
                else if (o->type == OBJ_COMMIT)
-                       o = &(((struct commit *) o)->tree->object);
+                       o = &(((struct commit *) o)->maybe_tree->object);
                else {
                        if (name)
                                error("%.*s: expected %s type, but the object "
diff --git a/tree.c b/tree.c
index b224115e0f4d61368560eba406a04f0259b7c4f0..dbc5e0be544ef169ae7be26d9acdc4eb7cbecd62 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, &commit->maybe_tree->object.oid);
                }
                else
                        continue;
@@ -248,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 = &(((struct commit *) obj)->maybe_tree->object);
                else if (obj->type == OBJ_TAG)
                        obj = ((struct tag *) obj)->tagged;
                else
index dffb9c8e37c220e71e108060dc5a81bc21f8370c..1d5f3059a298411717b55ebe4275869b757468a9 100644 (file)
--- a/walker.c
+++ b/walker.c
@@ -87,7 +87,7 @@ static int process_commit(struct walker *walker, struct commit *commit)
        walker_say(walker, "walk %s\n", oid_to_hex(&commit->object.oid));
 
        if (walker->get_tree) {
-               if (process(walker, &commit->tree->object))
+               if (process(walker, &commit->maybe_tree->object))
                        return -1;
                if (!walker->get_all)
                        walker->get_tree = 0;