Function: magit-git-version
magit-git-version is a byte-compiled function defined in magit-git.el.
Signature
(magit-git-version)
Documentation
Return the Git version used for default-directory.
Raise an error if Git cannot be found, if it exits with a non-zero status, or the output does not have the expected format.
Source Code
;; Defined in ~/.emacs.d/elpa/magit-20260411.1452/magit-git.el
(defun magit-git-version ()
"Return the Git version used for `default-directory'.
Raise an error if Git cannot be found, if it exits with a
non-zero status, or the output does not have the expected
format."
(magit--with-refresh-cache default-directory
(let ((host (file-remote-p default-directory)))
(or (cdr (assoc host magit--host-git-version-cache))
(magit--with-temp-process-buffer
;; Unset global arguments for ancient Git versions.
(let* ((magit-git-global-arguments nil)
(status (magit-process-git t "version"))
(output (buffer-string)))
(cond
((not (zerop status))
(display-warning
'magit
(format "%S\n\nRunning \"%s --version\" failed with output:\n\n%s"
(if host
(format "Magit cannot find Git on host %S.\n
Check the value of `magit-remote-git-executable' using
`magit-debug-git-executable' and consult the info node
`(tramp)Remote programs'." host)
"Magit cannot find Git.\n
Check the values of `magit-git-executable' and `exec-path'
using `magit-debug-git-executable'.")
(magit-git-executable)
output)))
((save-match-data
(and (string-match magit--git-version-regexp output)
(let ((version (match-str 1 output)))
(push (cons host version)
magit--host-git-version-cache)
version))))
((error "Unexpected \"%s --version\" output: %S"
(magit-git-executable)
output)))))))))