Skip to content

fix: skip empty .git directories during repo discovery#1471

Draft
kayagokalp wants to merge 2 commits into
git-ai-project:mainfrom
kayagokalp:fix/skip-empty-git-dirs
Draft

fix: skip empty .git directories during repo discovery#1471
kayagokalp wants to merge 2 commits into
git-ai-project:mainfrom
kayagokalp:fix/skip-empty-git-dirs

Conversation

@kayagokalp
Copy link
Copy Markdown

Summary

  • Validate .git directories contain a HEAD file before treating them as repo roots
  • Empty .git dirs (e.g. from docker-compose volume mounts) are now skipped during tree-walk
  • Fixes repo discovery in worktree_root_for_path, has_intervening_git_dir, and find_repository_for_file
  • Unit tests for is_valid_git_dir (rejects empty dir, accepts dir with HEAD, accepts .git file, rejects nonexistent)
  • Unit tests for worktree_root_for_path skipping empty .git dirs

Closes #1415

Validate that a .git directory contains a HEAD file before treating it
as a repository root. Empty .git directories (e.g. created by
docker-compose volume mounts) are now skipped so the tree-walk
continues upward to the real repository.

Closes git-ai-project#1415
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented May 29, 2026

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
0 out of 2 committers have signed the CLA.

❌ kayagokalp
❌ gitar-bot
You have signed the CLA already but the status is still pending? Let us recheck it.

…ry case

Co-authored-by: kaya <20915464+kayagokalp@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Exclude empty .git dirs from valid git repo detection

3 participants