Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🚀 Transform file paths to be relative to current directory #552

Closed
dandavison opened this issue Mar 28, 2021 · 3 comments · Fixed by #565
Closed

🚀 Transform file paths to be relative to current directory #552

dandavison opened this issue Mar 28, 2021 · 3 comments · Fixed by #565

Comments

@dandavison
Copy link
Owner

Git outputs file paths in various contexts (e.g. hunk headers, --stat output) but if you are not in the root directory of your repository these paths will not be valid as relative paths from your location. This can be annoying, for example the following workflows fail:

  • Copy the relative path and try to open it from the command line using something like vim, open, bat, code, emacsclient, etc
  • Command-click on the relative path in something like VS Code terminal

Since every line of git output is passing through delta, delta could relativize these paths thus making those workflows succeed.

@dandavison
Copy link
Owner Author

Ah, of course, git has an option for this: I need to start adding --relative to my git aliases!

@dandavison
Copy link
Owner Author

--relative seems potentially dangerous: e.g. --relative commands do not show changes to files outside the subtree rooted at $PWD, so you might make incorrect decisions about a commit if you view it that way. So perhaps this does make sense for delta to do.

@dandavison dandavison reopened this Apr 2, 2021
@dandavison
Copy link
Owner Author

It looks like git's pager process runs with cwd set to the repo root, but that the path that git was invoked from, relative to repo root, is available in the env var GIT_PREFIX. (As an be seen by doing e.g. git -c core.pager=env show)

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 a pull request may close this issue.

1 participant