Skip to content

Commit 503a4d7

Browse files
committed
[Issue 30] Allow linking to a different branch.
1 parent e4cfed0 commit 503a4d7

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

git-link.el

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@
3535

3636
;;; Change Log:
3737

38+
;; 2024-11-03 - v0.9.3
39+
;; * Add support for linking to a different branch with git-link-diffrent-branch (@dotemacs)
40+
;;
3841
;; 2024-06-29 - v0.9.2
3942
;; * Add git-link-add-to-kill-ring to not add to kill ring (thanks Michael Hauser-Raspe)
4043
;; * Add prefix arg to open in browser when calling git-link-homepage (thanks Sibi Prabakaran)
@@ -852,6 +855,22 @@ shown via annotate in bitbucket."
852855
"annotate"
853856
"src")))
854857

858+
;;;###autoload
859+
(defun git-link-diffrent-branch (branch)
860+
"Invoke `git-link', but with the `branch' name set to a different
861+
branch than the one you're currently working on."
862+
(interactive "P")
863+
(let* ((default-remote-branch-name "main")
864+
(git-link-current-branch-setting git-link-default-branch)
865+
(git-link-default-branch (if branch
866+
(completing-read
867+
(format "Instead of '%s' branch replace with branch: " (git-link--branch))
868+
(magit-list-branch-names))
869+
default-remote-branch-name)))
870+
(setq current-prefix-arg nil)
871+
(call-interactively 'git-link)
872+
(setq git-link-default-branch git-link-current-branch-setting)))
873+
855874
;;;###autoload
856875
(defun git-link (remote start end)
857876
"Create a URL representing the current buffer's location in its

0 commit comments

Comments
 (0)