Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #82: correctly handle filenames reported by git.ls_files() when they contain unicode escapes #83

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion aider/coders/base_coder.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import os
import sys
import traceback
import codecs
from json.decoder import JSONDecodeError
from pathlib import Path, PurePosixPath

Expand Down Expand Up @@ -966,7 +967,20 @@ def get_tracked_files(self):
return []
# 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)
# decode file names to UTF-8 when git reports them enclosed in quotes, and convert backslashes to os.sep
res = set()
for path in files:
if path[0] == '"' and path[-1] == '"':
# Strip quotes, convert escape sequence to characters,
# convert to bytes and decode as UTF-8.
path = (path[1:-1]
.encode('latin1')
.decode('unicode_escape')
.encode('latin1')
.decode('utf-8')
)
res.add(str(Path(PurePosixPath(path))))

return res

apply_update_errors = 0
Expand Down