developing Emacs.
@end defvar
+@defvar 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
+@code{nil}.
+@end defvar
+
+@defvar 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}.
+@end defvar
+
@node Acknowledgments
@section Acknowledgments
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.
+
\f
* Editing Changes in Emacs 27.1
(string-to-number
(substring name (length base) exelen))))
files)))
- (setq emacs-repository-version (condition-case nil (emacs-repository-get-version)
- (error nil)))
+ (setq emacs-repository-version (ignore-errors (emacs-repository-get-version))
+ emacs-repository-branch (ignore-errors (emacs-repository-get-branch)))
;; A constant, so we shouldn't change it with `setq'.
(defconst emacs-build-number
(if versions (1+ (apply 'max versions)) 1))))
(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.
;; In rare cases, it could contain the password. So we make it nil.
tramp-password-save-function)
(reporter-submit-bug-report
- 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)
(sort
(delq nil (mapcar
(lambda (x)
";; 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.
(defconst tramp-bug-report-address "tramp-devel@gnu.org"
"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"))
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"))