summaryrefslogtreecommitdiff
path: root/lisp/vc/vc-git.el
diff options
context:
space:
mode:
authorJustin Schell <justinmschell@gmail.com>2021-12-06 02:27:52 +0100
committerLars Ingebrigtsen <larsi@gnus.org>2021-12-06 02:27:52 +0100
commite6a0cfaad5365a129def0b348103233372a8fe49 (patch)
tree7989b777df8ba8306fe1646cbd7b9e5eacc89122 /lisp/vc/vc-git.el
parent2454f9876d647453d5e0d8e4aa2260f9254978c8 (diff)
downloademacs-e6a0cfaad5365a129def0b348103233372a8fe49.tar.gz
emacs-e6a0cfaad5365a129def0b348103233372a8fe49.tar.bz2
emacs-e6a0cfaad5365a129def0b348103233372a8fe49.zip
vc-git--program-version to support Git for macOS version string
`git version` on macOS returns e.g., "git version 2.30.1 (Apple Git-130)" and `vc-git--program-version` currently returns "0" instead of "2.30.1". * lisp/vc/vc-git.el (vc-git--program-version): Ignore text after the version number when parsing git versions (bug#52172). Copyright-paperwork-exempt: yes
Diffstat (limited to 'lisp/vc/vc-git.el')
-rw-r--r--lisp/vc/vc-git.el14
1 files changed, 8 insertions, 6 deletions
diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
index 4b6cd930744..08282647eb0 100644
--- a/lisp/vc/vc-git.el
+++ b/lisp/vc/vc-git.el
@@ -298,12 +298,14 @@ included in the completions."
(vc-git--run-command-string nil "version")))
(setq vc-git--program-version
(if (and version-string
- ;; Git for Windows appends ".windows.N" to the
- ;; numerical version reported by Git.
- (string-match
- "git version \\([0-9.]+\\)\\(\\.windows\\.[0-9]+\\)?$"
- version-string))
- (match-string 1 version-string)
+ ;; Some Git versions append additional strings
+ ;; to the numerical version string. E.g., Git
+ ;; for Windows appends ".windows.N", while Git
+ ;; for Mac appends " (Apple Git-N)". Capture
+ ;; numerical version and ignore the rest.
+ (string-match "git version \\([0-9][0-9.]+\\)"
+ version-string))
+ (string-trim-right (match-string 1 version-string) "\\.")
"0")))))
(defun vc-git--git-status-to-vc-state (code-list)