-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Conversation
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.
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) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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 :)
Updated from @pks-t 's feedback |
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.