fix: exclude symlinks-to-directories from repo map file listing#4891
Open
yshch wants to merge 1 commit intoAider-AI:mainfrom
Open
fix: exclude symlinks-to-directories from repo map file listing#4891yshch wants to merge 1 commit intoAider-AI:mainfrom
yshch wants to merge 1 commit intoAider-AI:mainfrom
Conversation
Co-authored-by: aider (claude-opus-4.6) <aider@aider.chat>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
In repositories that contain symlinks pointing to directories, aider's repo map would incorrectly include these symlink paths as if they were regular files. This caused warnings like:
Git tracks symlinks as blob objects (storing the symlink target as content), so they appear alongside regular files when enumerating the repository. However, when Python resolves these paths, Path.is_file() returns False because the resolved target is a directory, not a file.
How to reproduce the problem
Create new git repository with symlink-to-directory
Run aider and refresh repomap
Root Cause
GitRepo.get_tracked_files() collects files from two sources:
1 Committed files — via commit.tree.traverse(), filtering for blob.type == "blob"
2 Staged files — via index.entries.keys()
Neither path checked whether a blob/entry was a symlink pointing to a directory. These entries were passed to the repo map, which then failed the Path(fname).is_file() check and emitted the misleading warning.
Fix
Added a check in both code paths within get_tracked_files(): if a path is a symlink, it is only included if it resolves to a file (not a directory).
This correctly:
• Includes regular files (not symlinks) — is_symlink() is False, so the condition passes
• Includes symlinks to files — is_symlink() is True but is_file() is also True
• Excludes symlinks to directories — is_symlink() is True and is_file() is False