Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tree: accept null ids in existing trees when updating #4727

Merged
merged 2 commits into from
Aug 26, 2018

Conversation

carlosmn
Copy link
Member

When we add entries to a treebuilder we validate them. But we validate even
those that we're adding because they exist in the base tree. This disables
using the normal mechanisms on these trees, even to fix them.

Keep track of whether the entry we're appending comes from an existing tree and
bypass the name and id validation if it's from existing data.

When we add entries to a treebuilder we validate them. But we validate even
those that we're adding because they exist in the base tree. This disables
using the normal mechanisms on these trees, even to fix them.

Keep track of whether the entry we're appending comes from an existing tree and
bypass the name and id validation if it's from existing data.
@carlosmn
Copy link
Member Author

This would be one for backporting into a maintenance release.

src/tree.c Outdated
@@ -447,15 +447,16 @@ static int append_entry(
git_treebuilder *bld,
const char *filename,
const git_oid *id,
git_filemode_t filemode)
git_filemode_t filemode,
bool from_tree)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was misreading this commit the whole time, as I first misinterpreted the from_tree parameter to mean the exact opposite thing. I think this would be a bit easier to reason about if this was instead called validate, with the value passed by callers being the inverse from what it is now.

@@ -284,3 +284,18 @@ void test_object_tree_update__add_conflict2(void)

cl_git_fail(git_tree_create_updated(&tree_updater_id, g_repo, NULL, 2, updates));
}

void test_object_tree_update__remove_invalid_submodule(void)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please add a small comment detailing what is so special about the tree 396c7f1? It's rather hard to reason about this test otherwise :)

@carlosmn
Copy link
Member Author

Updated from @pks-t 's feedback

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants