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

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

[nongnu] elpa/tuareg 57a79f9444 1/2: Fix tuareg-mode-revision in git wor


From: ELPA Syncer
Subject: [nongnu] elpa/tuareg 57a79f9444 1/2: Fix tuareg-mode-revision in git worktrees and when loading .el
Date: Sun, 17 Jul 2022 22:59:01 -0400 (EDT)

branch: elpa/tuareg
commit 57a79f944434949335cf930e3d3c20edad28a171
Author: Mattias EngdegÄrd <mattiase@acm.org>
Commit: Mattias EngdegÄrd <mattiase@acm.org>

    Fix tuareg-mode-revision in git worktrees and when loading .el
    
    Use the right directory to extract the git revision when loading
    Tuareg from source or when .git is a non-directory.
---
 tuareg.el | 24 +++++++++++++++---------
 1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/tuareg.el b/tuareg.el
index dc13d6c047..b635d736c7 100644
--- a/tuareg.el
+++ b/tuareg.el
@@ -91,15 +91,21 @@
 
 (defconst tuareg-mode-revision
   (eval-when-compile
-    (with-temp-buffer
-      (if (file-directory-p ".git")
-           (progn
-             (insert "git: ")
-             (call-process "git" nil t nil "log" "--pretty=%h" "-1")))
-      (unless (zerop (buffer-size))
-        (buffer-substring-no-properties
-         (point-min) (1- (point-max))))))
-  "Tuareg revision from the control system used.")
+    (let ((dir (or (and (fboundp 'macroexp-file-name)
+                        (let ((f (macroexp-file-name)))
+                          (and f (file-name-directory f))))
+                   (and load-file-name (file-name-directory load-file-name))
+                   default-directory)))
+      (with-temp-buffer
+        (let ((default-directory dir))
+          (and (file-exists-p ".git")
+               (ignore-errors
+                 (call-process "git" nil t nil "log" "--pretty=%h" "-1"))
+               (not (zerop (buffer-size)))
+               (concat "git: "
+                       (buffer-substring-no-properties
+                        (point-min) (1- (point-max)))))))))
+  "Tuareg revision from the control system used, or nil.")
 
 (defconst tuareg-mode-version
   (let ((version (or (if (fboundp 'package-get-version)



reply via email to

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