summaryrefslogtreecommitdiff
path: root/lisp/version.el
diff options
context:
space:
mode:
authorMichael Albinus <michael.albinus@gmx.de>2018-11-10 16:03:12 +0100
committerMichael Albinus <michael.albinus@gmx.de>2018-11-10 16:03:12 +0100
commita062fc4137ff195fe269076cda07a61c2e1a8012 (patch)
treec1ca66b9f322fd9db69baaa1e0c47444931527d7 /lisp/version.el
parent55f3f21b39389263d707b091d7e1b45d295a149c (diff)
downloademacs-a062fc4137ff195fe269076cda07a61c2e1a8012.tar.gz
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. (tramp-debug-message): * 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.
Diffstat (limited to 'lisp/version.el')
-rw-r--r--lisp/version.el28
1 files changed, 28 insertions, 0 deletions
diff --git a/lisp/version.el b/lisp/version.el
index 84919308191..c72164cdacc 100644
--- a/lisp/version.el
+++ b/lisp/version.el
@@ -135,6 +135,34 @@ Optional argument DIR is a directory to use instead of `source-directory'.
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"))