From unknown Sun Jun 22 11:44:30 2025 X-Loop: help-debbugs@gnu.org Subject: bug#21930: emacs-repository-get-version fails on linked worktrees Resent-From: Juanma Barranquero Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 16 Nov 2015 03:48:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 21930 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 21930@debbugs.gnu.org X-Debbugs-Original-To: Bug-Gnu-Emacs Received: via spool by submit@debbugs.gnu.org id=B.144764568024278 (code B ref -1); Mon, 16 Nov 2015 03:48:01 +0000 Received: (at submit) by debbugs.gnu.org; 16 Nov 2015 03:48:00 +0000 Received: from localhost ([127.0.0.1]:39402 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZyAls-0006JW-1S for submit@debbugs.gnu.org; Sun, 15 Nov 2015 22:48:00 -0500 Received: from eggs.gnu.org ([208.118.235.92]:48190) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZyAlX-0006J5-5k for submit@debbugs.gnu.org; Sun, 15 Nov 2015 22:47:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZyAlV-0003tk-GT for submit@debbugs.gnu.org; Sun, 15 Nov 2015 22:47:38 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM, HTML_MESSAGE,T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:52083) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZyAlV-0003tf-Dw for submit@debbugs.gnu.org; Sun, 15 Nov 2015 22:47:37 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58191) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZyAlT-00034i-Rk for bug-gnu-emacs@gnu.org; Sun, 15 Nov 2015 22:47:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZyAlS-0003tM-Eg for bug-gnu-emacs@gnu.org; Sun, 15 Nov 2015 22:47:35 -0500 Received: from mail-lb0-x234.google.com ([2a00:1450:4010:c04::234]:36856) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZyAlS-0003tI-3Y for bug-gnu-emacs@gnu.org; Sun, 15 Nov 2015 22:47:34 -0500 Received: by lbblt2 with SMTP id lt2so81421243lbb.3 for ; Sun, 15 Nov 2015 19:47:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:content-type; bh=DSLHiZrAip4G6l4vHF7uf6QEM5z1kBQ8Xx3C3FKl9pk=; b=0KeSwBm3RsInLGue4MscKHjIGb6HfatGcnSRqq+ng6YjyT95XCYNJQPQN3+it/Ac7T EokOhcY13kiBEDoMoqi0zXHlavjp9uDm05sd914PcG5uGg6E5VgKDRrB00mDVQ09tKMu fT5hQei+hwOBxCHHcajTsTAOtBMmff+4WG6uIUheGWdaTuEmuSKpfBiYvbR/DE1av1uZ cwXMyFNZfZvi0Z/zVhoQFUysBxUHfH7szPJwZ/HJkQ1PWqJUGG9qUjBjN8eurIAHZJvP eEx9woZJ5EvSrLljmzJZzJahUp6sw38TPgFZXfB2coBslzUSg7u0j5I6+yhRDb4fYsBf 5Qhw== X-Received: by 10.112.234.163 with SMTP id uf3mr16080874lbc.15.1447645653226; Sun, 15 Nov 2015 19:47:33 -0800 (PST) MIME-Version: 1.0 Received: by 10.25.21.198 with HTTP; Sun, 15 Nov 2015 19:46:52 -0800 (PST) From: Juanma Barranquero Date: Mon, 16 Nov 2015 04:46:52 +0100 Message-ID: Content-Type: multipart/alternative; boundary=001a11c317e8ebde3b0524a044ca X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) --001a11c317e8ebde3b0524a044ca Content-Type: text/plain; charset=UTF-8 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. --001a11c317e8ebde3b0524a044ca Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Package: emacs
Version: 25.0.50
Severity: mi= nor

When run inside a linked worktree (created wit= h "git worktree add ..."), emacs-repository-get-version needs to = ask the VCS to find the repository version, which doesn't work during d= umping.

I'd like to apply this patch to the re= lease branch.


