Skip to content

Commit 3588bca

Browse files
committed
[Issue 30] Allow linking to a different branch.
1 parent fd33c3f commit 3588bca

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)
@@ -819,6 +822,22 @@ shown via annotate in bitbucket."
819822
"annotate"
820823
"src")))
821824

825+
;;;###autoload
826+
(defun git-link-diffrent-branch (branch)
827+
"Invoke `git-link', but with the `branch' name set to a different
828+
branch than the one you're currently working on."
829+
(interactive "P")
830+
(let* ((default-remote-branch-name "main")
831+
(git-link-current-branch-setting git-link-default-branch)
832+
(git-link-default-branch (if branch
833+
(completing-read
834+
(format "Instead of '%s' branch replace with branch: " (git-link--branch))
835+
(magit-list-branch-names))
836+
default-remote-branch-name)))
837+
(setq current-prefix-arg nil)
838+
(call-interactively 'git-link)
839+
(setq git-link-default-branch git-link-current-branch-setting)))
840+
822841
;;;###autoload
823842
(defun git-link (remote start end)
824843
"Create a URL representing the current buffer's location in its

0 commit comments

Comments
 (0)