Skip to content

[GitRepository] injection fails inside a git worktree (.git is a file, not a directory) #458

Description

@ChrisonSimtian

Problem

GitRepository.FromLocalDirectory finds the repo root by looking for a .git directory (src/Fallout.Build/VCS/GitRepository.cs:42, via ContainsDirectory(".git")), then reads HEAD/config from rootDirectory / ".git" (:43). In a git worktree .git is a file containing a gitdir: pointer to the main repo's worktree metadata, so detection fails: No parent Git directory for '<path>'. Both ./build.ps1 (dogfood [GitRepository] injection) and any test that resolves the local repo break when run from a worktree.

Outcome

[GitRepository] injection and local-repo resolution work inside a git worktree, the same as in a normal clone.

Acceptance criteria

  • GitRepository.FromLocalDirectory resolves the repo when .git is a file (worktree), not only a directory
  • HEAD / commit / config reads follow the worktree's gitdir: pointer instead of assuming rootDirectory / ".git" is a directory
  • ./build.ps1 <target> runs from a worktree without the No parent Git directory failure
  • GitHubTasksSpecs.GitHubRepositoryFromLocalDirectorySpec and ChangelogTasksSpecs.Missing_changelog_does_not_add_a_full_changelog_link_to_release_notes pass when the suite runs from a worktree

Notes

Increasingly relevant because AI coding agents commonly run in git worktrees for isolation. Surfaced while smoke-testing #447 from a worktree.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingenhancementNew feature or requesttarget/2026Targets the 2026 calendar-version line (current). See ADR-0004.

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions