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

Compute old lines for changed file #26

Open
ruifm opened this issue Jul 7, 2021 · 3 comments
Open

Compute old lines for changed file #26

ruifm opened this issue Jul 7, 2021 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@ruifm
Copy link
Owner

ruifm commented Jul 7, 2021

After #24, it's now possible to generate URLs for changed files.
Unfortunately that is done at the expense of the line numbers which are discarded since on a changed file they no longer make sense. See #21 for further discussion.

It should be possible to parse git diff and compute what the old line numbers were, and use those ones instead of nothing.

@ruifm ruifm added the enhancement New feature or request label Jul 7, 2021
@ruifm ruifm self-assigned this Jul 7, 2021
@williamboman
Copy link
Contributor

I'll try to research how https://github.com/gitkraken/vscode-gitlens does this (if they do it). This doesn't feel like a novel problem, surely someone must've done something similar

@jebaum
Copy link

jebaum commented May 14, 2022

Fugitive's :GBrowse command + vim-rhubarb does this for github. I think vim-rhubarb has nothing really to do with the actual logic of computing the old line numbers, but am not 100% sure since reading complex vimscript gives me a headache.

I think the code to do the old line number computation lives in this ~230 line behemoth of a function: https://github.com/tpope/vim-fugitive/blob/5b62c75238bf04b3156ffe62f821930827de8578/autoload/fugitive.vim#L7251=

Specifically here perhaps?: https://github.com/tpope/vim-fugitive/blob/5b62c75238bf04b3156ffe62f821930827de8578/autoload/fugitive.vim#L7404-L7431=

Looks like it's using git blame somehow to assist with the logic.

stevanmilic pushed a commit to stevanmilic/gitlinker.nvim that referenced this issue Nov 12, 2023
@karasjoh000
Copy link

@ruifm git link does not make sense to use unless it's a commit pushed to remote. My suggestion is to use a config param to allow the git diff line remap to be applied until the latest commit pushed remotely. Depending on whether config specifies to use latest commit or latest remote commit do the diff line remap accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants