Skip to content

fix(discover): honor .git/info/exclude and core.excludesFile in linked worktrees#695

Open
lg320531124 wants to merge 1 commit into
DeusData:mainfrom
lg320531124:fix/689-worktree-exclude
Open

fix(discover): honor .git/info/exclude and core.excludesFile in linked worktrees#695
lg320531124 wants to merge 1 commit into
DeusData:mainfrom
lg320531124:fix/689-worktree-exclude

Conversation

@lg320531124

Copy link
Copy Markdown

What Problem This Solves

Linked git worktrees have a .git file (not directory) containing gitdir: <path> pointing to the worktree-specific git directory under the main repo's .git/worktrees/<name>/. The discover module checked S_ISDIR on .git, which returned false for worktrees, causing two issues:

  1. .git/info/exclude not honored — per-repo local exclude rules were skipped
  2. core.excludesFile not evaluated — git config check also used wrong path

Why This Change Was Made

Added resolve_git_dir_from_dotgit_file() to parse the gitdir: pointer and resolve the actual git directory. Both info/exclude and config lookups now use the resolved path.

Evidence

  • Built and tested on macOS arm64 with a linked git worktree
  • Before fix: local_only.txt (in info/exclude) was indexed
  • After fix: correctly excluded; only main.c indexed
  • Regular repos unaffected

Fixes #689

@lg320531124 lg320531124 requested a review from DeusData as a code owner June 29, 2026 09:34
@lg320531124 lg320531124 force-pushed the fix/689-worktree-exclude branch from f5140e8 to 1702afa Compare June 29, 2026 10:36
@DeusData

Copy link
Copy Markdown
Owner

Huge thanks for opening this PR and for the work you put into it.

The maintainer shop is currently full, so this may sit for a bit before it gets a proper review. We will come back to this as soon as possible with real feedback; I wanted to make sure it did not sit unacknowledged in the meantime.

@DeusData DeusData added bug Something isn't working ux/behavior Display bugs, docs, adoption UX priority/high Needs near-term maintainer attention; high-impact bug, regression, safety issue, or release blocker. labels Jun 29, 2026
@lg320531124 lg320531124 force-pushed the fix/689-worktree-exclude branch from 1702afa to 2333563 Compare July 1, 2026 00:07
@DeusData

DeusData commented Jul 1, 2026

Copy link
Copy Markdown
Owner

Thanks, this looks focused. Before merge, please rewrite the commit metadata to remove generated/co-author/session attribution. DCO otherwise appears to be present on the non-merge commit.

…d worktrees

Linked git worktrees have a .git *file* (not directory) containing
'gitdir: <path>' pointing to the worktree-specific git directory.
The previous code checked S_ISDIR on .git, which returned false for
worktrees, skipping all exclude/config resolution.

Add resolve_git_dir_from_dotgit_file() to parse the gitdir: pointer
and resolve the actual git directory. Use the resolved path for
info/exclude and config lookups, making worktree exclude rules work
identically to regular repos.

Fixes DeusData#689

Signed-off-by: lg320531124 <lg320531124@users.noreply.github.com>
@lg320531124 lg320531124 force-pushed the fix/689-worktree-exclude branch from 2333563 to 5d7315a Compare July 1, 2026 11:50
@lg320531124

Copy link
Copy Markdown
Author

Done — rewrote the commit metadata to drop the Co-Authored-By trailer (head now 5d7315a). The Signed-off-by DCO line and the rest of the message are unchanged. Ready for merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working priority/high Needs near-term maintainer attention; high-impact bug, regression, safety issue, or release blocker. ux/behavior Display bugs, docs, adoption UX

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(git): index_repository ignores .git/info/exclude and core.excludesFile inside linked git worktrees

2 participants