Fix how Diff handles commits that contain submodule changes #947
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.
This PR addresses the issue reported in #891
The problem was that
Diff
was receiving the parentRepo
but commit hashes from the submodule repo, resulting inDiff
being unable to find the commits. This was due to the output ofgit diff-tree <parent_commit_1> <parent_commit_2>
containing the hashes from the submodule:This implementation fixes that issue by comparing the
a_rawpath
to all of the repo's submodulepath
s and overwritingrepo
to the submodule's repo if there's a match. If there are ideas concerning a more efficient way to identify this situation I'm more than happy to entertain other approaches.The test added by this PR is based off of the repro provided in #891. While it's a great repro case I don't feel like it's a particularly elegant test so I'm open to suggestions there as well.
Fixed a typo in a comment in
cmd.py
and resolved a deprecation warning within thetest_diff.py
file while I was in there. I also addedgit submodule update --init --recursive
toinit-tests-after-clone.sh
because there are a decent number of tests that fail withoutgitdb
andsmmap
cloned.