Skip to content

Commit eaf7583

Browse files
committed
Use magit to determine primary branch and local branches.
1 parent 503a4d7 commit eaf7583

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

git-link.el

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -856,16 +856,18 @@ shown via annotate in bitbucket."
856856
"src")))
857857

858858
;;;###autoload
859-
(defun git-link-diffrent-branch (branch)
859+
(defun git-link-different-branch (branch)
860860
"Invoke `git-link', but with the `branch' name set to a different
861861
branch than the one you're currently working on."
862862
(interactive "P")
863-
(let* ((default-remote-branch-name "main")
863+
(let* ((default-remote-branch-name (magit-main-branch))
864864
(git-link-current-branch-setting git-link-default-branch)
865865
(git-link-default-branch (if branch
866866
(completing-read
867867
(format "Instead of '%s' branch replace with branch: " (git-link--branch))
868-
(magit-list-branch-names))
868+
(mapcar (lambda (branch)
869+
(replace-regexp-in-string "^refs/heads/" "" branch))
870+
(magit-list-local-branches)))
869871
default-remote-branch-name)))
870872
(setq current-prefix-arg nil)
871873
(call-interactively 'git-link)

0 commit comments

Comments
 (0)