From 7c0ac4d92fddd504ff0a91cc3941f0225e7b17cc Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Tue, 11 Jul 2023 08:12:44 -0700 Subject: [PATCH] Tell git to stop quoting the paths in ls-files --- aider/coders/base_coder.py | 6 +++++- aider/repomap.py | 16 ++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/aider/coders/base_coder.py b/aider/coders/base_coder.py index 2cab25d64..39ef5e07d 100755 --- a/aider/coders/base_coder.py +++ b/aider/coders/base_coder.py @@ -964,9 +964,13 @@ class Coder: def get_tracked_files(self): if not self.repo: return [] + + files = self.repo.git.execute(["git", "-c", "core.quotepath=off", "ls-files"]) + files = set(files.splitlines()) + # convert to appropriate os.sep, since git always normalizes to / - files = set(self.repo.git.ls_files().splitlines()) res = set(str(Path(PurePosixPath(path))) for path in files) + return res apply_update_errors = 0 diff --git a/aider/repomap.py b/aider/repomap.py index 6e9f25834..7535838dc 100644 --- a/aider/repomap.py +++ b/aider/repomap.py @@ -172,7 +172,10 @@ class RepoMap: def run_ctags(self, filename): # Check if the file is in the cache and if the modification time has not changed - file_mtime = os.path.getmtime(filename) + file_mtime = self.get_mtime(filename) + if file_mtime is None: + return [] + cache_key = filename if cache_key in self.TAGS_CACHE and self.TAGS_CACHE[cache_key]["mtime"] == file_mtime: return self.TAGS_CACHE[cache_key]["data"] @@ -239,8 +242,17 @@ class RepoMap: def save_ident_cache(self): pass + def get_mtime(self, fname): + try: + return os.path.getmtime(fname) + except FileNotFoundError: + self.io.tool_error(f"File not found error: {fname}") + def get_name_identifiers(self, fname, uniq=True): - file_mtime = os.path.getmtime(fname) + file_mtime = self.get_mtime(fname) + if file_mtime is None: + return set() + cache_key = fname if cache_key in self.IDENT_CACHE and self.IDENT_CACHE[cache_key]["mtime"] == file_mtime: idents = self.IDENT_CACHE[cache_key]["data"]