Skip to content

fix: resolve Git repo root from CWD when possible#118

Merged
dlvhdr merged 1 commit intodlvhdr:mainfrom
flonle:main
Apr 4, 2026
Merged

fix: resolve Git repo root from CWD when possible#118
dlvhdr merged 1 commit intodlvhdr:mainfrom
flonle:main

Conversation

@flonle
Copy link
Copy Markdown
Contributor

@flonle flonle commented Mar 30, 2026

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.

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.
@dlvhdr
Copy link
Copy Markdown
Owner

dlvhdr commented Apr 4, 2026

thank you!

@dlvhdr dlvhdr merged commit 5f77725 into dlvhdr:main Apr 4, 2026
3 checks passed
@dlvhdr dlvhdr changed the title Resolve Git repo root from CWD when possible. fix: resolve Git repo root from CWD when possible Apr 4, 2026
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