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
Ensure the index owner is set. #3173
Ensure the index owner is set. #3173
Conversation
The index returned by `git_merge_trees` should be owned by the repository. Otherwise things like `git_diff_index_to_workdir` will crash when trying to generate a diff with the returned index.
0982908
to
0498608
Compare
@carlosmn This also needs to be backported to all maintenance release lines. |
This doesn't quite feel right. This index is just one of many which happen to not represent the index file. We would still have the same crash if given an index which the a user has created themselves. That is, Rugged::Index.new.diff would crash even like this. IMO this is an issue with the rugged implementation of I think that |
@carlosmn The problem is not in Rugged. If you pass an index that is not associated with a repository to It will come from:
Here, repo will be null. This happens because the index iterator in Anyway, there's three issues here. First, I should be able to diff a workdir with an unowned index without The second issue is that the index returned by The third is that |
Right, so, per your second question: at present only the repository's index has a pointer back to the repo itself (and only it should really need one). So That said, you're absolutely right that you should be able to diff an index that isn't the repository's index. However I don't think these indexes having a pointer back to the repository is necessary. We should plumb the caller's repository up into the diff mechanism, I would think, instead of always assuming that |
Okay, that's fine by me as well. I'll see what needs to be changed and modify this PR accordingly. |
The index returned by
git_merge_trees
should be owned by the repository. Otherwise things likegit_diff_index_to_workdir
will crash when trying to generate a diff with the returned index.Fixes libgit2/rugged#420.