sshaw / git-link

Emacs package to get the GitHub/Bitbucket/GitLab/... URL for a buffer location
399 stars 74 forks source link

not working for files in an auxiliary worktree (using git-worktree) #86

Open edgimar opened 3 years ago

edgimar commented 3 years ago

Given a git repository contained in the folder foo, if (from this folder) the command git worktree add ../foo-worktree-otherbranch otherbranch is executed, a worktree will be created for the otherbranch branch in the folder ../foo-worktree-otherbranch (relative to the foo folder).

When editing a file within the foo-worktree-otherbranch folder, and attempting to use git-link, the error Remote 'origin' not found occurs. Instead, git-link should be able to correctly identify the remote and branch. In the particular case this was tested under, the foo repository didn't even have an origin remote (but did have other remotes).

sshaw commented 3 years ago

Instead, git-link should be able to correctly identify the remote and branch.

How to do that?

In the particular case this was tested under, the foo repository didn't even have an origin remote (but did have other remotes).

If git-link-default-remote nor git-link.remote are set, some place in the code will default to origin.

sshaw commented 3 years ago

Closing . If the above git-link* options do not work for you feel free to reopen.

edgimar commented 3 years ago

Ok thanks for the information - I believe that the problem has something to do with git-link not being able to determine what the upstream repository and tracked branch is in the case when a "git-worktree" branch is being used. If I have more time to investigate, and find out anything more specific, I'll reopen.

bergey commented 2 years ago

FWIW, I routinely use git-link with worktrees. It reliably finds the branch I am on. Since my remote is called origin, I would not have observed any issue determining the remote.