GNU bug report logs -
#21930
emacs-repository-get-version fails on linked worktrees
Previous Next
Reported by: Juanma Barranquero <lekktu <at> gmail.com>
Date: Mon, 16 Nov 2015 03:48:01 UTC
Severity: minor
Found in version 25.0.50
Done: Juanma Barranquero <lekktu <at> gmail.com>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 21930 in the body.
You can then email your comments to 21930 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#21930
; Package
emacs
.
(Mon, 16 Nov 2015 03:48:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Juanma Barranquero <lekktu <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Mon, 16 Nov 2015 03:48:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Package: emacs
Version: 25.0.50
Severity: minor
When run inside a linked worktree (created with "git worktree add ..."),
emacs-repository-get-version needs to ask the VCS to find the repository
version, which doesn't work during dumping.
I'd like to apply this patch to the release branch.
diff --git i/lisp/version.el w/lisp/version.el
index 43103fd..4207cb4 100644
--- i/lisp/version.el
+++ w/lisp/version.el
@@ -114,15 +114,15 @@ emacs-repository-version-git
(match-string 0)))))
-(defun emacs-repository--version-git-1 (file)
+(defun emacs-repository--version-git-1 (file dir)
"Internal subroutine of `emacs-repository-get-version'."
(when (file-readable-p file)
- (erase-buffer)
- (insert-file-contents file)
- (cond ((looking-at "[0-9a-fA-F]\\{40\\}")
- (match-string 0))
- ((looking-at "ref: \\(.*\\)")
- (emacs-repository--version-git-1
- (expand-file-name (match-string 1)
- (file-name-directory file)))))))
+ (with-temp-buffer
+ (insert-file-contents file)
+ (cond ((looking-at "[0-9a-fA-F]\\{40\\}")
+ (match-string 0))
+ ((looking-at "ref: \\(.*\\)")
+ (emacs-repository--version-git-1
+ (expand-file-name (match-string 1) dir)
+ dir))))))
(defun emacs-repository-get-version (&optional dir external)
@@ -139,18 +139,36 @@ emacs-repository-get-version
the VCS if we cannot find any information ourselves."
(or dir (setq dir source-directory))
- (when (file-directory-p (expand-file-name ".git" dir))
- (if external
- (emacs-repository-version-git dir)
- (or (let ((files '("HEAD" "refs/heads/master"))
- file rev)
- (with-temp-buffer
- (while (and (not rev)
- (setq file (car files)))
- (setq file (expand-file-name (format ".git/%s" file) dir)
- files (cdr files)
- rev (emacs-repository--version-git-1 file))))
- rev)
- ;; AFAICS this doesn't work during dumping (bug#20799).
- (emacs-repository-version-git dir)))))
+ (let* ((base-dir (expand-file-name ".git" dir))
+ (in-main-worktree (file-directory-p base-dir))
+ (in-linked-worktree nil)
+ sub-dir)
+ ;; If the sources are in a linked worktree, .git is a file that points
to
+ ;; the location of the main worktree and the repo's administrative
files.
+ (when (and (not in-main-worktree)
+ (file-regular-p base-dir)
+ (file-readable-p base-dir))
+ (with-temp-buffer
+ (insert-file-contents base-dir)
+ (when (looking-at "gitdir: \\(.*\.git\\)\\(.*\\)$")
+ (setq base-dir (match-string 1)
+ sub-dir (concat base-dir (match-string 2))
+ in-linked-worktree t))))
+ ;; We've found a worktree, either main or linked.
+ (when (or in-main-worktree in-linked-worktree)
+ (if external
+ (emacs-repository-version-git dir)
+ (or (if in-linked-worktree
+ (emacs-repository--version-git-1
+ (expand-file-name "HEAD" sub-dir) base-dir)
+ (let ((files '("HEAD" "refs/heads/master"))
+ file rev)
+ (while (and (not rev)
+ (setq file (car files)))
+ (setq file (expand-file-name file base-dir)
+ files (cdr files)
+ rev (emacs-repository--version-git-1 file
base-dir)))
+ rev))
+ ;; AFAICS this doesn't work during dumping (bug#20799).
+ (emacs-repository-version-git dir))))))
;; We put version info into the executable in the form that `ident' uses.
[Message part 2 (text/html, inline)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#21930
; Package
emacs
.
(Mon, 16 Nov 2015 23:03:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 21930 <at> debbugs.gnu.org (full text, mbox):
Juanma Barranquero <lekktu <at> gmail.com> writes:
> When run inside a linked worktree (created with "git worktree add ..."),
> emacs-repository-get-version needs to ask the VCS to find the repository
> version, which doesn't work during dumping.
I'm guessing because running any background process doesn't work during
dumping; they don't work in general in batch mode.
> I'd like to apply this patch to the release branch.
Looks good to me.
--
-- Stephe
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#21930
; Package
emacs
.
(Tue, 17 Nov 2015 00:21:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 21930 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On Tue, Nov 17, 2015 at 12:01 AM, Stephen Leake <
stephen_leake <at> stephe-leake.org> wrote:
> I'm guessing because running any background process doesn't work during
> dumping; they don't work in general in batch mode.
The code refers to bug#20799, which states that git (and other external
processes) cannot be run while dumping because `exec-path' is nil.
So the function, to be usable on a linked worktree while dumping, needs to
directly read the .git file. That's what my patch does. Calls to
`emacs-repository-get-version' with EXTERNAL = t already work (when not
dumping) without my patch, of course.
> Looks good to me.
Great.
[Message part 2 (text/html, inline)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#21930
; Package
emacs
.
(Thu, 19 Nov 2015 18:19:01 GMT)
Full text and
rfc822 format available.
Message #14 received at 21930 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Ping.
John, it's OK to install this change in the emacs-25 branch?
[Message part 2 (text/html, inline)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#21930
; Package
emacs
.
(Thu, 19 Nov 2015 19:04:01 GMT)
Full text and
rfc822 format available.
Message #17 received at 21930 <at> debbugs.gnu.org (full text, mbox):
>>>>> Juanma Barranquero <lekktu <at> gmail.com> writes:
> John, it's OK to install this change in the emacs-25 branch?
Yes, please do.
John
Reply sent
to
Juanma Barranquero <lekktu <at> gmail.com>
:
You have taken responsibility.
(Fri, 20 Nov 2015 00:42:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
Juanma Barranquero <lekktu <at> gmail.com>
:
bug acknowledged by developer.
(Fri, 20 Nov 2015 00:42:02 GMT)
Full text and
rfc822 format available.
Message #22 received at 21930-done <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Done in c210b8b128c17929dbb8e0b0564ee25930d44dd1.
[Message part 2 (text/html, inline)]
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Fri, 18 Dec 2015 12:24:03 GMT)
Full text and
rfc822 format available.
This bug report was last modified 9 years and 187 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.