[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/git-commit 489f84a3d6 7/9: magit--safe-git-version: New fu
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/git-commit 489f84a3d6 7/9: magit--safe-git-version: New function |
Date: |
Tue, 22 Feb 2022 05:58:10 -0500 (EST) |
branch: elpa/git-commit
commit 489f84a3d6eb7944b719cb1bcdc553ea2ad46a9d
Author: Jonas Bernoulli <jonas@bernoul.li>
Commit: Jonas Bernoulli <jonas@bernoul.li>
magit--safe-git-version: New function
Instead of using `magit-git-version' and hacking around that wanting
to report verbosely on any issues, add a new function for when we want
to be quiet about it.
`magit-version' now is more verbose and precise about why the Git
version cannot be determined.
---
lisp/magit-git.el | 25 +++++++++++++++++--------
lisp/magit-utils.el | 3 +++
lisp/magit.el | 10 +---------
3 files changed, 21 insertions(+), 17 deletions(-)
diff --git a/lisp/magit-git.el b/lisp/magit-git.el
index 3e0c7be1c4..a81c77bcdd 100644
--- a/lisp/magit-git.el
+++ b/lisp/magit-git.el
@@ -576,6 +576,9 @@ call function WASHER with ARGS as its sole argument."
;;; Git Version
+(defconst magit--git-version-regexp
+ "\\`git version \\([0-9]+\\(\\.[0-9]+\\)\\{1,2\\}\\)")
+
(defvar magit--remotes-using-recent-git nil)
(defun magit-git-version (&optional raw)
@@ -593,6 +596,18 @@ call function WASHER with ARGS as its sole argument."
"Return t if `magit-git-version's value is smaller than N."
(version< (magit-git-version) n))
+(defun magit--safe-git-version ()
+ "Return the Git version used for `default-directory' or an error message."
+ (magit--with-temp-process-buffer
+ (let* ((magit-git-global-arguments nil)
+ (status (magit-process-git t "version"))
+ (output (buffer-string)))
+ (cond ((not (zerop status)) output)
+ ((save-match-data
+ (and (string-match magit--git-version-regexp output)
+ (match-string 1 output))))
+ (t output)))))
+
(defun magit-debug-git-executable ()
"Display a buffer with information about `magit-git-executable'.
Also include information about `magit-remote-git-executable'.
@@ -607,10 +622,7 @@ See info node `(magit)Debugging Tools' for more
information."
(format "magit-git-executable: %S" magit-git-executable)
(and (not (file-name-absolute-p magit-git-executable))
(format " [%S]" (executable-find magit-git-executable)))
- (format " (%s)\n"
- (let* ((errmsg nil)
- (magit-git-debug (lambda (err) (setq errmsg err))))
- (or (magit-git-version t) errmsg)))))
+ (format " (%s)\n" (magit--safe-git-version))))
(insert (format "exec-path: %S\n" exec-path))
(--when-let (cl-set-difference
(-filter #'file-exists-p (remq nil (parse-colon-path
@@ -625,10 +637,7 @@ See info node `(magit)Debugging Tools' for more
information."
execdir t (concat
"\\`git" (regexp-opt exec-suffixes) "\\'")))
(insert (format " %s (%s)\n" exec
- (let* ((magit-git-executable exec)
- (errmsg nil)
- (magit-git-debug (lambda (err) (setq errmsg
err))))
- (or (magit-git-version t) errmsg)))))))))
+ (magit--safe-git-version))))))))
;;; Variables
diff --git a/lisp/magit-utils.el b/lisp/magit-utils.el
index 1afb2402dd..f44926e6ac 100644
--- a/lisp/magit-utils.el
+++ b/lisp/magit-utils.el
@@ -40,6 +40,9 @@
;;; Code:
+(defconst magit--minimal-git "2.2.0")
+(defconst magit--minimal-emacs "25.1")
+
(require 'cl-lib)
(require 'dash)
(require 'eieio)
diff --git a/lisp/magit.el b/lisp/magit.el
index 9a6401ee1f..5ee9a44907 100644
--- a/lisp/magit.el
+++ b/lisp/magit.el
@@ -65,9 +65,6 @@
(require 'package nil t) ; used in `magit-version'
(require 'with-editor)
-(defconst magit--minimal-git "2.2.0")
-(defconst magit--minimal-emacs "25.1")
-
;;; Faces
(defface magit-header-line
@@ -587,12 +584,7 @@ and Emacs to it."
(locate-library "magit.el" t))
(lm-header "Package-Version"))))))
"")
- (or (let ((magit-git-debug
- (lambda (err)
- (display-warning '(magit git)
- err :error))))
- (magit-git-version t))
- "(unknown)")
+ (magit--safe-git-version)
emacs-version
system-type)
print-dest))
- [nongnu] elpa/git-commit updated (68be0584f4 -> 9b94654921), ELPA Syncer, 2022/02/22
- [nongnu] elpa/git-commit 4d59e1cafd 5/9: magit-zap-caches: Also zap magit--remotes-using-recent-git, ELPA Syncer, 2022/02/22
- [nongnu] elpa/git-commit 8394f0d4ea 8/9: Refactor git version asserts, ELPA Syncer, 2022/02/22
- [nongnu] elpa/git-commit 477603835b 6/9: magit-debug-git-executable: Move definition to magit-git.el, ELPA Syncer, 2022/02/22
- [nongnu] elpa/git-commit 69be963b62 2/9: magit-startup-asserts: Remove special case for Travis, ELPA Syncer, 2022/02/22
- [nongnu] elpa/git-commit 489f84a3d6 7/9: magit--safe-git-version: New function,
ELPA Syncer <=
- [nongnu] elpa/git-commit 6c4ff54a08 3/9: magit-startup-asserts: Don't check Git version when building Magit, ELPA Syncer, 2022/02/22
- [nongnu] elpa/git-commit 9b94654921 9/9: Remove redundant version/feature caches, ELPA Syncer, 2022/02/22
- [nongnu] elpa/git-commit 18728adc76 4/9: magit-zap-caches: With a prefix discard complete caches, ELPA Syncer, 2022/02/22
- [nongnu] elpa/git-commit d5ed87b138 1/9: magit-margin-default-time-format: New un-advertised variable, ELPA Syncer, 2022/02/22