Skip to content

Commit f00db9e

Browse files
committed
tree: rename from_tree to validate and clarify the tree in the test
1 parent 2dff7e2 commit f00db9e

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/tree.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -448,15 +448,15 @@ static int append_entry(
448448
const char *filename,
449449
const git_oid *id,
450450
git_filemode_t filemode,
451-
bool from_tree)
451+
bool validate)
452452
{
453453
git_tree_entry *entry;
454454
int error = 0;
455455

456-
if (!from_tree && !valid_entry_name(bld->repo, filename))
456+
if (validate && !valid_entry_name(bld->repo, filename))
457457
return tree_error("failed to insert entry: invalid name for a tree entry", filename);
458458

459-
if (!from_tree && git_oid_iszero(id))
459+
if (validate && git_oid_iszero(id))
460460
return tree_error("failed to insert entry: invalid null OID for a tree entry", filename);
461461

462462
entry = alloc_entry(filename, strlen(filename), id);
@@ -554,12 +554,12 @@ static int write_tree(
554554
last_comp = subdir;
555555
}
556556

557-
error = append_entry(bld, last_comp, &sub_oid, S_IFDIR, false);
557+
error = append_entry(bld, last_comp, &sub_oid, S_IFDIR, true);
558558
git__free(subdir);
559559
if (error < 0)
560560
goto on_error;
561561
} else {
562-
error = append_entry(bld, filename, &entry->id, entry->mode, false);
562+
error = append_entry(bld, filename, &entry->id, entry->mode, true);
563563
if (error < 0)
564564
goto on_error;
565565
}
@@ -658,7 +658,7 @@ int git_treebuilder_new(
658658
bld, entry_src->filename,
659659
entry_src->oid,
660660
entry_src->attr,
661-
true) < 0)
661+
false) < 0)
662662
goto on_error;
663663
}
664664
}

tests/object/tree/update.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ void test_object_tree_update__remove_invalid_submodule(void)
293293
{GIT_TREE_UPDATE_REMOVE, {{0}}, GIT_FILEMODE_BLOB, "submodule"},
294294
};
295295

296+
/* This tree contains a submodule with an all-zero commit for a submodule named 'submodule' */
296297
cl_git_pass(git_oid_fromstr(&baseline_id, "396c7f1adb7925f51ba13a75f48252f44c5a14a2"));
297298
cl_git_pass(git_tree_lookup(&baseline, g_repo, &baseline_id));
298299
cl_git_pass(git_tree_create_updated(&updated_tree_id, g_repo, baseline, 1, updates));

0 commit comments

Comments
 (0)