Repository navigation
Conversation
…epository=explicit With safe.bareRepository=explicit (git 2.38+), git refuses to use a bare repository found from the working directory. The cloner and the collector ran git with cmd.Dir set to the bare clone, so the clone failed at `git repack -d` with "cannot use bare repository". Pass --git-dir explicitly, and do the same in the test helpers that run git in bare repos. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
pr-type/bug-fix,pr-type/feature-development, etc.Summary
With
safe.bareRepository=explicit(git 2.38+), git refuses to use a barerepository that it finds from the working directory. Hardened hosts, some CI
runners and agent shells set this option, for example through
GIT_CONFIG_COUNT/GIT_CONFIG_KEY_n/GIT_CONFIG_VALUE_n, and the serverinherits it.
gitextractor always clones into a bare repository and then runs git with
cmd.Dirset to that clone. With the option set, an incremental clone failsat
git repack -d:and the collector would fail the same way on
git rev-parse --git-dir.This PR passes
--git-dir=<clone>explicitly:GitcliCloner.gitCommandadds it whenever a directory is given (git clonestill runs without one).
gitRunner.command, used by the collector, always adds it.The test helpers that run git inside bare repositories (
runGit,hasObject,blameAtHEAD) do the same, so the test suite also passes onmachines with the option set. A new test,
TestCloneAndCollectWithSafeBareRepositoryExplicit, sets the option and runsan incremental clone and the collector against a bare clone.
Does this close any open issues?
No.
Screenshots
N/A
Other Information
go test ./plugins/gitextractor/...passes with and withoutsafe.bareRepository=explicitin the environment; the new test fails withoutthe fix with the error above.
golangci-lint run ./plugins/gitextractor/...reports no issues.--git-dirbehaves exactly like discovering the repository from the working directory.