Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,9 @@ For example:
<img src="./magit-revision-buffer.png" width="400" alt="magit-revision buffer demo">

Here one can get a link to:
- The commit by calling `git-link-commit` on a commit hash
- A file by calling `git-link` on a filename or within its diff
- The commit by calling `git-link-commit` on a commit hash or anywhere in the
buffer (besides filename or its diff)

### Building Links and Adding Services

Expand Down
8 changes: 6 additions & 2 deletions git-link.el
Original file line number Diff line number Diff line change
Expand Up @@ -951,15 +951,19 @@ Defaults to \"origin\"."
(if (null remote-url)
(message "Remote `%s' not found" remote)

(setq commit (word-at-point))
(when (and (not (string-match-p "[a-fA-F0-9]\\{7,40\\}" (or commit "")))
(derived-mode-p 'magit-revision-mode))
(setq commit (magit-buffer-revision)))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function does not exist for me:

setq: Symbol’s function definition is void: magit-buffer-revision

I'm on Emacs 29.4 with Magit 20241001.2052. We should make sure it works on old versions (assuming this is the problem)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm on Emacs 29.4 with Magit 20241001.2052. We should make sure it works on old versions (assuming this is the problem)

If this function was introduced in later versions and there's no alternative we can call (functionp) for the time being to guard against cases where it does not exist.


(setq remote-info (git-link--parse-remote remote-url)
git-host (car remote-info)
commit (word-at-point)
handler (git-link--handler git-link-commit-remote-alist git-host)
web-host (git-link--web-host git-host))

(cond ((null git-host)
(message "Remote `%s' contains an unsupported URL" remote))
((not (string-match-p "[a-fA-F0-9]\\{7,40\\}" (or commit "")))
((not commit)
(message "Point is not on a commit hash"))
((not (functionp handler))
(message "No handler for %s" git-host))
Expand Down