Repository navigation
Multi-commit-diffing: Catch error when path not in ref - #14988
Merged
Merged
Conversation
sergiou87
approved these changes
Jul 20, 2022
sergiou87
left a comment
Member
There was a problem hiding this comment.
Looks great and works as expected!
✨
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.
Description
For our syntax highlighter, we grab what the a file's contents in the current commit and the commit before to create appropriate highlighting. For the commit to be diffed, we know if a file was added/untracked, modified, or deleted in that commit. For highlighting, we are only interested in modified and deleted; if it is new, there is nothing to highlight. Thus, if a file is new or untracked, we do not try to look for it in the commit before. This works great when comparing only one commit at time.
However, with multi-commit diffing, given a history of A, B, C and we pick a range of B - C, we want to compare changes from B and C against the commit A. If a file is added in B and modified in C, when doing a diff of B..C the status will show modified for that file. Thus, our current logic will attempt to find the file contents of that file in A that do not exist -> resulting in a git error.
This PR returns null if that error is present (which is what the parent method would return if the file status was new or untracked).
Release notes
Notes: no-notes