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:

committed by
Junio C Hamano

parent
5bb03de102
commit
2e27bd7731
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);
|
||||
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)
|
||||
return 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);
|
||||
if (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));
|
||||
if (err)
|
||||
return err;
|
||||
|
Reference in New Issue
Block a user