Function: magit-copy-buffer-revision
magit-copy-buffer-revision is an autoloaded, interactive and
byte-compiled function defined in magit-extras.el.
Signature
(magit-copy-buffer-revision)
Documentation
Save the revision of the current buffer for later use.
Save the revision shown in the current buffer to the kill-ring
and push it to the magit-revision-stack.
This command is mainly intended for use in magit-revision-mode
buffers, the only buffers where it is always unambiguous exactly
which revision should be saved.
Most other Magit buffers usually show more than one revision, in some way or another, so this command has to select one of them, and that choice might not always be the one you think would have been the best pick.
In such buffers it is often more useful to save the value of
the current section instead, using magit-copy-section-value.
When the region is active, then save that to the kill-ring,
like kill-ring-save would, instead of behaving as described
above.
When magit-copy-revision-abbreviated is non-nil, save the
abbreviated revision to the kill-ring and the
magit-revision-stack.
Key Bindings
Source Code
;; Defined in ~/.emacs.d/elpa/magit-20260411.1452/magit-extras.el
;;;###autoload
(defun magit-copy-buffer-revision ()
"Save the revision of the current buffer for later use.
Save the revision shown in the current buffer to the `kill-ring'
and push it to the `magit-revision-stack'.
This command is mainly intended for use in `magit-revision-mode'
buffers, the only buffers where it is always unambiguous exactly
which revision should be saved.
Most other Magit buffers usually show more than one revision, in
some way or another, so this command has to select one of them,
and that choice might not always be the one you think would have
been the best pick.
In such buffers it is often more useful to save the value of
the current section instead, using `magit-copy-section-value'.
When the region is active, then save that to the `kill-ring',
like `kill-ring-save' would, instead of behaving as described
above.
When `magit-copy-revision-abbreviated' is non-nil, save the
abbreviated revision to the `kill-ring' and the
`magit-revision-stack'."
(interactive)
(cond-let*
((use-region-p)
(call-interactively #'copy-region-as-kill))
([rev (or magit-buffer-revision
(cl-case major-mode
(magit-diff-mode
(if (string-match "\\.\\.\\.?\\(.+\\)"
magit-buffer-diff-range)
(match-str 1 magit-buffer-diff-range)
magit-buffer-diff-range))
(magit-status-mode "HEAD")))]
[_(magit-commit-p rev)]
(setq rev (magit-rev-parse
(and magit-copy-revision-abbreviated "--short")
rev))
(push (list rev default-directory) magit-revision-stack)
(kill-new (message "%s" rev)))))