From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44600) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g44D8-0008JQ-H3 for guix-patches@gnu.org; Sun, 23 Sep 2018 09:14:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g44D4-0004dC-QA for guix-patches@gnu.org; Sun, 23 Sep 2018 09:14:06 -0400 Received: from debbugs.gnu.org ([208.118.235.43]:46110) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g44D4-0004d6-L6 for guix-patches@gnu.org; Sun, 23 Sep 2018 09:14:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1g44D4-0001Lm-B0 for guix-patches@gnu.org; Sun, 23 Sep 2018 09:14:02 -0400 Subject: [bug#32740] [PATCH] git-download: Don't assume the git checkout is the parent of ".git". Resent-Message-ID: From: Marius Bakke In-Reply-To: <87sh235ggi.fsf@gnu.org> References: <20180915101034.10102-1-mbakke@fastmail.com> <87sh235ggi.fsf@gnu.org> Date: Sun, 23 Sep 2018 15:13:09 +0200 Message-ID: <87y3bsl5lm.fsf@fastmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 32740@debbugs.gnu.org --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable ludo@gnu.org (Ludovic Court=C3=A8s) writes: > Hello Marius! > > Marius Bakke skribis: > >> This makes it play nicely with worktrees. >> >> * guix/git-download.scm (git-file-list): Use REPOSITORY-WORKING-DIRECTOR= Y to >> locate checkout. Rename from "top" to "workdir". >> --- >> >> Notes: >> Guix, >>=20=20=20=20=20 >> This fixes (current-guix) for me in a worktree. Testing needed on o= ther git >> setups! >> >> guix/git-download.scm | 9 ++++++--- >> 1 file changed, 6 insertions(+), 3 deletions(-) >> >> diff --git a/guix/git-download.scm b/guix/git-download.scm >> index 24cf11be5..a7c8173f4 100644 >> --- a/guix/git-download.scm >> +++ b/guix/git-download.scm >> @@ -158,19 +158,22 @@ also includes directories, not just regular files.= The returned file names >> are relative to DIRECTORY, which is not necessarily the root of the che= ckout." >> (let* ((directory (canonicalize-path directory)) >> (dot-git (repository-discover directory)) >> - (top (dirname dot-git)) >> (repository (repository-open dot-git)) >> + (workdir (canonicalize-path >> + ;; XXX: This variable is mistakenly private in Gu= ile-Git 0.1.0. >> + ((@@ (git repository) repository-working-director= y) >> + repository))) > > I think we can avoid the call to =E2=80=98canonicalize-path=E2=80=99 here= , can=E2=80=99t we? > It=E2=80=99s costly, and since we did it just above, it shouldn=E2=80=99t= be needed > here. You're right. I mostly needed it because (repository-working-directory) includes a trailing slash. This behaviour seems to be consistent, so I managed to simplify the code further by assuming that is the case: --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-git-download-Don-t-assume-the-working-directory-is-t.patch Content-Transfer-Encoding: quoted-printable From=20e8b443e1de0a5b1e3dfeee024cd0625790f4f834 Mon Sep 17 00:00:00 2001 From: Marius Bakke Date: Sat, 15 Sep 2018 11:53:40 +0200 Subject: [PATCH] git-download: Don't assume the working directory is the parent of ".git". * guix/git-download.scm (git-file-list): Use REPOSITORY-WORKING-DIRECTORY to locate checkout. Rename from "top" to "workdir". =2D-- guix/git-download.scm | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/guix/git-download.scm b/guix/git-download.scm index 24cf11be5..eb20927c7 100644 =2D-- a/guix/git-download.scm +++ b/guix/git-download.scm @@ -156,22 +156,21 @@ HASH-ALGO (a symbol). Use NAME as the file name, or = a generic name if #f." The result is similar to that of the 'git ls-files' command, except that it also includes directories, not just regular files. The returned file names are relative to DIRECTORY, which is not necessarily the root of the checko= ut." =2D (let* ((directory (canonicalize-path directory)) + (let* ((directory (string-append (canonicalize-path directory) "/")) (dot-git (repository-discover directory)) =2D (top (dirname dot-git)) (repository (repository-open dot-git)) + ;; XXX: This procedure is mistakenly private in Guile-Git 0.1.0. + (workdir ((@@ (git repository) repository-working-directory) + repository)) (head (repository-head repository)) (oid (reference-target head)) (commit (commit-lookup repository oid)) (tree (commit-tree commit)) (files (tree-list tree))) (repository-close! repository) =2D (if (string=3D? top directory) + (if (string=3D? workdir directory) files =2D (let ((relative (string-append =2D (string-drop directory =2D (+ 1 (string-length top))) =2D "/"))) + (let ((relative (string-drop directory (string-length workdir)))) (filter-map (lambda (file) (and (string-prefix? relative file) (string-drop file (string-length relative)))) =2D-=20 2.19.0 --=-=-= Content-Type: text/plain WDYT? --=-=-=-- --==-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCgAdFiEEu7At3yzq9qgNHeZDoqBt8qM6VPoFAlunkWUACgkQoqBt8qM6 VPo9lAf/TPJsRa7pJU5sQZ80ls2SGzxjuXtMNPeuiDKEwEG3pI86U1/wX+xnFyvD Vndt0rNUhmo0LPya1MyIoYFQy5pBj8R1RyhZNldthCn4maMx6/WVhITEKpnU/NJl k5y9P52j7LrZdoMq4p55UpL9QSJee3rJ0GA2sK23W2V2G2Hog1hMIwxH9WGAy6UX qCL3Lp8a3Id2d7uRy/wq9cztMTjlJ+LYahAaQggE4pSEJk2dILlgc9yHam/HfHvV jkW9BNNshF68D+aOPNn/wfBtELw5Qa/6BeVsrPoS/GACMYJAMS9ZM++kXNb7aA5o ef1Bjp0bEyZnbUqg9/V9itdbq/Rr1Q== =F3Sd -----END PGP SIGNATURE----- --==-=-=--