git-link
git-link copied to clipboard
What should git-link do when the current local branch has commits that haven't been pushed yet?
Hi @sshaw! First off, thanks (again) for writing and maintaining git-link all these years. It's great!
Sometimes I use git-link when I have commits in my local clone that haven't been pushed to the remote yet. git-link happily generates a link with the local head commit, but that link obviously doesn't work, at least not until the local commits get pushed.
Fixing this to use the remote's head commit could be pretty easy, we'd just add something like "--remotes=" (git-link--remote) to git-link--last-commit:
https://github.com/sshaw/git-link/blob/40f7b1674d2c703199ff2f82b464f17aa6f61b4b/git-link.el#L333-L334
...but the local commits may have changed the current file such that current point or region won't be the same thing in the remote's head commit.
Any idea what we should do?
Thanks in advance!
One easy dumb answer here could be to just add an option, default off, to let users generate these possibly-wrong links. If the user turns it on, they accept the risk.
When this happens to me, the line(s) I want to link to usually haven't been changed by the local commits, and if they have, I'm ok with either checking or getting a wrong link.
Hi, definitely experienced this problem myself :/ Not sure if there's a single solution since link generation time is not always the same as link share/link access time. Some ideas:
- Emit a warning when commit for the linked thing has not been pushed. This would go to
*Messages*and likely would go unnoticed at generation time so, not really a solution but a "good measure" - Have an option
git-link-commit-exists-at-remote-checkwhentprompt if remote does not match local:Latest commit has not been pushed to REMOTE. Use it or use REMOTE's latest - Have an option
git-link-commit-exists-at-remote-preference(or similar) that instructs the package what to do::localto use local regardless or:remoteto fallback to remote in this case
Thoughts?
Personally, I'd like to always use remote, so I'd go for the third option here. I don't know if I'm representative though, and worst case I'm sure I can always advise it to do whatever I want, so don't lean on me too much.
Hi, the third option sounds good. If you can come through with a PR that'd be: amaaaaaaazing 💪
Great! I'll see if I can find time at some point.