Commit f00db9ed by Carlos Martín Nieto

tree: rename from_tree to validate and clarify the tree in the test

parent 2dff7e28
......@@ -448,15 +448,15 @@ static int append_entry(
const char *filename,
const git_oid *id,
git_filemode_t filemode,
bool from_tree)
bool validate)
{
git_tree_entry *entry;
int error = 0;
if (!from_tree && !valid_entry_name(bld->repo, filename))
if (validate && !valid_entry_name(bld->repo, filename))
return tree_error("failed to insert entry: invalid name for a tree entry", filename);
if (!from_tree && git_oid_iszero(id))
if (validate && git_oid_iszero(id))
return tree_error("failed to insert entry: invalid null OID for a tree entry", filename);
entry = alloc_entry(filename, strlen(filename), id);
......@@ -554,12 +554,12 @@ static int write_tree(
last_comp = subdir;
}
error = append_entry(bld, last_comp, &sub_oid, S_IFDIR, false);
error = append_entry(bld, last_comp, &sub_oid, S_IFDIR, true);
git__free(subdir);
if (error < 0)
goto on_error;
} else {
error = append_entry(bld, filename, &entry->id, entry->mode, false);
error = append_entry(bld, filename, &entry->id, entry->mode, true);
if (error < 0)
goto on_error;
}
......@@ -658,7 +658,7 @@ int git_treebuilder_new(
bld, entry_src->filename,
entry_src->oid,
entry_src->attr,
true) < 0)
false) < 0)
goto on_error;
}
}
......
......@@ -293,6 +293,7 @@ void test_object_tree_update__remove_invalid_submodule(void)
{GIT_TREE_UPDATE_REMOVE, {{0}}, GIT_FILEMODE_BLOB, "submodule"},
};
/* This tree contains a submodule with an all-zero commit for a submodule named 'submodule' */
cl_git_pass(git_oid_fromstr(&baseline_id, "396c7f1adb7925f51ba13a75f48252f44c5a14a2"));
cl_git_pass(git_tree_lookup(&baseline, g_repo, &baseline_id));
cl_git_pass(git_tree_create_updated(&updated_tree_id, g_repo, baseline, 1, updates));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment