Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/cli/land-fixer-repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ export function importFixer(
const objects: string[] = [];
const walk = (path: string, relative = "") => {
for (const name of readdirSync(path)) {
// Git lock files are transient: a background `git maintenance` or auto-gc can create and remove one
// while this walks (moq-dev/moq#6987 crashed on a vanished `objects/maintenance.lock`). None is imported.
if (name.endsWith(".lock")) continue;
if (++files > 100_000) throw new Error("fixer repository has too many files");
const child = join(path, name);
const rel = relative ? `${relative}/${name}` : name;
Expand Down
3 changes: 3 additions & 0 deletions src/cli/land-fixer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ export async function startFixer(
return;
}
git(checkout, ["init", "--quiet"]);
// No background gc or maintenance may rewrite objects while the daemon imports the fixer's result.
git(checkout, ["config", "gc.auto", "0"]);
git(checkout, ["config", "maintenance.auto", "false"]);
git(checkout, [
"fetch",
"--quiet",
Expand Down
2 changes: 2 additions & 0 deletions test/land.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2074,6 +2074,8 @@ describe.skipIf(process.platform === "win32")("asynchronous land fixer", () => {
mkdirSync(submodule, { recursive: true });
writeFileSync(join(submodule, `${large}.pack`), "");
truncateSync(join(submodule, `${large}.pack`), 101 * 1024 * 1024);
// A transient lock is skipped, never read: git maintenance may remove it mid-walk (moq-dev/moq#6987).
symlinkSync(join(checkout, "missing"), join(checkout, ".git", "objects", "maintenance.lock"));
importFixer(root, tempDir(), checkout, 1, fixed, [...packs, `${large}.pack`]);
expect(git(root, "show", `${fixed}:kept.txt`)).toBe("unchanged");
expect(git(root, "rev-parse", `${fixed}^`)).toBe(pinned);
Expand Down
Loading