[Top][All Lists]

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

[Emacs-diffs] master a062fc4 2/2: Provide branch information for both Em

From: Michael Albinus
Subject: [Emacs-diffs] master a062fc4 2/2: Provide branch information for both Emacs and Tramp (Bug#33328)
Date: Sat, 10 Nov 2018 10:03:24 -0500 (EST)

branch: master
commit a062fc4137ff195fe269076cda07a61c2e1a8012
Author: Michael Albinus <address@hidden>
Commit: Michael Albinus <address@hidden>

    Provide branch information for both Emacs and Tramp (Bug#33328)
    * doc/lispref/intro.texi (Version Info):
    Document `emacs-repository-version' and `emacs-repository-branch'.
    * etc/NEWS: Mention `emacs-repository-branch'.
    * lisp/loadup.el: Initialize `emacs-repository-branch'.
    * lisp/version.el (emacs-repository-branch): New variable.
    (emacs-repository-branch-git, emacs-repository-get-branch):
    New defuns.
    * lisp/mail/emacsbug.el (report-emacs-bug):
    Insert `emacs-repository-branch'.
    * lisp/net/tramp.el (tramp-get-local-gid):
    Use `group-name' if available.
    * lisp/net/tramp-cmds.el (tramp-bug): Report also
    `tramp-repository-branch' and `tramp-repository-version'.
    * lisp/net/trampver.el (tramp-repository-branch)
    (tramp-repository-version): New defconst.
    (tramp-repository-get-version): Remove.
 doc/lispref/intro.texi | 12 ++++++++++++
 etc/NEWS               |  4 ++++
 lisp/loadup.el         |  4 ++--
 lisp/mail/emacsbug.el  |  2 ++
 lisp/net/tramp-cmds.el |  5 +++--
 lisp/net/tramp.el      | 11 +++++++----
 lisp/net/trampver.el   | 28 +++++++++++++++++-----------
 lisp/version.el        | 28 ++++++++++++++++++++++++++++
 8 files changed, 75 insertions(+), 19 deletions(-)

diff --git a/doc/lispref/intro.texi b/doc/lispref/intro.texi
index 197f54e..2353cf9 100644
--- a/doc/lispref/intro.texi
+++ b/doc/lispref/intro.texi
@@ -530,6 +530,18 @@ directory (without cleaning).  This is only of relevance 
 developing Emacs.
 @end defvar
address@hidden emacs-repository-version
+A string that gives the repository revision from which Emacs was
+built.  If Emacs was built outside revision control, the value is
address@hidden defvar
address@hidden emacs-repository-branch
+A string that gives the repository branch from which Emacs was built.
+In the most cases this is @code{"master"}.  If Emacs was built outside
+revision control, the value is @code{nil}.
address@hidden defvar
 @node Acknowledgments
 @section Acknowledgments
diff --git a/etc/NEWS b/etc/NEWS
index e5892d7..b8073dd 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -225,6 +225,10 @@ In addition to nil or non-nil, the value can now be a 
 function.  Follow mode uses this to control scrolling of its windows
 when the last screen line in a window is not fully visible.
+** New variable 'emacs-repository-branch'.
+It reports the git branch from which Emacs was built.
 * Editing Changes in Emacs 27.1
diff --git a/lisp/loadup.el b/lisp/loadup.el
index 5ecfae1..eb66353 100644
--- a/lisp/loadup.el
+++ b/lisp/loadup.el
@@ -368,8 +368,8 @@ lost after dumping")))
                                 (substring name (length base) exelen))))
-      (setq emacs-repository-version (condition-case nil 
-                              (error nil)))
+      (setq emacs-repository-version (ignore-errors 
+            emacs-repository-branch (ignore-errors 
       ;; A constant, so we shouldn't change it with `setq'.
       (defconst emacs-build-number
        (if versions (1+ (apply 'max versions)) 1))))
diff --git a/lisp/mail/emacsbug.el b/lisp/mail/emacsbug.el
index 8cacad8..e55f950 100644
--- a/lisp/mail/emacsbug.el
+++ b/lisp/mail/emacsbug.el
@@ -307,6 +307,8 @@ usually do not have translators for other languages.\n\n")))
     (if (stringp emacs-repository-version)
        (insert "Repository revision: " emacs-repository-version "\n"))
+    (if (stringp emacs-repository-branch)
+       (insert "Repository branch: " emacs-repository-branch "\n"))
     (if (fboundp 'x-server-vendor)
        (condition-case nil
             ;; This is used not only for X11 but also W32 and others.
diff --git a/lisp/net/tramp-cmds.el b/lisp/net/tramp-cmds.el
index 456300e..3c8f182 100644
--- a/lisp/net/tramp-cmds.el
+++ b/lisp/net/tramp-cmds.el
@@ -198,8 +198,9 @@ This includes password cache, file cache, connection cache, 
          ;; In rare cases, it could contain the password.  So we make it nil.
-       tramp-bug-report-address                ; to-address
-       (format "tramp (%s)" tramp-version) ; package name and version
+       tramp-bug-report-address          ; to-address
+       (format "tramp (%s %s/%s)" ; package name and version
+              tramp-version tramp-repository-branch tramp-repository-version)
        (delq nil (mapcar
          (lambda (x)
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index 44d6640..e8d535e 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -1609,10 +1609,13 @@ ARGUMENTS to actually emit the message (if applicable)."
        ";; Emacs: %s Tramp: %s -*- mode: outline; -*-"
        emacs-version tramp-version))
       (when (>= tramp-verbose 10)
-       (insert
-        (format
-         "\n;; Location: %s Git: %s"
-         (locate-library "tramp") (tramp-repository-get-version)))))
+       (let ((tramp-verbose 0))
+         (insert
+          (format
+           "\n;; Location: %s Git: %s/%s"
+           (locate-library "tramp")
+           (or tramp-repository-branch "")
+           (or tramp-repository-version ""))))))
     (unless (bolp)
       (insert "\n"))
     ;; Timestamp.
diff --git a/lisp/net/trampver.el b/lisp/net/trampver.el
index de76788..f93e538 100644
--- a/lisp/net/trampver.el
+++ b/lisp/net/trampver.el
@@ -38,17 +38,23 @@
 (defconst tramp-bug-report-address "address@hidden"
   "Email address to send bug reports to.")
-(defun tramp-repository-get-version ()
-  "Try to return as a string the repository revision of the Tramp sources."
-  (let ((dir (locate-dominating-file (locate-library "tramp") ".git")))
-    (when dir
-      (with-temp-buffer
-       (let ((default-directory (file-name-as-directory dir)))
-         (and (zerop
-               (ignore-errors
-                 (call-process "git" nil '(t nil) nil "rev-parse" "HEAD")))
-              (not (zerop (buffer-size)))
-              (replace-regexp-in-string "\n" "" (buffer-string))))))))
+(defconst tramp-repository-branch
+  (ignore-errors
+    ;; Suppress message from `emacs-repository-get-branch'.
+    (let ((inhibit-message t))
+      ;; `emacs-repository-get-branch' has been introduced with Emacs 27.1.
+      (with-no-warnings
+       (emacs-repository-get-branch
+        (locate-dominating-file (locate-library "tramp") ".git")))))
+  "The repository branch of the Tramp sources.")
+(defconst tramp-repository-version
+  (ignore-errors
+    ;; Suppress message from `emacs-repository-get-version'.
+    (let ((inhibit-message t))
+      (emacs-repository-get-version
+       (locate-dominating-file (locate-library "tramp") ".git"))))
+  "The repository revision of the Tramp sources.")
 ;; Check for Emacs version.
 (let ((x   (if (not (string-lessp emacs-version "24.1"))
diff --git a/lisp/version.el b/lisp/version.el
index 8491930..c72164c 100644
--- a/lisp/version.el
+++ b/lisp/version.el
@@ -135,6 +135,34 @@ Optional argument DIR is a directory to use instead of 
 Optional argument EXTERNAL is ignored."
   (emacs-repository-version-git (or dir source-directory)))
+(defvar emacs-repository-branch nil
+  "String giving the repository branch from which this Emacs was built.
+Value is nil if Emacs was not built from a repository checkout,
+or if we could not determine the branch.")
+(defun emacs-repository-branch-git (dir)
+  "Ask git itself for the branch information for directory DIR."
+  (message "Waiting for git...")
+  (with-temp-buffer
+    (let ((default-directory (file-name-as-directory dir)))
+      (and (zerop
+           (with-demoted-errors "Error running git rev-parse --abbrev-ref: %S"
+             (call-process "git" nil '(t nil) nil
+                            "rev-parse" "--abbrev-ref" "HEAD")))
+           (goto-char (point-min))
+           (buffer-substring (point) (line-end-position))))))
+(defun emacs-repository-get-branch (&optional dir)
+  "Try to return as a string the repository branch of the Emacs sources.
+The format of the returned string is dependent on the VCS in use.
+Value is nil if the sources do not seem to be under version
+control, or if we could not determine the branch.  Note that
+this reports on the current state of the sources, which may not
+correspond to the running Emacs.
+Optional argument DIR is a directory to use instead of `source-directory'."
+  (emacs-repository-branch-git (or dir source-directory)))
 ;; We put version info into the executable in the form that `ident' uses.
 (purecopy (concat "\n$Id: " (subst-char-in-string ?\n ?\s (emacs-version))
                  " $\n"))

reply via email to

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