Subject: [bug#32740] [PATCH] git-download: Don't assume the git checkout is the parent of ".git".

From: Leo Famulari <[email-masked]>
Date: Mon, 17 Sep 2018 15:19:39 -0400

On Sat, Sep 15, 2018 at 12:10:34PM +0200, Marius Bakke wrote:
> This makes it play nicely with worktrees.
> 
> * guix/git-download.scm (git-file-list): Use REPOSITORY-WORKING-DIRECTORY to
> locate checkout.  Rename from "top" to "workdir".

Thanks!

> ---
> 
> Notes:
>     Guix,
>     
>     This fixes (current-guix) for me in a worktree.  Testing needed on other git
>     setups!

To clarify what this fixes, I tried building a fresh worktree from
scratch without your patch and it crashed:

------
  LOAD     gnu/tests/install.scm
Backtrace:
In srfi/srfi-1.scm:
   592:29 19 (map1 (#<<service> type: #<service-type mingetty cf7?> ?))
   592:29 18 (map1 (#<<service> type: #<service-type mingetty cf7?> ?))
   592:29 17 (map1 (#<<service> type: #<service-type mingetty cf7?> ?))
   592:29 16 (map1 (#<<service> type: #<service-type syslog c7537?> ?))
   592:17 15 (map1 (#<<service> type: #<service-type guix 43f8be0?> ?))
In ice-9/eval.scm:
   196:43 14 (_ #(#(#(#<directory (gnu tests install) 110a20a0>) ?) ?))
   293:34 13 (_ #(#(#(#<directory (gnu tests install) 110a20a0>) ?) ?))
   293:34 12 (_ #(#(#(#<directory (gnu packages package-manag?> ?)) ?))
   174:20 11 (_ #(#(#(#<directory (gnu packages package-manag?> ?)) ?))
   177:49 10 (lp (#<procedure ed4d8c0 at ice-9/eval.scm:282:4 (en?> ?))
   177:49  9 (lp (#<procedure ed4d8a0 at ice-9/eval.scm:282:4 (en?> ?))
   177:49  8 (lp (#<procedure ed4d880 at ice-9/eval.scm:282:4 (en?> ?))
   177:32  7 (lp (#<procedure ed4d860 at ice-9/eval.scm:182:7 (env)>))
In unknown file:
           6 (force #<promise #<procedure 8aa6580 at ice-9/eval.scm:?>)
In ice-9/eval.scm:
   293:34  5 (_ #(#(#<directory (gnu packages package-management?> ?)))
In ice-9/boot-9.scm:
    829:9  4 (catch git-error #<procedure ed4d460 at ice-9/eval.scm?> ?)
In ice-9/eval.scm:
   293:34  3 (_ #(#(#<directory (guix git-download) 3ec5c80> "/ho?")))
   293:34  2 (_ #(#(#(#(#(#(#(#(#(#(#(#) ?) ?) ?) ?) ?) ?) ?) ?) ?) ?))
    159:9  1 (_ #(#(#(#(#(#(#(#(#(#(#(#) ?) ?) ?) ?) ?) ?) ?) ?) ?) ?))
In unknown file:
           0 (string-drop "/home/leo/tmp/mytest" 35)

ERROR: In procedure string-drop:
Value out of range 0 to 20: 35
------

Your patch avoids this crash, which I was stymied by a couple days ago!
Has it always been there? I've been using Guix worktrees for a while.