Fix issue where git archive
fails on repositories with Git LFS
#8186
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
Add a flag
-c remote.origin.lfsurl=<actualUrl>
togit.cc
to support LFS calls end-to-end, unblocking issues wherefetchGit
fails on Git repositories using LFS.Context
Resolves: #4623
Currently
fetchGit
is incapable of callinggit-lfs
. Fortunately, it almost works perfectly asgit
properly hands off necessary calls to a locally installedgit-lfs
executable, but there is a minor difference in expectations between what is available in the bare Git repository and whatlfs
needs. The error message from LFS is not very descriptive.In particular, git-lfs attempts to discover the remote URL that it needs for fetching artifact URLs using the
remote.origin.url
Git config option, which is not present in the current bare Git repository.While I think setting the
remote.origin.url
might have undesirable side-effects, LFS accepts an alternative URL via the LFS-specific configuration optionremote.origin.lfsurl
.Since
git.cc
uses a barecheckout
when pulling from repositories using submodules, Git LFS should work in those cases. It's only for repositories without submodules (i.e. when thearchive
command is invoked) that this configuration option is necessary. Thus, I added it directly as a configuration option on thearchive
command rather than updating the repository'sconfig
file.One uncertainty that I have: I'm not exactly sure how easy this will be to test. Git LFS usually operates by making an HTTP request to an asset server and I'm not sure if it's feasible to run a test for LFS without needing a lot of extra infrastructure. It also sounds like such tests may be fundamentally changed with this new
libgit
approach. I can provide a sample repository with LFS files to manually verify this change, but I don't know if there is an easy way to test LFS going forward.Checklist for maintainers
Maintainers: tick if completed or explain if not relevant
tests/**.sh
src/*/tests
tests/nixos/*
Priorities
Add 👍 to pull requests you find important.