Skip to content
Snippets Groups Projects
Commit 13ea55ce authored by Justin Tobler's avatar Justin Tobler
Browse files

localrepo: Disable `FetchBundle()` fsck

Starting in Git version 2.46.0, executing git-fetch(1) on a bundle
performs fsck checks when `transfer.fsckObjects` is enabled. Prior to
this, this configuration was always ignored and fsck checks were not
run. Unfortunately, fsck message severity configuration is ignored by
Git only for bundle fetches.

Until this is supported by Git, disable `transfer.fsckObjects` so
bundles containing fsck errors can continue to be fetched. This matches
behavior prior to Git version 2.46.0.
parent c53bf77a
No related branches found
No related tags found
1 merge request!7347localrepo: Disable `FetchBundle()` fsck
......@@ -166,7 +166,16 @@ func (repo *Repo) FetchBundle(ctx context.Context, txManager transaction.Manager
{Key: "remote.inmemory.fetch", Value: git.MirrorRefSpec},
}
fetchOpts := FetchOpts{
CommandOptions: []gitcmd.CmdOpt{gitcmd.WithConfigEnv(fetchConfig...)},
CommandOptions: []gitcmd.CmdOpt{
gitcmd.WithConfigEnv(fetchConfig...),
// Starting in Git version 2.46.0, executing git-fetch(1) on a bundle performs fsck
// checks when `transfer.fsckObjects` is enabled. Prior to this, this configuration was
// always ignored and fsck checks were not run. Unfortunately, fsck message severity
// configuration is ignored by Git only for bundle fetches. Until this is supported by
// Git, disable `transfer.fsckObjects` so bundles containing fsck errors can continue to
// be fetched. This matches behavior prior to Git version 2.46.0.
gitcmd.WithConfig(gitcmd.ConfigPair{Key: "transfer.fsckObjects", Value: "false"}),
},
}
if err := repo.FetchRemote(ctx, "inmemory", fetchOpts); err != nil {
return fmt.Errorf("fetch bundle: %w", err)
......
......@@ -330,19 +330,24 @@ func TestRepo_FetchBundle(t *testing.T) {
// Write a tree object that has the same path twice. When git-fetch(1) executes with
// `transfer.fsckObjects=true`, it is expected that this objects causes the fetch to fail.
//
// The git-fetch(1) performed when fetching bundles is configured to override
// `transfer.fsckObjects` to `false`. Therefore, fsck errors are ignored.
treeID := gittest.WriteTree(t, cfg, sourceRepoPath, []gittest.TreeEntry{
{Path: "duplicate", Mode: "100644", Content: "foo"},
{Path: "duplicate", Mode: "100644", Content: "bar"},
})
gittest.WriteCommit(t, cfg, sourceRepoPath, gittest.WithBranch(git.DefaultBranch), gittest.WithTree(treeID))
mainOid := gittest.WriteCommit(t, cfg, sourceRepoPath, gittest.WithBranch(git.DefaultBranch), gittest.WithTree(treeID))
return testSetup{
reader: createBundle(t, cfg, sourceRepoPath),
reader: createBundle(t, cfg, sourceRepoPath),
expectedHeadRef: git.DefaultRef,
expectedRefs: []git.Reference{
git.NewReference(git.DefaultRef, mainOid),
},
}
},
expectedErrAs: FetchFailedError{},
expectedErrContains: "duplicateEntries: contains duplicate file entries",
},
} {
t.Run(tc.desc, func(t *testing.T) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment