From 24aa48198bb228a9988289f006c95e3d9e7f2d3a Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Thu, 1 Aug 2024 16:28:10 -0300 Subject: [PATCH] fix: Use os.path.commonpath() to check if fname_path is below cwd_path --- aider/repo.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/aider/repo.py b/aider/repo.py index 3410a8bd1..795bdc9e6 100644 --- a/aider/repo.py +++ b/aider/repo.py @@ -269,14 +269,11 @@ class GitRepo: def ignored_file_raw(self, fname): if self.subtree_only: - try: - fname_path = Path(self.normalize_path(fname)).resolve() - cwd_path = Path.cwd().resolve() - dump(fname_path) - dump(cwd_path) - if not fname_path.is_relative_to(cwd_path): - return True - except ValueError: + fname_path = Path(self.normalize_path(fname)).resolve() + cwd_path = Path.cwd().resolve() + dump(fname_path) + dump(cwd_path) + if os.path.commonpath([str(fname_path), str(cwd_path)]) != str(cwd_path): return True if not self.aider_ignore_file or not self.aider_ignore_file.is_file():