branch: elpa/git-commit
commit 6e86f36ead29e16a0a10e5e14d061ef8f7c4b947
Author: Jonas Bernoulli <[email protected]>
Commit: Jonas Bernoulli <[email protected]>
magit-git-version>=, magit-git-version<: New functions
If we are forced to use our own version comparison functions
anyway (see previous commit), then we might as well use convenient
specialized ones.
---
lisp/magit-bisect.el | 8 ++++----
lisp/magit-branch.el | 2 +-
lisp/magit-diff.el | 2 +-
lisp/magit-fetch.el | 10 +++++-----
lisp/magit-git.el | 13 +++++++++++--
lisp/magit-sequence.el | 4 ++--
lisp/magit-submodule.el | 4 ++--
lisp/magit-wip.el | 3 +--
8 files changed, 27 insertions(+), 19 deletions(-)
diff --git a/lisp/magit-bisect.el b/lisp/magit-bisect.el
index 337d6e001a..ff2a53b540 100644
--- a/lisp/magit-bisect.el
+++ b/lisp/magit-bisect.el
@@ -65,11 +65,11 @@
["Arguments"
("-n" "Don't checkout commits" "--no-checkout")
("-p" "Follow only first parent of a merge" "--first-parent"
- :if (lambda () (magit--version>= (magit-git-version) "2.29")))
+ :if (lambda () (magit-git-version>= "2.29")))
(6 magit-bisect:--term-old
- :if (lambda () (magit--version>= (magit-git-version) "2.7")))
+ :if (lambda () (magit-git-version>= "2.7")))
(6 magit-bisect:--term-new
- :if (lambda () (magit--version>= (magit-git-version) "2.7")))]
+ :if (lambda () (magit-git-version>= "2.7")))]
["Actions"
("B" "Start" magit-bisect-start)
("s" "Start script" magit-bisect-run)]]
@@ -78,7 +78,7 @@
("B" "Bad" magit-bisect-bad)
("g" "Good" magit-bisect-good)
(6 "m" "Mark" magit-bisect-mark
- :if (lambda () (magit--version>= (magit-git-version) "2.7")))
+ :if (lambda () (magit-git-version>= "2.7")))
("k" "Skip" magit-bisect-skip)
("r" "Reset" magit-bisect-reset)
("s" "Run script" magit-bisect-run)])
diff --git a/lisp/magit-branch.el b/lisp/magit-branch.el
index e567362829..c663eb14bc 100644
--- a/lisp/magit-branch.el
+++ b/lisp/magit-branch.el
@@ -217,7 +217,7 @@ has to be used to view and change branch related variables."
["Arguments"
(7 "-r" "Recurse submodules when checking out an existing branch"
"--recurse-submodules"
- :if (lambda () (magit--version>= (magit-git-version) "2.13")))]
+ :if (lambda () (magit-git-version>= "2.13")))]
["Variables"
:if (lambda ()
(and magit-branch-direct-configure
diff --git a/lisp/magit-diff.el b/lisp/magit-diff.el
index 10c45487e7..b38c17ad98 100644
--- a/lisp/magit-diff.el
+++ b/lisp/magit-diff.el
@@ -2058,7 +2058,7 @@ Staging and applying changes is documented in info node
(when (and (not (equal cmd "merge-tree"))
(pcase (magit-repository-local-get 'diff-ita-kludge-p 'unset)
(`unset
- (let ((val (magit--version>= (magit-git-version) "2.19.0")))
+ (let ((val (magit-git-version>= "2.19.0")))
(magit-repository-local-set 'diff-ita-kludge-p val)
val))
(val val)))
diff --git a/lisp/magit-fetch.el b/lisp/magit-fetch.el
index 432030d1e7..3cbd008dba 100644
--- a/lisp/magit-fetch.el
+++ b/lisp/magit-fetch.el
@@ -190,11 +190,11 @@ with a prefix argument."
(list nil (transient-args 'magit-fetch-modules))))
(if transient
(transient-setup 'magit-fetch-modules)
- (let ((git-version (magit-git-version)))
- (when (version< git-version "2.8.0")
- (when-let ((value (transient-arg-value "--jobs=" args)))
- (message "Dropping --jobs; not supported by Git v%s" git-version)
- (setq args (remove (format "--jobs=%s" value) args)))))
+ (when (magit-git-version< "2.8.0")
+ (when-let ((value (transient-arg-value "--jobs=" args)))
+ (message "Dropping --jobs; not supported by Git v%s"
+ (magit-git-version))
+ (setq args (remove (format "--jobs=%s" value) args))))
(magit-with-toplevel
(magit-run-git-async "fetch" "--recurse-submodules" args))))
diff --git a/lisp/magit-git.el b/lisp/magit-git.el
index ec8bd8a463..80e2e30fc7 100644
--- a/lisp/magit-git.el
+++ b/lisp/magit-git.el
@@ -575,11 +575,20 @@ call function WASHER with ARGS as its sole argument."
(magit-maybe-make-margin-overlay))))
(defun magit-git-version (&optional raw)
+ "Return the installed Git version."
(--when-let (let (magit-git-global-arguments)
(ignore-errors (substring (magit-git-string "version") 12)))
(if raw it (and (string-match "\\`\\([0-9]+\\(\\.[0-9]+\\)\\{1,2\\}\\)" it)
(match-string 1 it)))))
+(defun magit-git-version>= (n)
+ "Return t if `magit-git-version's value is greater than or equal to N."
+ (magit--version>= (magit-git-version) n))
+
+(defun magit-git-version< (n)
+ "Return t if `magit-git-version's value is smaller than N."
+ (version< (magit-git-version) n))
+
;;; Variables
(defun magit-config-get-from-cached-list (key)
@@ -1199,7 +1208,7 @@ ref that should have been excluded, then that is
discarded and
this function returns nil instead. This is unfortunate because
there might be other refs that do match. To fix that, update
Git."
- (if (version< (magit-git-version) "2.13")
+ (if (magit-git-version< "2.13")
(when-let
((ref (magit-git-string "name-rev" "--name-only" "--no-undefined"
(and pattern (concat "--refs=" pattern))
@@ -2163,7 +2172,7 @@ and this option only controls what face is used.")
(defun magit-update-ref (ref message rev &optional stashish)
(let ((magit--refresh-cache nil))
- (or (if (magit--version>= (magit-git-version) "2.6.0")
+ (or (if (magit-git-version>= "2.6.0")
(zerop (magit-call-git "update-ref" "--create-reflog"
"-m" message ref rev
(or (magit-rev-verify ref) "")))
diff --git a/lisp/magit-sequence.el b/lisp/magit-sequence.el
index a860425379..44b7bc3737 100644
--- a/lisp/magit-sequence.el
+++ b/lisp/magit-sequence.el
@@ -515,10 +515,10 @@ This discards all changes made since the sequence
started."
:if-not magit-rebase-in-progress-p
("-k" "Keep empty commits" "--keep-empty")
("-p" "Preserve merges" ("-p" "--preserve-merges")
- :if (lambda () (version< (magit-git-version) "2.33.0")))
+ :if (lambda () (magit-git-version< "2.33.0")))
("-r" "Rebase merges" ("-r" "--rebase-merges=")
magit-rebase-merges-select-mode
- :if (lambda () (magit--version>= (magit-git-version) "2.18.0")))
+ :if (lambda () (magit-git-version>= "2.18.0")))
(7 magit-merge:--strategy)
(7 magit-merge:--strategy-option)
(7 "=X" magit-diff:--diff-algorithm :argument "-Xdiff-algorithm=")
diff --git a/lisp/magit-submodule.el b/lisp/magit-submodule.el
index a985272116..b14266197d 100644
--- a/lisp/magit-submodule.el
+++ b/lisp/magit-submodule.el
@@ -225,7 +225,7 @@ it is nil, then PATH also becomes the name."
(magit-process-sentinel process event)
(process-put process 'inhibit-refresh t)
(magit-process-sentinel process event)
- (when (magit--version>= (magit-git-version) "2.12.0")
+ (when (magit-git-version>= "2.12.0")
(magit-call-git "submodule" "absorbgitdirs" path))
(magit-refresh)))))))
@@ -360,7 +360,7 @@ to recover from making a mistake here, but don't count on
it."
(list (magit-read-module-path "Remove module")))
(magit-submodule-arguments "--force")
current-prefix-arg))
- (when (version< (magit-git-version) "2.12.0")
+ (when (magit-git-version< "2.12.0")
(error "This command requires Git v2.12.0"))
(when magit-submodule-remove-trash-gitdirs
(setq trash-gitdirs t))
diff --git a/lisp/magit-wip.el b/lisp/magit-wip.el
index 1b59702f59..7f42b573d7 100644
--- a/lisp/magit-wip.el
+++ b/lisp/magit-wip.el
@@ -304,8 +304,7 @@ commit message."
(and (pcase (magit-repository-local-get
'update-index-has-ignore-sw-p 'unset)
(`unset
- (let ((val (magit--version>=
(magit-git-version)
- "2.25.0")))
+ (let ((val (magit-git-version>= "2.25.0")))
(magit-repository-local-set
'update-index-has-ignore-sw-p val)
val))