From e6a0cfaad5365a129def0b348103233372a8fe49 Mon Sep 17 00:00:00 2001 From: Justin Schell Date: Mon, 6 Dec 2021 02:27:52 +0100 Subject: 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 --- lisp/vc/vc-git.el | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'lisp/vc/vc-git.el') 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) -- cgit v1.2.3