Skip to content

git.sh: Support blobless/treeless clones: use `git worktree` in extract_git()

Tom Hale requested to merge tomhale/pacman:worktree into master

Use git worktree rather than git clone -s to avoid issues with bare (clone --mirror or --bare) repositories that are also blobless or treeless clones.

If the remote HEAD commit is not going to be used (eg, a particular tag will be used instead), cloning bare will mean that unneeded HEAD blobs don't need to be transferred.

git worktree also avoids unnecessary hard-linking to the initial repository objects, and just provides a "bare" worktree.

Currently, with GITFLAGS="--mirror --filter=tree:0}", the following error occurs (ssh-ident-git used as an example):

Cloning into 'ssh-ident'...
done.
fatal: unable to parse commit 66a00104057411d85592411455261284d08bb065
warning: Clone succeeded, but checkout failed.
You can inspect what was checked out with 'git status'
and retry with 'git restore --source=HEAD :/'

NB: using git restore --source=HEAD :/ has the initial fatal: reoccur.

Edited by Tom Hale

Merge request reports