apply: git_apply_to_tree fails to apply patches that add new files#5208
Merged
Conversation
git_apply_to_tree() cannot be used apply patches with new files. An attempt to apply such a patch fails because git_apply_to_tree() tries to remove a non-existing file from an old index. The solution is to modify git_apply_to_tree() to git_index_remove() when the patch states that the modified files is removed.
Member
|
This definitely makes sense and looks correct. We should have a test that exercises this, though. |
Introduce an unit test to validate if git_apply_to_tree() fails when an applied patch adds new files.
Contributor
Author
|
Hi Edward. Could you please check if the test case is okay? It looks okay for me, but maybe I missed something obvious. Thank you. |
ethomson
approved these changes
Aug 27, 2019
Member
|
I added a commit to free the |
Contributor
Author
|
Thank you. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
git_apply_to_tree() cannot be used to apply patches with new files.
An attempt to apply such a patch fails because git_apply_to_tree() tries to
remove a non-existing file from an old index.
The solution is to modify git_apply_to_tree() to git_index_remove() when the
patch states that the modified files is removed.