treewide: replace maybe_tree with accessor methods
In anticipation of making trees load lazily, create a Coccinelle script (contrib/coccinelle/commit.cocci) to ensure that all references to the 'maybe_tree' member of struct commit are either mutations or accesses through get_commit_tree() or get_commit_tree_oid(). Apply the Coccinelle script to create the rest of the patch. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
5bb03de102
commit
2e27bd7731
18
blame.c
18
blame.c
@ -553,10 +553,10 @@ static struct blame_origin *find_origin(struct commit *parent,
|
|||||||
diff_setup_done(&diff_opts);
|
diff_setup_done(&diff_opts);
|
||||||
|
|
||||||
if (is_null_oid(&origin->commit->object.oid))
|
if (is_null_oid(&origin->commit->object.oid))
|
||||||
do_diff_cache(&parent->maybe_tree->object.oid, &diff_opts);
|
do_diff_cache(get_commit_tree_oid(parent), &diff_opts);
|
||||||
else
|
else
|
||||||
diff_tree_oid(&parent->maybe_tree->object.oid,
|
diff_tree_oid(get_commit_tree_oid(parent),
|
||||||
&origin->commit->maybe_tree->object.oid,
|
get_commit_tree_oid(origin->commit),
|
||||||
"", &diff_opts);
|
"", &diff_opts);
|
||||||
diffcore_std(&diff_opts);
|
diffcore_std(&diff_opts);
|
||||||
|
|
||||||
@ -622,10 +622,10 @@ static struct blame_origin *find_rename(struct commit *parent,
|
|||||||
diff_setup_done(&diff_opts);
|
diff_setup_done(&diff_opts);
|
||||||
|
|
||||||
if (is_null_oid(&origin->commit->object.oid))
|
if (is_null_oid(&origin->commit->object.oid))
|
||||||
do_diff_cache(&parent->maybe_tree->object.oid, &diff_opts);
|
do_diff_cache(get_commit_tree_oid(parent), &diff_opts);
|
||||||
else
|
else
|
||||||
diff_tree_oid(&parent->maybe_tree->object.oid,
|
diff_tree_oid(get_commit_tree_oid(parent),
|
||||||
&origin->commit->maybe_tree->object.oid,
|
get_commit_tree_oid(origin->commit),
|
||||||
"", &diff_opts);
|
"", &diff_opts);
|
||||||
diffcore_std(&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;
|
diff_opts.flags.find_copies_harder = 1;
|
||||||
|
|
||||||
if (is_null_oid(&target->commit->object.oid))
|
if (is_null_oid(&target->commit->object.oid))
|
||||||
do_diff_cache(&parent->maybe_tree->object.oid, &diff_opts);
|
do_diff_cache(get_commit_tree_oid(parent), &diff_opts);
|
||||||
else
|
else
|
||||||
diff_tree_oid(&parent->maybe_tree->object.oid,
|
diff_tree_oid(get_commit_tree_oid(parent),
|
||||||
&target->commit->maybe_tree->object.oid,
|
get_commit_tree_oid(target->commit),
|
||||||
"", &diff_opts);
|
"", &diff_opts);
|
||||||
|
|
||||||
if (!diff_opts.flags.find_copies_harder)
|
if (!diff_opts.flags.find_copies_harder)
|
||||||
|
@ -484,7 +484,8 @@ static int merge_working_tree(const struct checkout_opts *opts,
|
|||||||
|
|
||||||
resolve_undo_clear();
|
resolve_undo_clear();
|
||||||
if (opts->force) {
|
if (opts->force) {
|
||||||
ret = reset_tree(new_branch_info->commit->maybe_tree, opts, 1, writeout_error);
|
ret = reset_tree(get_commit_tree(new_branch_info->commit),
|
||||||
|
opts, 1, writeout_error);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
} else {
|
} else {
|
||||||
@ -570,18 +571,23 @@ static int merge_working_tree(const struct checkout_opts *opts,
|
|||||||
o.verbosity = 0;
|
o.verbosity = 0;
|
||||||
work = write_tree_from_memory(&o);
|
work = write_tree_from_memory(&o);
|
||||||
|
|
||||||
ret = reset_tree(new_branch_info->commit->maybe_tree, opts, 1,
|
ret = reset_tree(get_commit_tree(new_branch_info->commit),
|
||||||
|
opts, 1,
|
||||||
writeout_error);
|
writeout_error);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
o.ancestor = old_branch_info->name;
|
o.ancestor = old_branch_info->name;
|
||||||
o.branch1 = new_branch_info->name;
|
o.branch1 = new_branch_info->name;
|
||||||
o.branch2 = "local";
|
o.branch2 = "local";
|
||||||
ret = merge_trees(&o, new_branch_info->commit->maybe_tree, work,
|
ret = merge_trees(&o,
|
||||||
old_branch_info->commit->maybe_tree, &result);
|
get_commit_tree(new_branch_info->commit),
|
||||||
|
work,
|
||||||
|
get_commit_tree(old_branch_info->commit),
|
||||||
|
&result);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
exit(128);
|
exit(128);
|
||||||
ret = reset_tree(new_branch_info->commit->maybe_tree, opts, 0,
|
ret = reset_tree(get_commit_tree(new_branch_info->commit),
|
||||||
|
opts, 0,
|
||||||
writeout_error);
|
writeout_error);
|
||||||
strbuf_release(&o.obuf);
|
strbuf_release(&o.obuf);
|
||||||
if (ret)
|
if (ret)
|
||||||
@ -1002,7 +1008,7 @@ static int parse_branchname_arg(int argc, const char **argv,
|
|||||||
*source_tree = parse_tree_indirect(rev);
|
*source_tree = parse_tree_indirect(rev);
|
||||||
} else {
|
} else {
|
||||||
parse_commit_or_die(new_branch_info->commit);
|
parse_commit_or_die(new_branch_info->commit);
|
||||||
*source_tree = new_branch_info->commit->maybe_tree;
|
*source_tree = get_commit_tree(new_branch_info->commit);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!*source_tree) /* case (1): want a tree */
|
if (!*source_tree) /* case (1): want a tree */
|
||||||
|
@ -398,7 +398,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
|
|||||||
if (!obj)
|
if (!obj)
|
||||||
die(_("invalid object '%s' given."), name);
|
die(_("invalid object '%s' given."), name);
|
||||||
if (obj->type == OBJ_COMMIT)
|
if (obj->type == OBJ_COMMIT)
|
||||||
obj = &((struct commit *)obj)->maybe_tree->object;
|
obj = &get_commit_tree(((struct commit *)obj))->object;
|
||||||
|
|
||||||
if (obj->type == OBJ_TREE) {
|
if (obj->type == OBJ_TREE) {
|
||||||
obj->flags |= flags;
|
obj->flags |= flags;
|
||||||
|
@ -578,11 +578,11 @@ static void handle_commit(struct commit *commit, struct rev_info *rev,
|
|||||||
get_object_mark(&commit->parents->item->object) != 0 &&
|
get_object_mark(&commit->parents->item->object) != 0 &&
|
||||||
!full_tree) {
|
!full_tree) {
|
||||||
parse_commit_or_die(commit->parents->item);
|
parse_commit_or_die(commit->parents->item);
|
||||||
diff_tree_oid(&commit->parents->item->maybe_tree->object.oid,
|
diff_tree_oid(get_commit_tree_oid(commit->parents->item),
|
||||||
&commit->maybe_tree->object.oid, "", &rev->diffopt);
|
get_commit_tree_oid(commit), "", &rev->diffopt);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
diff_root_tree_oid(&commit->maybe_tree->object.oid,
|
diff_root_tree_oid(get_commit_tree_oid(commit),
|
||||||
"", &rev->diffopt);
|
"", &rev->diffopt);
|
||||||
|
|
||||||
/* Export the referenced blobs, and remember the marks. */
|
/* Export the referenced blobs, and remember the marks. */
|
||||||
|
@ -1064,8 +1064,8 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
|
|||||||
|
|
||||||
diff_setup_done(&opts);
|
diff_setup_done(&opts);
|
||||||
|
|
||||||
diff_tree_oid(&origin->maybe_tree->object.oid,
|
diff_tree_oid(get_commit_tree_oid(origin),
|
||||||
&head->maybe_tree->object.oid,
|
get_commit_tree_oid(head),
|
||||||
"", &opts);
|
"", &opts);
|
||||||
diffcore_std(&opts);
|
diffcore_std(&opts);
|
||||||
diff_flush(&opts);
|
diff_flush(&opts);
|
||||||
|
@ -153,7 +153,7 @@ static int commit_is_complete(struct commit *commit)
|
|||||||
for (i = 0; i < found.nr; i++) {
|
for (i = 0; i < found.nr; i++) {
|
||||||
struct commit *c =
|
struct commit *c =
|
||||||
(struct commit *)found.objects[i].item;
|
(struct commit *)found.objects[i].item;
|
||||||
if (!tree_is_complete(&c->maybe_tree->object.oid)) {
|
if (!tree_is_complete(get_commit_tree_oid(c))) {
|
||||||
is_incomplete = 1;
|
is_incomplete = 1;
|
||||||
c->object.flags |= INCOMPLETE;
|
c->object.flags |= INCOMPLETE;
|
||||||
}
|
}
|
||||||
|
@ -369,7 +369,7 @@ static void write_graph_chunk_data(struct hashfile *f, int hash_len,
|
|||||||
uint32_t packedDate[2];
|
uint32_t packedDate[2];
|
||||||
|
|
||||||
parse_commit(*list);
|
parse_commit(*list);
|
||||||
hashwrite(f, (*list)->maybe_tree->object.oid.hash, hash_len);
|
hashwrite(f, get_commit_tree_oid(*list)->hash, hash_len);
|
||||||
|
|
||||||
parent = (*list)->parents;
|
parent = (*list)->parents;
|
||||||
|
|
||||||
|
30
contrib/coccinelle/commit.cocci
Normal file
30
contrib/coccinelle/commit.cocci
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
@@
|
||||||
|
expression c;
|
||||||
|
@@
|
||||||
|
- &c->maybe_tree->object.oid
|
||||||
|
+ get_commit_tree_oid(c)
|
||||||
|
|
||||||
|
@@
|
||||||
|
expression c;
|
||||||
|
@@
|
||||||
|
- c->maybe_tree->object.oid.hash
|
||||||
|
+ get_commit_tree_oid(c)->hash
|
||||||
|
|
||||||
|
@@
|
||||||
|
expression c;
|
||||||
|
@@
|
||||||
|
- c->maybe_tree
|
||||||
|
+ get_commit_tree(c)
|
||||||
|
|
||||||
|
@@
|
||||||
|
expression c;
|
||||||
|
expression s;
|
||||||
|
@@
|
||||||
|
- get_commit_tree(c) = s
|
||||||
|
+ c->maybe_tree = s
|
||||||
|
|
||||||
|
@@
|
||||||
|
expression c;
|
||||||
|
@@
|
||||||
|
- return get_commit_tree(c);
|
||||||
|
+ return c->maybe_tree;
|
8
fsck.c
8
fsck.c
@ -396,9 +396,11 @@ static int fsck_walk_commit(struct commit *commit, void *data, struct fsck_optio
|
|||||||
|
|
||||||
name = get_object_name(options, &commit->object);
|
name = get_object_name(options, &commit->object);
|
||||||
if (name)
|
if (name)
|
||||||
put_object_name(options, &commit->maybe_tree->object, "%s:", name);
|
put_object_name(options, &get_commit_tree(commit)->object,
|
||||||
|
"%s:", name);
|
||||||
|
|
||||||
result = options->walk((struct object *)commit->maybe_tree, OBJ_TREE, data, options);
|
result = options->walk((struct object *)get_commit_tree(commit),
|
||||||
|
OBJ_TREE, data, options);
|
||||||
if (result < 0)
|
if (result < 0)
|
||||||
return result;
|
return result;
|
||||||
res = result;
|
res = result;
|
||||||
@ -772,7 +774,7 @@ static int fsck_commit_buffer(struct commit *commit, const char *buffer,
|
|||||||
err = fsck_ident(&buffer, &commit->object, options);
|
err = fsck_ident(&buffer, &commit->object, options);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
if (!commit->maybe_tree) {
|
if (!get_commit_tree(commit)) {
|
||||||
err = report(options, &commit->object, FSCK_MSG_BAD_TREE, "could not load commit's tree %s", sha1_to_hex(tree_sha1));
|
err = report(options, &commit->object, FSCK_MSG_BAD_TREE, "could not load commit's tree %s", sha1_to_hex(tree_sha1));
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
@ -1330,7 +1330,7 @@ static int get_delta(struct rev_info *revs, struct remote_lock *lock)
|
|||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
while ((commit = get_revision(revs)) != NULL) {
|
while ((commit = get_revision(revs)) != NULL) {
|
||||||
p = process_tree(commit->maybe_tree, p);
|
p = process_tree(get_commit_tree(commit), p);
|
||||||
commit->object.flags |= LOCAL;
|
commit->object.flags |= LOCAL;
|
||||||
if (!(commit->object.flags & UNINTERESTING))
|
if (!(commit->object.flags & UNINTERESTING))
|
||||||
count += add_send_request(&commit->object, lock);
|
count += add_send_request(&commit->object, lock);
|
||||||
|
@ -817,8 +817,8 @@ static void queue_diffs(struct line_log_data *range,
|
|||||||
assert(commit);
|
assert(commit);
|
||||||
|
|
||||||
DIFF_QUEUE_CLEAR(&diff_queued_diff);
|
DIFF_QUEUE_CLEAR(&diff_queued_diff);
|
||||||
diff_tree_oid(parent ? &parent->maybe_tree->object.oid : NULL,
|
diff_tree_oid(parent ? get_commit_tree_oid(parent) : NULL,
|
||||||
&commit->maybe_tree->object.oid, "", opt);
|
get_commit_tree_oid(commit), "", opt);
|
||||||
if (opt->detect_rename) {
|
if (opt->detect_rename) {
|
||||||
filter_diffs_for_paths(range, 1);
|
filter_diffs_for_paths(range, 1);
|
||||||
if (diff_might_be_rename())
|
if (diff_might_be_rename())
|
||||||
|
@ -195,7 +195,7 @@ static void mark_edge_parents_uninteresting(struct commit *commit,
|
|||||||
struct commit *parent = parents->item;
|
struct commit *parent = parents->item;
|
||||||
if (!(parent->object.flags & UNINTERESTING))
|
if (!(parent->object.flags & UNINTERESTING))
|
||||||
continue;
|
continue;
|
||||||
mark_tree_uninteresting(parent->maybe_tree);
|
mark_tree_uninteresting(get_commit_tree(parent));
|
||||||
if (revs->edge_hint && !(parent->object.flags & SHOWN)) {
|
if (revs->edge_hint && !(parent->object.flags & SHOWN)) {
|
||||||
parent->object.flags |= SHOWN;
|
parent->object.flags |= SHOWN;
|
||||||
show_edge(parent);
|
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;
|
struct commit *commit = list->item;
|
||||||
|
|
||||||
if (commit->object.flags & UNINTERESTING) {
|
if (commit->object.flags & UNINTERESTING) {
|
||||||
mark_tree_uninteresting(commit->maybe_tree);
|
mark_tree_uninteresting(get_commit_tree(commit));
|
||||||
if (revs->edge_hint_aggressive && !(commit->object.flags & SHOWN)) {
|
if (revs->edge_hint_aggressive && !(commit->object.flags & SHOWN)) {
|
||||||
commit->object.flags |= SHOWN;
|
commit->object.flags |= SHOWN;
|
||||||
show_edge(commit);
|
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;
|
struct commit *commit = (struct commit *)obj;
|
||||||
if (obj->type != OBJ_COMMIT || !(obj->flags & UNINTERESTING))
|
if (obj->type != OBJ_COMMIT || !(obj->flags & UNINTERESTING))
|
||||||
continue;
|
continue;
|
||||||
mark_tree_uninteresting(commit->maybe_tree);
|
mark_tree_uninteresting(get_commit_tree(commit));
|
||||||
if (!(obj->flags & SHOWN)) {
|
if (!(obj->flags & SHOWN)) {
|
||||||
obj->flags |= SHOWN;
|
obj->flags |= SHOWN;
|
||||||
show_edge(commit);
|
show_edge(commit);
|
||||||
@ -300,8 +300,8 @@ static void do_traverse(struct rev_info *revs,
|
|||||||
* an uninteresting boundary commit may not have its tree
|
* an uninteresting boundary commit may not have its tree
|
||||||
* parsed yet, but we are not going to show them anyway
|
* parsed yet, but we are not going to show them anyway
|
||||||
*/
|
*/
|
||||||
if (commit->maybe_tree)
|
if (get_commit_tree(commit))
|
||||||
add_pending_tree(revs, commit->maybe_tree);
|
add_pending_tree(revs, get_commit_tree(commit));
|
||||||
show_commit(commit, show_data);
|
show_commit(commit, show_data);
|
||||||
|
|
||||||
if (revs->tree_blobs_in_commit_order)
|
if (revs->tree_blobs_in_commit_order)
|
||||||
|
@ -806,7 +806,7 @@ static int log_tree_diff(struct rev_info *opt, struct commit *commit, struct log
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
parse_commit_or_die(commit);
|
parse_commit_or_die(commit);
|
||||||
oid = &commit->maybe_tree->object.oid;
|
oid = get_commit_tree_oid(commit);
|
||||||
|
|
||||||
/* Root commit? */
|
/* Root commit? */
|
||||||
parents = get_saved_parents(opt, 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_.
|
* we merged _in_.
|
||||||
*/
|
*/
|
||||||
parse_commit_or_die(parents->item);
|
parse_commit_or_die(parents->item);
|
||||||
diff_tree_oid(&parents->item->maybe_tree->object.oid,
|
diff_tree_oid(get_commit_tree_oid(parents->item),
|
||||||
oid, "", &opt->diffopt);
|
oid, "", &opt->diffopt);
|
||||||
log_tree_diff_flush(opt);
|
log_tree_diff_flush(opt);
|
||||||
return !opt->loginfo;
|
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;
|
struct commit *parent = parents->item;
|
||||||
|
|
||||||
parse_commit_or_die(parent);
|
parse_commit_or_die(parent);
|
||||||
diff_tree_oid(&parent->maybe_tree->object.oid,
|
diff_tree_oid(get_commit_tree_oid(parent),
|
||||||
oid, "", &opt->diffopt);
|
oid, "", &opt->diffopt);
|
||||||
log_tree_diff_flush(opt);
|
log_tree_diff_flush(opt);
|
||||||
|
|
||||||
|
@ -2154,8 +2154,8 @@ int merge_recursive(struct merge_options *o,
|
|||||||
read_cache();
|
read_cache();
|
||||||
|
|
||||||
o->ancestor = "merged common ancestors";
|
o->ancestor = "merged common ancestors";
|
||||||
clean = merge_trees(o, h1->maybe_tree, h2->maybe_tree,
|
clean = merge_trees(o, get_commit_tree(h1), get_commit_tree(h2),
|
||||||
merged_common_ancestors->maybe_tree,
|
get_commit_tree(merged_common_ancestors),
|
||||||
&mrtree);
|
&mrtree);
|
||||||
if (clean < 0) {
|
if (clean < 0) {
|
||||||
flush_output(o);
|
flush_output(o);
|
||||||
|
@ -600,14 +600,14 @@ int notes_merge(struct notes_merge_options *o,
|
|||||||
printf("No merge base found; doing history-less merge\n");
|
printf("No merge base found; doing history-less merge\n");
|
||||||
} else if (!bases->next) {
|
} else if (!bases->next) {
|
||||||
base_oid = &bases->item->object.oid;
|
base_oid = &bases->item->object.oid;
|
||||||
base_tree_oid = &bases->item->maybe_tree->object.oid;
|
base_tree_oid = get_commit_tree_oid(bases->item);
|
||||||
if (o->verbosity >= 4)
|
if (o->verbosity >= 4)
|
||||||
printf("One merge base found (%.7s)\n",
|
printf("One merge base found (%.7s)\n",
|
||||||
oid_to_hex(base_oid));
|
oid_to_hex(base_oid));
|
||||||
} else {
|
} else {
|
||||||
/* TODO: How to handle multiple merge-bases? */
|
/* TODO: How to handle multiple merge-bases? */
|
||||||
base_oid = &bases->item->object.oid;
|
base_oid = &bases->item->object.oid;
|
||||||
base_tree_oid = &bases->item->maybe_tree->object.oid;
|
base_tree_oid = get_commit_tree_oid(bases->item);
|
||||||
if (o->verbosity >= 3)
|
if (o->verbosity >= 3)
|
||||||
printf("Multiple merge bases found. Using the first "
|
printf("Multiple merge bases found. Using the first "
|
||||||
"(%.7s)\n", oid_to_hex(base_oid));
|
"(%.7s)\n", oid_to_hex(base_oid));
|
||||||
@ -634,8 +634,9 @@ int notes_merge(struct notes_merge_options *o,
|
|||||||
goto found_result;
|
goto found_result;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = merge_from_diffs(o, base_tree_oid, &local->maybe_tree->object.oid,
|
result = merge_from_diffs(o, base_tree_oid,
|
||||||
&remote->maybe_tree->object.oid, local_tree);
|
get_commit_tree_oid(local),
|
||||||
|
get_commit_tree_oid(remote), local_tree);
|
||||||
|
|
||||||
if (result != 0) { /* non-trivial merge (with or without conflicts) */
|
if (result != 0) { /* non-trivial merge (with or without conflicts) */
|
||||||
/* Commit (partial) result */
|
/* Commit (partial) result */
|
||||||
|
@ -1925,7 +1925,7 @@ static int add_promisor_object(const struct object_id *oid,
|
|||||||
struct commit *commit = (struct commit *) obj;
|
struct commit *commit = (struct commit *) obj;
|
||||||
struct commit_list *parents = commit->parents;
|
struct commit_list *parents = commit->parents;
|
||||||
|
|
||||||
oidset_insert(set, &commit->maybe_tree->object.oid);
|
oidset_insert(set, get_commit_tree_oid(commit));
|
||||||
for (; parents; parents = parents->next)
|
for (; parents; parents = parents->next)
|
||||||
oidset_insert(set, &parents->item->object.oid);
|
oidset_insert(set, &parents->item->object.oid);
|
||||||
} else if (obj->type == OBJ_TAG) {
|
} else if (obj->type == OBJ_TAG) {
|
||||||
|
5
pretty.c
5
pretty.c
@ -1161,10 +1161,11 @@ static size_t format_commit_one(struct strbuf *sb, /* in UTF-8 */
|
|||||||
strbuf_addstr(sb, diff_get_color(c->auto_color, DIFF_RESET));
|
strbuf_addstr(sb, diff_get_color(c->auto_color, DIFF_RESET));
|
||||||
return 1;
|
return 1;
|
||||||
case 'T': /* tree hash */
|
case 'T': /* tree hash */
|
||||||
strbuf_addstr(sb, oid_to_hex(&commit->maybe_tree->object.oid));
|
strbuf_addstr(sb, oid_to_hex(get_commit_tree_oid(commit)));
|
||||||
return 1;
|
return 1;
|
||||||
case 't': /* abbreviated tree hash */
|
case 't': /* abbreviated tree hash */
|
||||||
strbuf_add_unique_abbrev(sb, commit->maybe_tree->object.oid.hash,
|
strbuf_add_unique_abbrev(sb,
|
||||||
|
get_commit_tree_oid(commit)->hash,
|
||||||
c->pretty_ctx->abbrev);
|
c->pretty_ctx->abbrev);
|
||||||
return 1;
|
return 1;
|
||||||
case 'P': /* parent hashes */
|
case 'P': /* parent hashes */
|
||||||
|
@ -815,7 +815,7 @@ static void grab_commit_values(struct atom_value *val, int deref, struct object
|
|||||||
if (deref)
|
if (deref)
|
||||||
name++;
|
name++;
|
||||||
if (!strcmp(name, "tree")) {
|
if (!strcmp(name, "tree")) {
|
||||||
v->s = xstrdup(oid_to_hex(&commit->maybe_tree->object.oid));
|
v->s = xstrdup(oid_to_hex(get_commit_tree_oid(commit)));
|
||||||
}
|
}
|
||||||
else if (!strcmp(name, "numparent")) {
|
else if (!strcmp(name, "numparent")) {
|
||||||
v->value = commit_list_count(commit->parents);
|
v->value = commit_list_count(commit->parents);
|
||||||
|
@ -439,8 +439,8 @@ static void file_change(struct diff_options *options,
|
|||||||
static int rev_compare_tree(struct rev_info *revs,
|
static int rev_compare_tree(struct rev_info *revs,
|
||||||
struct commit *parent, struct commit *commit)
|
struct commit *parent, struct commit *commit)
|
||||||
{
|
{
|
||||||
struct tree *t1 = parent->maybe_tree;
|
struct tree *t1 = get_commit_tree(parent);
|
||||||
struct tree *t2 = commit->maybe_tree;
|
struct tree *t2 = get_commit_tree(commit);
|
||||||
|
|
||||||
if (!t1)
|
if (!t1)
|
||||||
return REV_TREE_NEW;
|
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)
|
static int rev_same_tree_as_empty(struct rev_info *revs, struct commit *commit)
|
||||||
{
|
{
|
||||||
int retval;
|
int retval;
|
||||||
struct tree *t1 = commit->maybe_tree;
|
struct tree *t1 = get_commit_tree(commit);
|
||||||
|
|
||||||
if (!t1)
|
if (!t1)
|
||||||
return 0;
|
return 0;
|
||||||
@ -614,7 +614,7 @@ static void try_to_simplify_commit(struct rev_info *revs, struct commit *commit)
|
|||||||
if (!revs->prune)
|
if (!revs->prune)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!commit->maybe_tree)
|
if (!get_commit_tree(commit))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!commit->parents) {
|
if (!commit->parents) {
|
||||||
|
12
sequencer.c
12
sequencer.c
@ -501,8 +501,8 @@ static int do_recursive_merge(struct commit *base, struct commit *next,
|
|||||||
o.show_rename_progress = 1;
|
o.show_rename_progress = 1;
|
||||||
|
|
||||||
head_tree = parse_tree_indirect(head);
|
head_tree = parse_tree_indirect(head);
|
||||||
next_tree = next ? next->maybe_tree : empty_tree();
|
next_tree = next ? get_commit_tree(next) : empty_tree();
|
||||||
base_tree = base ? base->maybe_tree : empty_tree();
|
base_tree = base ? get_commit_tree(base) : empty_tree();
|
||||||
|
|
||||||
for (xopt = opts->xopts; xopt != opts->xopts + opts->xopts_nr; xopt++)
|
for (xopt = opts->xopts; xopt != opts->xopts + opts->xopts_nr; xopt++)
|
||||||
parse_merge_opt(&o, *xopt);
|
parse_merge_opt(&o, *xopt);
|
||||||
@ -562,7 +562,7 @@ static int is_index_unchanged(void)
|
|||||||
return error(_("unable to update cache tree"));
|
return error(_("unable to update cache tree"));
|
||||||
|
|
||||||
return !oidcmp(&active_cache_tree->oid,
|
return !oidcmp(&active_cache_tree->oid,
|
||||||
&head_commit->maybe_tree->object.oid);
|
get_commit_tree_oid(head_commit));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int write_author_script(const char *message)
|
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 ?
|
if (!(flags & ALLOW_EMPTY) && !oidcmp(current_head ?
|
||||||
¤t_head->maybe_tree->object.oid :
|
get_commit_tree_oid(current_head) :
|
||||||
&empty_tree_oid, &tree)) {
|
&empty_tree_oid, &tree)) {
|
||||||
res = 1; /* run 'git commit' to display error message */
|
res = 1; /* run 'git commit' to display error message */
|
||||||
goto out;
|
goto out;
|
||||||
@ -1217,12 +1217,12 @@ static int is_original_commit_empty(struct commit *commit)
|
|||||||
if (parse_commit(parent))
|
if (parse_commit(parent))
|
||||||
return error(_("could not parse parent commit %s"),
|
return error(_("could not parse parent commit %s"),
|
||||||
oid_to_hex(&parent->object.oid));
|
oid_to_hex(&parent->object.oid));
|
||||||
ptree_oid = &parent->maybe_tree->object.oid;
|
ptree_oid = get_commit_tree_oid(parent);
|
||||||
} else {
|
} else {
|
||||||
ptree_oid = the_hash_algo->empty_tree; /* commit is root */
|
ptree_oid = the_hash_algo->empty_tree; /* commit is root */
|
||||||
}
|
}
|
||||||
|
|
||||||
return !oidcmp(ptree_oid, &commit->maybe_tree->object.oid);
|
return !oidcmp(ptree_oid, get_commit_tree_oid(commit));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -896,7 +896,7 @@ struct object *peel_to_type(const char *name, int namelen,
|
|||||||
if (o->type == OBJ_TAG)
|
if (o->type == OBJ_TAG)
|
||||||
o = ((struct tag*) o)->tagged;
|
o = ((struct tag*) o)->tagged;
|
||||||
else if (o->type == OBJ_COMMIT)
|
else if (o->type == OBJ_COMMIT)
|
||||||
o = &(((struct commit *) o)->maybe_tree->object);
|
o = &(get_commit_tree(((struct commit *)o))->object);
|
||||||
else {
|
else {
|
||||||
if (name)
|
if (name)
|
||||||
error("%.*s: expected %s type, but the object "
|
error("%.*s: expected %s type, but the object "
|
||||||
|
4
tree.c
4
tree.c
@ -109,7 +109,7 @@ static int read_tree_1(struct tree *tree, struct strbuf *base,
|
|||||||
oid_to_hex(entry.oid),
|
oid_to_hex(entry.oid),
|
||||||
base->buf, entry.path);
|
base->buf, entry.path);
|
||||||
|
|
||||||
oidcpy(&oid, &commit->maybe_tree->object.oid);
|
oidcpy(&oid, get_commit_tree_oid(commit));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
continue;
|
continue;
|
||||||
@ -248,7 +248,7 @@ struct tree *parse_tree_indirect(const struct object_id *oid)
|
|||||||
if (obj->type == OBJ_TREE)
|
if (obj->type == OBJ_TREE)
|
||||||
return (struct tree *) obj;
|
return (struct tree *) obj;
|
||||||
else if (obj->type == OBJ_COMMIT)
|
else if (obj->type == OBJ_COMMIT)
|
||||||
obj = &(((struct commit *) obj)->maybe_tree->object);
|
obj = &(get_commit_tree(((struct commit *)obj))->object);
|
||||||
else if (obj->type == OBJ_TAG)
|
else if (obj->type == OBJ_TAG)
|
||||||
obj = ((struct tag *) obj)->tagged;
|
obj = ((struct tag *) obj)->tagged;
|
||||||
else
|
else
|
||||||
|
2
walker.c
2
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));
|
walker_say(walker, "walk %s\n", oid_to_hex(&commit->object.oid));
|
||||||
|
|
||||||
if (walker->get_tree) {
|
if (walker->get_tree) {
|
||||||
if (process(walker, &commit->maybe_tree->object))
|
if (process(walker, &get_commit_tree(commit)->object))
|
||||||
return -1;
|
return -1;
|
||||||
if (!walker->get_all)
|
if (!walker->get_all)
|
||||||
walker->get_tree = 0;
|
walker->get_tree = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user