emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/git-commit c8c2efd014 1/2: Define version> and version>= b


From: ELPA Syncer
Subject: [nongnu] elpa/git-commit c8c2efd014 1/2: Define version> and version>= but sadly with our prefix
Date: Tue, 11 Jan 2022 05:58:12 -0500 (EST)

branch: elpa/git-commit
commit c8c2efd0141186c5808541d6844b58b876a1d81b
Author: Jonas Bernoulli <jonas@bernoul.li>
Commit: Jonas Bernoulli <jonas@bernoul.li>

    Define version> and version>= but sadly with our prefix
    
    My brain is too small to always get yoda conditions right, while the
    Emacs maintainers have huge brains and as a consequence have rejected
    the addition of these functions on grounds of them being unnecessary.
    I don't want to make such mistakes anymore, so I am forced to define
    these functions myself.
---
 lisp/magit-bisect.el    |  8 ++++----
 lisp/magit-branch.el    |  2 +-
 lisp/magit-diff.el      |  2 +-
 lisp/magit-git.el       |  2 +-
 lisp/magit-sequence.el  |  2 +-
 lisp/magit-status.el    |  2 +-
 lisp/magit-submodule.el |  2 +-
 lisp/magit-utils.el     | 12 +++++++++++-
 lisp/magit-wip.el       |  4 ++--
 lisp/magit.el           |  3 ++-
 10 files changed, 25 insertions(+), 14 deletions(-)

diff --git a/lisp/magit-bisect.el b/lisp/magit-bisect.el
index 1b62b0a0c6..337d6e001a 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 () (version<= "2.29" (magit-git-version))))
+     :if (lambda () (magit--version>= (magit-git-version) "2.29")))
     (6 magit-bisect:--term-old
-       :if (lambda () (version<= "2.7" (magit-git-version))))
+       :if (lambda () (magit--version>= (magit-git-version) "2.7")))
     (6 magit-bisect:--term-new
-       :if (lambda () (version<= "2.7" (magit-git-version))))]
+       :if (lambda () (magit--version>= (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 () (version<= "2.7" (magit-git-version))))
+      :if (lambda () (magit--version>= (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 d3db6774b7..e567362829 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 () (version<= "2.13" (magit-git-version))))]
+      :if (lambda () (magit--version>= (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 9a128db0f2..10c45487e7 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 (version<= "2.19.0" (magit-git-version))))
+                  (let ((val (magit--version>= (magit-git-version) "2.19.0")))
                     (magit-repository-local-set 'diff-ita-kludge-p val)
                     val))
                  (val val)))
diff --git a/lisp/magit-git.el b/lisp/magit-git.el
index f18a9062ef..ec8bd8a463 100644
--- a/lisp/magit-git.el
+++ b/lisp/magit-git.el
@@ -2163,7 +2163,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 (not (version< (magit-git-version) "2.6.0"))
+    (or (if (magit--version>= (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 c1c87a8e7a..a860425379 100644
--- a/lisp/magit-sequence.el
+++ b/lisp/magit-sequence.el
@@ -518,7 +518,7 @@ This discards all changes made since the sequence started."
     :if (lambda () (version< (magit-git-version) "2.33.0")))
    ("-r" "Rebase merges"            ("-r" "--rebase-merges=")
     magit-rebase-merges-select-mode
-    :if-not (lambda () (version< (magit-git-version) "2.18.0")))
+    :if (lambda () (magit--version>= (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-status.el b/lisp/magit-status.el
index f404843526..eed0dcd295 100644
--- a/lisp/magit-status.el
+++ b/lisp/magit-status.el
@@ -340,7 +340,7 @@ init file: (global-set-key (kbd \"C-x g\") 
'magit-status-quick)."
     (unless (member remote magit--remotes-using-recent-git)
       (if-let ((version (let ((default-directory directory))
                           (magit-git-version))))
-          (if (version<= magit--minimal-git version)
+          (if (magit--version>= version magit--minimal-git)
               (push remote magit--remotes-using-recent-git)
             (display-warning 'magit (format "\
 Magit requires Git >= %s, but on %s the version is %s.
diff --git a/lisp/magit-submodule.el b/lisp/magit-submodule.el
index f14337a2d8..a985272116 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)
-           (unless (version< (magit-git-version) "2.12.0")
+           (when (magit--version>= (magit-git-version) "2.12.0")
              (magit-call-git "submodule" "absorbgitdirs" path))
            (magit-refresh)))))))
 
diff --git a/lisp/magit-utils.el b/lisp/magit-utils.el
index 29730dead0..473b70416d 100644
--- a/lisp/magit-utils.el
+++ b/lisp/magit-utils.el
@@ -1010,6 +1010,16 @@ one trailing newline is added."
                 (and (eq trim ?\n) "\n"))
       str)))
 
+(defun magit--version> (v1 v2)
+  "Return t if version V1 is higher (younger) than V2.
+This function should be named `version>' and be part of Emacs."
+  (version-list-< (version-to-list v2) (version-to-list v1)))
+
+(defun magit--version>= (v1 v2)
+  "Return t if version V1 is higher (younger) than or equal to V2.
+This function should be named `version>=' and be part of Emacs."
+  (version-list-<= (version-to-list v2) (version-to-list v1)))
+
 ;;; Kludges for Emacs Bugs
 
 (defun magit-file-accessible-directory-p (filename)
@@ -1019,7 +1029,7 @@ and https://github.com/magit/magit/issues/2295.";
   (and (file-directory-p filename)
        (file-accessible-directory-p filename)))
 
-(when (version<= "25.1" emacs-version)
+(when (magit--version>= emacs-version "25.1")
   (with-eval-after-load 'vc-git
     (defun vc-git-conflicted-files (directory)
       "Return the list of files with conflicts in DIRECTORY."
diff --git a/lisp/magit-wip.el b/lisp/magit-wip.el
index 70952a5c1c..1b59702f59 100644
--- a/lisp/magit-wip.el
+++ b/lisp/magit-wip.el
@@ -304,8 +304,8 @@ commit message."
                         (and (pcase (magit-repository-local-get
                                      'update-index-has-ignore-sw-p 'unset)
                                (`unset
-                                (let ((val (version<= "2.25.0"
-                                                      (magit-git-version))))
+                                (let ((val (magit--version>= 
(magit-git-version)
+                                                             "2.25.0")))
                                   (magit-repository-local-set
                                    'update-index-has-ignore-sw-p val)
                                   val))
diff --git a/lisp/magit.el b/lisp/magit.el
index 767f57d7d2..83cba08406 100644
--- a/lisp/magit.el
+++ b/lisp/magit.el
@@ -567,7 +567,8 @@ and Emacs to it."
         (when print-dest
           (princ (format "Magit %s%s, Git %s, Emacs %s, %s"
                          (or magit-version "(unknown)")
-                         (or (and (ignore-errors (version< "2008" 
magit-version))
+                         (or (and (ignore-errors
+                                    (magit--version>= magit-version "2008"))
                                   (ignore-errors
                                     (require 'lisp-mnt)
                                     (and (fboundp 'lm-header)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]