fix: resolve Git repo root from CWD when possible#118
Merged
dlvhdr merged 1 commit intodlvhdr:mainfrom Apr 4, 2026
Merged
Conversation
This information is then used to construct absolute paths for the "openInEditor" functionality. This allows paths to be correctly resolved even if you launch diffnav from somewhere *under* the repo root, instead of at it. If you use diffnav outside of a repo root entirely, or the diff chunk somehow belongs to another repo or no repo at all, editors will still be unable to resolve the path given to them.
Owner
|
thank you! |
dlvhdr
approved these changes
Apr 4, 2026
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.
This information is then used to construct absolute paths for the "openInEditor" functionality.
This allows paths to be correctly resolved even if you launch diffnav from somewhere under the repo root, instead of at it.
Important limitation: If you use diffnav outside of a repo root entirely, or the diff chunk somehow belongs to another repo or no repo at all, editors will still be unable to resolve the path given to them.
There's not really a (sane) way to resolve the absolute path from an arbitrary relative path with no extra information.
The repo root information fetched at startup could also be used to (partially?) saturate the header in cases where it normally wouldn't be shown (I believe its only shown when the input diff has some kind of commit preamble). This is not contained in this PR, though.
Summary
How Did You Test this Change?
Open diffnav from inside the repository (not at the repo root), and then try to open any of the files using the 'o' shortcut.
Before: whatever your editor decides to do with a path that doesn't exist, most open a buffer with the path as the write target.
After: actually opens the file.