diff --git i/lis= p/version.el w/lisp/version.el
index 43103fd..4207cb4 100644
--- i/lisp/version.el
+++ w/lisp/version.el
@@ -1= 14,15 +114,15 @@ emacs-repository-version-git
=C2=A0 =C2=A0 (match-string 0)))))
<= div>=C2=A0
-(defun emacs-repository--version-git-1 (file)
+(defun emacs-repository--version-git-1 (file dir)
=C2=A0 =C2= =A0"Internal subroutine of `emacs-repository-get-version'."
=C2=A0 =C2=A0(when (file-readable-p file)
- =C2=A0 =C2= =A0(erase-buffer)
- =C2=A0 =C2=A0(insert-file-contents file)
- =C2=A0 =C2=A0(cond ((looking-at "[0-9a-fA-F]\\{40\\}")
- =C2=A0 (match-= string 0))
- = =C2=A0((looking-at "ref: \\(.*\\)")
- =C2=A0 (emacs-repository--version-git-1
- =C2=A0 =C2=A0= (expand-file-name (match-string 1)
- =C2=A0 =C2=A0 =C2=A0(file-name-directory file)))))= ))
+ =C2=A0 =C2=A0(with-temp-buffer
+ =C2=A0 =C2=A0 =C2= =A0(insert-file-contents file)
+ =C2=A0 =C2=A0 =C2=A0(cond ((look= ing-at "[0-9a-fA-F]\\{40\\}")
+ =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 (match-string 0))
+ =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0((looking-at "ref: \\(.*\\)")
+ =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (emacs-repository--version-git-1
<= div>+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(expand-file-name (ma= tch-string 1) dir)
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0dir))))))
=C2=A0
=C2=A0(defun emacs-repository-ge= t-version (&optional dir external)
@@ -139,18 +139,36 @@ emac= s-repository-get-version
=C2=A0the VCS if we cannot find any info= rmation ourselves."
=C2=A0 =C2=A0(or dir (setq dir source-di= rectory))
- =C2=A0(when (file-directory-p (expand-file-name "= ;.git" dir))
- =C2=A0 =C2=A0(if external
- (emacs-repository-version-git di= r)
- =C2=A0 =C2=A0 =C2=A0(or (let ((files '("HEAD" = "refs/heads/master"))
- file rev)
- =C2=A0 =C2=A0(with-temp-buffer
- =C2=A0 =C2=A0 =C2=A0(while (and (not r= ev)
- =C2=A0= (setq file (car files)))
- (setq file (expand-file-name (format ".git/%s" file)= dir)
- =C2= =A0 =C2=A0 =C2=A0files (cdr files)
- =C2=A0 =C2=A0 =C2=A0rev (emacs-repository--version-= git-1 file))))
- =C2=A0 =C2=A0rev)
-= =C2=A0;; AFAICS this doesn't work during dumping (bug#20799).<= /div>
- =C2=A0(emacs= -repository-version-git dir)))))
+ =C2=A0(let* ((base-dir (expand= -file-name ".git" dir))
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 (= in-main-worktree (file-directory-p base-dir))
+ =C2=A0 =C2=A0 =C2= =A0 =C2=A0 (in-linked-worktree nil)
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0= sub-dir)
+ =C2=A0 =C2=A0;; If the sources are in a linked worktr= ee, .git is a file that points to
+ =C2=A0 =C2=A0;; the location = of the main worktree and the repo's administrative files.
+ = =C2=A0 =C2=A0(when (and (not in-main-worktree)
+ =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (file-regular-p base-dir)
+ = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (file-readable-p base-dir)= )
+ =C2=A0 =C2=A0 =C2=A0(with-temp-buffer
+ =C2=A0 =C2= =A0 =C2=A0 =C2=A0(insert-file-contents base-dir)
+ =C2=A0 =C2=A0 = =C2=A0 =C2=A0(when (looking-at "gitdir: \\(.*\.git\\)\\(.*\\)$")<= /div>
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(setq base-dir (match-string = 1)
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0sub-d= ir (concat base-dir (match-string 2))
+ =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0in-linked-worktree t))))
+ =C2=A0 = =C2=A0;; We've found a worktree, either main or linked.
+ =C2= =A0 =C2=A0(when (or in-main-worktree in-linked-worktree)
+ =C2=A0= =C2=A0 =C2=A0(if external
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(e= macs-repository-version-git dir)
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0(or= (if in-linked-worktree
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0(emacs-repository--version-git-1
+ =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (expand-file-name "HEAD&quo= t; sub-dir) base-dir)
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0(let ((files '("HEAD" "refs/heads/master"))<= /div>
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0file rev)
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0(while (and (not rev)
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(setq fil= e (car files)))
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0(setq file (expand-file-name file base-dir)
+ = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0files (cdr files)
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0rev (emacs-repository--vers= ion-git-1 file base-dir)))
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0rev))
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0;; AFAICS this doesn't work during dumping (bug#20799).
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(emacs-repository-version-git d= ir))))))
=C2=A0
=C2=A0;; We put version info into the e= xecutable in the form that `ident' uses.

--001a11c317e8ebde3b0524a044ca-- From unknown Sun Jun 22 11:44:30 2025 X-Loop: help-debbugs@gnu.org Subject: bug#21930: emacs-repository-get-version fails on linked worktrees Resent-From: Stephen Leake Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 16 Nov 2015 23:03:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 21930 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Juanma Barranquero Cc: 21930@debbugs.gnu.org Received: via spool by 21930-submit@debbugs.gnu.org id=B21930.144771492423458 (code B ref 21930); Mon, 16 Nov 2015 23:03:02 +0000 Received: (at 21930) by debbugs.gnu.org; 16 Nov 2015 23:02:04 +0000 Received: from localhost ([127.0.0.1]:40606 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZySmh-00066I-Td for submit@debbugs.gnu.org; Mon, 16 Nov 2015 18:02:04 -0500 Received: from gproxy5-pub.mail.unifiedlayer.com ([67.222.38.55]:49894) by debbugs.gnu.org with smtp (Exim 4.80) (envelope-from ) id 1ZySmf-00065t-3J for 21930@debbugs.gnu.org; Mon, 16 Nov 2015 18:02:02 -0500 Received: (qmail 13614 invoked by uid 0); 16 Nov 2015 23:01:56 -0000 Received: from unknown (HELO cmgw2) (10.0.90.83) by gproxy5.mail.unifiedlayer.com with SMTP; 16 Nov 2015 23:01:56 -0000 Received: from host114.hostmonster.com ([74.220.207.114]) by cmgw2 with id iP1l1r00k2UdiVW01P1ovs; Mon, 16 Nov 2015 16:01:54 -0700 X-Authority-Analysis: v=2.1 cv=Jv9i8qIC c=1 sm=1 tr=0 a=CQdxDb2CKd3SRg4I0/XZPQ==:117 a=CQdxDb2CKd3SRg4I0/XZPQ==:17 a=DsvgjBjRAAAA:8 a=f5113yIGAAAA:8 a=9i_RQKNPAAAA:8 a=hEr_IkYJT6EA:10 a=x_XPkuGwIRMA:10 a=qtqOOiqGOCEA:10 a=pGLkceISAAAA:8 a=lkBmpjMkPiG1Ix4VLeAA:9 Received: from [76.218.37.33] (port=60826 helo=TAKVER2) by host114.hostmonster.com with esmtpa (Exim 4.84) (envelope-from ) id 1ZySmR-0007vE-7r; Mon, 16 Nov 2015 16:01:47 -0700 From: Stephen Leake References: Date: Mon, 16 Nov 2015 17:01:44 -0600 In-Reply-To: (Juanma Barranquero's message of "Mon, 16 Nov 2015 04:46:52 +0100") Message-ID: <867flha6qv.fsf@stephe-leake.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (windows-nt) MIME-Version: 1.0 Content-Type: text/plain X-Identified-User: {2442:host114.hostmonster.com:stephele:stephe-leake.org} {sentby:smtp auth 76.218.37.33 authed with stephen_leake@stephe-leake.org} X-Spam-Score: -0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) Juanma Barranquero 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 From unknown Sun Jun 22 11:44:30 2025 X-Loop: help-debbugs@gnu.org Subject: bug#21930: emacs-repository-get-version fails on linked worktrees Resent-From: Juanma Barranquero Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 17 Nov 2015 00:21:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 21930 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Stephen Leake Cc: 21930@debbugs.gnu.org Received: via spool by 21930-submit@debbugs.gnu.org id=B21930.144771965830639 (code B ref 21930); Tue, 17 Nov 2015 00:21:02 +0000 Received: (at 21930) by debbugs.gnu.org; 17 Nov 2015 00:20:58 +0000 Received: from localhost ([127.0.0.1]:40634 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZyU14-0007y6-0d for submit@debbugs.gnu.org; Mon, 16 Nov 2015 19:20:58 -0500 Received: from mail-lf0-f46.google.com ([209.85.215.46]:35341) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZyU12-0007xx-1v for 21930@debbugs.gnu.org; Mon, 16 Nov 2015 19:20:56 -0500 Received: by lfdo63 with SMTP id o63so96726459lfd.2 for <21930@debbugs.gnu.org>; Mon, 16 Nov 2015 16:20:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=Yx6jnjNRZXFdKHHA99XxCzRnhaCwuoDgHmgFWhAxVWI=; b=ghln/GkVSpCkAMvJsgJU+3kH5xcEZComdq9jiado4IqjlVxpOkvmcjNbVLOSYT6Utr iB/phtOIBM0EFcuQXtLKmfAIc1WSo3UdFEa/ZFSCKKD4mcNmMclx8PbCRFGah5Bt15Ld wC0l2KnGNudl2UTO/U58kDuplerdtHajbKekrLwMeoLgvWw2LVVFJSfBaPK/o3BENtIO JDqIwBold2AKIZwuk7Ot20YfihT/BADIQFIzF2jvH41FgpRvQBxABNKzxzjHCsq+hmSO UEZQJc9ohd1nkrIypiWKg8G71vemNC7UlT2cT1y2bWT8fnHgFRstmvE7ea0/mLoYlq+g REEQ== X-Received: by 10.25.135.136 with SMTP id j130mr18156061lfd.95.1447719655110; Mon, 16 Nov 2015 16:20:55 -0800 (PST) MIME-Version: 1.0 Received: by 10.25.21.198 with HTTP; Mon, 16 Nov 2015 16:20:15 -0800 (PST) In-Reply-To: <867flha6qv.fsf@stephe-leake.org> References: <867flha6qv.fsf@stephe-leake.org> From: Juanma Barranquero Date: Tue, 17 Nov 2015 01:20:15 +0100 Message-ID: Content-Type: multipart/alternative; boundary=001a113fc40ac6ffb60524b17f11 X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) --001a113fc40ac6ffb60524b17f11 Content-Type: text/plain; charset=UTF-8 On Tue, Nov 17, 2015 at 12:01 AM, Stephen Leake < stephen_leake@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. --001a113fc40ac6ffb60524b17f11 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable --001a113fc40ac6ffb60524b17f11-- From unknown Sun Jun 22 11:44:30 2025 X-Loop: help-debbugs@gnu.org Subject: bug#21930: emacs-repository-get-version fails on linked worktrees Resent-From: Juanma Barranquero Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 19 Nov 2015 18:19:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 21930 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: John Wiegley Cc: 21930@debbugs.gnu.org Received: via spool by 21930-submit@debbugs.gnu.org id=B21930.144795711627643 (code B ref 21930); Thu, 19 Nov 2015 18:19:01 +0000 Received: (at 21930) by debbugs.gnu.org; 19 Nov 2015 18:18:36 +0000 Received: from localhost ([127.0.0.1]:45173 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZzTn2-0007Bm-DY for submit@debbugs.gnu.org; Thu, 19 Nov 2015 13:18:36 -0500 Received: from mail-lb0-f177.google.com ([209.85.217.177]:34584) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZzTn0-0007Bb-5s for 21930@debbugs.gnu.org; Thu, 19 Nov 2015 13:18:34 -0500 Received: by lbbcs9 with SMTP id cs9so48576670lbb.1 for <21930@debbugs.gnu.org>; Thu, 19 Nov 2015 10:18:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=ivqqA8FrCS8dnNNBy7bY8fHYhVSUSUYgLuD7d5TWzuE=; b=PBC1xJNOorPvbz39WYODBAsbZh1gm6+lcbBq/mWaoq53BKyzUe5Y+QDx9HZtFwSCyT JzJWooLsAGwlr1lRF6mjM3M6gJeQr8Mn4K3TrXdbg0+sFtXOg988Mq3uT1xxyKErkveX F5jKWecGloBTeXxVEaxZWHw3juNFYvXaZXi4iJNEDBppKxy2t6Bhar9O4Bk2RQCLka97 QF3Ld00Hd3KMXviD3cE8P/0n6m+NPFiyjg3bByNHa51k/6xp/hE9G5Y/o8U1fcvKM550 4womdtkTO+XmQi3xPymYGN8tfY9jvwkzj18zBjzX4I52a5+R8/9ZDkQ0LgKbd0uGGf27 /TmQ== X-Received: by 10.112.236.67 with SMTP id us3mr3994332lbc.64.1447957113137; Thu, 19 Nov 2015 10:18:33 -0800 (PST) MIME-Version: 1.0 Received: by 10.25.21.198 with HTTP; Thu, 19 Nov 2015 10:17:53 -0800 (PST) In-Reply-To: References: <867flha6qv.fsf@stephe-leake.org> From: Juanma Barranquero Date: Thu, 19 Nov 2015 19:17:53 +0100 Message-ID: Content-Type: multipart/alternative; boundary=001a11c323f660ee480524e8c939 X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) --001a11c323f660ee480524e8c939 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Ping. John, it's OK to install this change in the emacs-25 branch? =E2=80=8B --001a11c323f660ee480524e8c939 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Ping.

John, it's OK to install this= change in the emacs-25 branch?
=E2=80=8B
--001a11c323f660ee480524e8c939-- From unknown Sun Jun 22 11:44:30 2025 X-Loop: help-debbugs@gnu.org Subject: bug#21930: emacs-repository-get-version fails on linked worktrees Resent-From: "John Wiegley" Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 19 Nov 2015 19:04:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 21930 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Juanma Barranquero Cc: 21930@debbugs.gnu.org Received: via spool by 21930-submit@debbugs.gnu.org id=B21930.14479598222770 (code B ref 21930); Thu, 19 Nov 2015 19:04:01 +0000 Received: (at 21930) by debbugs.gnu.org; 19 Nov 2015 19:03:42 +0000 Received: from localhost ([127.0.0.1]:45194 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZzUUf-0000ic-U3 for submit@debbugs.gnu.org; Thu, 19 Nov 2015 14:03:42 -0500 Received: from mail-pa0-f45.google.com ([209.85.220.45]:34065) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZzUUM-0000hp-8B for 21930@debbugs.gnu.org; Thu, 19 Nov 2015 14:03:40 -0500 Received: by padhx2 with SMTP id hx2so89439535pad.1 for <21930@debbugs.gnu.org>; Thu, 19 Nov 2015 11:03:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:in-reply-to:date:message-id:references :user-agent:mime-version:content-type; bh=X+onvehqO9Wnk4PyqTbtaafi/GLZ6r1kkNDVgZeAUkE=; b=IGI73BmGrJIetTZHSCsUHun1a5XZr1CpVC/VBTUIobewhA/PpXpM6tJu2oRXlYNACe kOW8LItjbaKFHT/XA2LqZze3mDcrEV7XLUlDrEeztLLcQvjy1zQteFQasrZOCy90A5kj VUrJI4/K9WdCLRmnjXFbDRnBfUe9ETOVgtuMBwDuI5zm+ttXJWcYkn+WujsJjWIDM3KS tyQ60fMxvETVybfNApvXQOBXhTltMwyIzHB5YWtwMC9A7LrtG1mofK+eq592jdpIRELo MzM7jU8Z8NEUCuJYY5Ko+rgRrK9TSAtkMmaxWCiZx2oe56WlprhTP1cXh6EbJZxBXnnV Hi6Q== X-Received: by 10.69.17.66 with SMTP id gc2mr13018985pbd.24.1447959801595; Thu, 19 Nov 2015 11:03:21 -0800 (PST) Received: from Vulcan.local (76-234-68-79.lightspeed.frokca.sbcglobal.net. [76.234.68.79]) by smtp.gmail.com with ESMTPSA id ef5sm12168737pbc.46.2015.11.19.11.03.19 (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 19 Nov 2015 11:03:19 -0800 (PST) Received: by Vulcan.local (Postfix, from userid 501) id 23D4010A33300; Thu, 19 Nov 2015 11:03:19 -0800 (PST) From: "John Wiegley" In-Reply-To: (Juanma Barranquero's message of "Thu, 19 Nov 2015 19:17:53 +0100") Date: Thu, 19 Nov 2015 11:03:17 -0800 Message-ID: References: <867flha6qv.fsf@stephe-leake.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (darwin) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) >>>>> Juanma Barranquero writes: > John, it's OK to install this change in the emacs-25 branch? Yes, please do. John From unknown Sun Jun 22 11:44:30 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.503 (Entity 5.503) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Juanma Barranquero Subject: bug#21930: closed (Re: bug#21930: emacs-repository-get-version fails on linked worktrees) Message-ID: References: X-Gnu-PR-Message: they-closed 21930 X-Gnu-PR-Package: emacs Reply-To: 21930@debbugs.gnu.org Date: Fri, 20 Nov 2015 00:42:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1447980122-29312-1" This is a multi-part message in MIME format... ------------=_1447980122-29312-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #21930: emacs-repository-get-version fails on linked worktrees which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 21930@debbugs.gnu.org. --=20 21930: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D21930 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1447980122-29312-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 21930-done) by debbugs.gnu.org; 20 Nov 2015 00:41:13 +0000 Received: from localhost ([127.0.0.1]:45352 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZzZlJ-0007bS-4B for submit@debbugs.gnu.org; Thu, 19 Nov 2015 19:41:13 -0500 Received: from mail-lf0-f52.google.com ([209.85.215.52]:33183) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZzZlG-0007bF-II for 21930-done@debbugs.gnu.org; Thu, 19 Nov 2015 19:41:11 -0500 Received: by lfaz4 with SMTP id z4so59340472lfa.0 for <21930-done@debbugs.gnu.org>; Thu, 19 Nov 2015 16:41:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=PCxHr7eA/VNwnwC6P+GJp/5NgaPRHx25hRCXriGYVnk=; b=JI9uba2X8gc4OLhrQ3R3dccRvcYFKWSuQB4G2QX33EqDWtnCDAaX1YdFu+er68Rtpe y+VdrIPhiIHkYr0SxZh0/Pn7kNjF9ybA5xeypqUcWlU9iuY+6vc51ADZMufybDu4mrnE Eb57+KZi+oL3dz1VDdwmOe7MtbShPZ1o/oiD6xyQi9TSFlhWEiPCGk6zkD5mMLg/Az9T 2MEXE7mc++MhQ0XGKWVwyWHP5MnlHLEKoc7BUX1llTBeMS5KlqAlEt+04H8u3iLAvsSZ Go/rJbRXpF5LCAeWJB+kvrvznnLxS6UnV+iFQ5yh3HLkytAlh/52oNuIDHHACL/vv7MG e15w== X-Received: by 10.25.134.134 with SMTP id i128mr4610610lfd.103.1447980069643; Thu, 19 Nov 2015 16:41:09 -0800 (PST) MIME-Version: 1.0 Received: by 10.25.21.198 with HTTP; Thu, 19 Nov 2015 16:40:30 -0800 (PST) In-Reply-To: References: <867flha6qv.fsf@stephe-leake.org> From: Juanma Barranquero Date: Fri, 20 Nov 2015 01:40:30 +0100 Message-ID: Subject: Re: bug#21930: emacs-repository-get-version fails on linked worktrees To: John Wiegley Content-Type: multipart/alternative; boundary=001a113fafd2b16c220524ee21b9 X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 21930-done Cc: 21930-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) --001a113fafd2b16c220524ee21b9 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Done in c210b8b128c17929dbb8e0b0564ee25930d44dd1.=E2=80=8B --001a113fafd2b16c220524ee21b9 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Done in=C2=A0c210b8b128c17929dbb8e0b0564ee25930d44dd1.=E2= =80=8B
--001a113fafd2b16c220524ee21b9-- ------------=_1447980122-29312-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 16 Nov 2015 03:48:00 +0000 Received: from localhost ([127.0.0.1]:39402 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZyAls-0006JW-1S for submit@debbugs.gnu.org; Sun, 15 Nov 2015 22:48:00 -0500 Received: from eggs.gnu.org ([208.118.235.92]:48190) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZyAlX-0006J5-5k for submit@debbugs.gnu.org; Sun, 15 Nov 2015 22:47:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZyAlV-0003tk-GT for submit@debbugs.gnu.org; Sun, 15 Nov 2015 22:47:38 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM, HTML_MESSAGE,T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:52083) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZyAlV-0003tf-Dw for submit@debbugs.gnu.org; Sun, 15 Nov 2015 22:47:37 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58191) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZyAlT-00034i-Rk for bug-gnu-emacs@gnu.org; Sun, 15 Nov 2015 22:47:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZyAlS-0003tM-Eg for bug-gnu-emacs@gnu.org; Sun, 15 Nov 2015 22:47:35 -0500 Received: from mail-lb0-x234.google.com ([2a00:1450:4010:c04::234]:36856) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZyAlS-0003tI-3Y for bug-gnu-emacs@gnu.org; Sun, 15 Nov 2015 22:47:34 -0500 Received: by lbblt2 with SMTP id lt2so81421243lbb.3 for ; Sun, 15 Nov 2015 19:47:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:content-type; bh=DSLHiZrAip4G6l4vHF7uf6QEM5z1kBQ8Xx3C3FKl9pk=; b=0KeSwBm3RsInLGue4MscKHjIGb6HfatGcnSRqq+ng6YjyT95XCYNJQPQN3+it/Ac7T EokOhcY13kiBEDoMoqi0zXHlavjp9uDm05sd914PcG5uGg6E5VgKDRrB00mDVQ09tKMu fT5hQei+hwOBxCHHcajTsTAOtBMmff+4WG6uIUheGWdaTuEmuSKpfBiYvbR/DE1av1uZ cwXMyFNZfZvi0Z/zVhoQFUysBxUHfH7szPJwZ/HJkQ1PWqJUGG9qUjBjN8eurIAHZJvP eEx9woZJ5EvSrLljmzJZzJahUp6sw38TPgFZXfB2coBslzUSg7u0j5I6+yhRDb4fYsBf 5Qhw== X-Received: by 10.112.234.163 with SMTP id uf3mr16080874lbc.15.1447645653226; Sun, 15 Nov 2015 19:47:33 -0800 (PST) MIME-Version: 1.0 Received: by 10.25.21.198 with HTTP; Sun, 15 Nov 2015 19:46:52 -0800 (PST) From: Juanma Barranquero Date: Mon, 16 Nov 2015 04:46:52 +0100 Message-ID: Subject: emacs-repository-get-version fails on linked worktrees To: Bug-Gnu-Emacs Content-Type: multipart/alternative; boundary=001a11c317e8ebde3b0524a044ca X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) --001a11c317e8ebde3b0524a044ca Content-Type: text/plain; charset=UTF-8 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. --001a11c317e8ebde3b0524a044ca Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Package: emacs
Version: 25.0.50
Severity: mi= nor

When run inside a linked worktree (created wit= h "git worktree add ..."), emacs-repository-get-version needs to = ask the VCS to find the repository version, which doesn't work during d= umping.

I'd like to apply this patch to the re= lease branch.


diff --git i/lis= p/version.el w/lisp/version.el
index 43103fd..4207cb4 100644
--- i/lisp/version.el
+++ w/lisp/version.el
@@ -1= 14,15 +114,15 @@ emacs-repository-version-git
=C2=A0 =C2=A0 (match-string 0)))))
<= div>=C2=A0
-(defun emacs-repository--version-git-1 (file)
+(defun emacs-repository--version-git-1 (file dir)
=C2=A0 =C2= =A0"Internal subroutine of `emacs-repository-get-version'."
=C2=A0 =C2=A0(when (file-readable-p file)
- =C2=A0 =C2= =A0(erase-buffer)
- =C2=A0 =C2=A0(insert-file-contents file)
- =C2=A0 =C2=A0(cond ((looking-at "[0-9a-fA-F]\\{40\\}")
- =C2=A0 (match-= string 0))
- = =C2=A0((looking-at "ref: \\(.*\\)")
- =C2=A0 (emacs-repository--version-git-1
- =C2=A0 =C2=A0= (expand-file-name (match-string 1)
- =C2=A0 =C2=A0 =C2=A0(file-name-directory file)))))= ))
+ =C2=A0 =C2=A0(with-temp-buffer
+ =C2=A0 =C2=A0 =C2= =A0(insert-file-contents file)
+ =C2=A0 =C2=A0 =C2=A0(cond ((look= ing-at "[0-9a-fA-F]\\{40\\}")
+ =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 (match-string 0))
+ =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0((looking-at "ref: \\(.*\\)")
+ =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (emacs-repository--version-git-1
<= div>+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(expand-file-name (ma= tch-string 1) dir)
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0dir))))))
=C2=A0
=C2=A0(defun emacs-repository-ge= t-version (&optional dir external)
@@ -139,18 +139,36 @@ emac= s-repository-get-version
=C2=A0the VCS if we cannot find any info= rmation ourselves."
=C2=A0 =C2=A0(or dir (setq dir source-di= rectory))
- =C2=A0(when (file-directory-p (expand-file-name "= ;.git" dir))
- =C2=A0 =C2=A0(if external
- (emacs-repository-version-git di= r)
- =C2=A0 =C2=A0 =C2=A0(or (let ((files '("HEAD" = "refs/heads/master"))
- file rev)
- =C2=A0 =C2=A0(with-temp-buffer
- =C2=A0 =C2=A0 =C2=A0(while (and (not r= ev)
- =C2=A0= (setq file (car files)))
- (setq file (expand-file-name (format ".git/%s" file)= dir)
- =C2= =A0 =C2=A0 =C2=A0files (cdr files)
- =C2=A0 =C2=A0 =C2=A0rev (emacs-repository--version-= git-1 file))))
- =C2=A0 =C2=A0rev)
-= =C2=A0;; AFAICS this doesn't work during dumping (bug#20799).<= /div>
- =C2=A0(emacs= -repository-version-git dir)))))
+ =C2=A0(let* ((base-dir (expand= -file-name ".git" dir))
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 (= in-main-worktree (file-directory-p base-dir))
+ =C2=A0 =C2=A0 =C2= =A0 =C2=A0 (in-linked-worktree nil)
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0= sub-dir)
+ =C2=A0 =C2=A0;; If the sources are in a linked worktr= ee, .git is a file that points to
+ =C2=A0 =C2=A0;; the location = of the main worktree and the repo's administrative files.
+ = =C2=A0 =C2=A0(when (and (not in-main-worktree)
+ =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (file-regular-p base-dir)
+ = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (file-readable-p base-dir)= )
+ =C2=A0 =C2=A0 =C2=A0(with-temp-buffer
+ =C2=A0 =C2= =A0 =C2=A0 =C2=A0(insert-file-contents base-dir)
+ =C2=A0 =C2=A0 = =C2=A0 =C2=A0(when (looking-at "gitdir: \\(.*\.git\\)\\(.*\\)$")<= /div>
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(setq base-dir (match-string = 1)
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0sub-d= ir (concat base-dir (match-string 2))
+ =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0in-linked-worktree t))))
+ =C2=A0 = =C2=A0;; We've found a worktree, either main or linked.
+ =C2= =A0 =C2=A0(when (or in-main-worktree in-linked-worktree)
+ =C2=A0= =C2=A0 =C2=A0(if external
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(e= macs-repository-version-git dir)
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0(or= (if in-linked-worktree
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0(emacs-repository--version-git-1
+ =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (expand-file-name "HEAD&quo= t; sub-dir) base-dir)
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0(let ((files '("HEAD" "refs/heads/master"))<= /div>
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0file rev)
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0(while (and (not rev)
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(setq fil= e (car files)))
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0(setq file (expand-file-name file base-dir)
+ = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0files (cdr files)
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0rev (emacs-repository--vers= ion-git-1 file base-dir)))
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0rev))
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0;; AFAICS this doesn't work during dumping (bug#20799).
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(emacs-repository-version-git d= ir))))))
=C2=A0
=C2=A0;; We put version info into the e= xecutable in the form that `ident' uses.

--001a11c317e8ebde3b0524a044ca-- ------------=_1447980122-29312-1--