Skip to content

Multi-commit-diffing: Catch error when path not in ref - #14988

Merged
tidy-dev merged 3 commits into
developmentfrom
path-not-in-ref-catch
Jul 20, 2022
Merged

tidy-dev merged 3 commits into
developmentfrom
path-not-in-ref-catch

Conversation

@tidy-dev

@tidy-dev tidy-dev commented Jul 18, 2022 •

Copy link
Copy Markdown
Contributor

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

@sergiou87 sergiou87 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great and works as expected! :shipit: ✨

@tidy-dev
tidy-dev enabled auto-merge July 20, 2022 13:47
@tidy-dev
tidy-dev merged commit 176971b into development Jul 20, 2022
@tidy-dev
tidy-dev deleted the path-not-in-ref-catch branch July 20, 2022 14:03
@niik niik mentioned this pull request Oct 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants