Skip to content

Commit 6f4d215

Browse files
committed
Allow filenames with non-ascii characters
This encodes the filenames from `git status` to utf-8. With this change the filenames are properly displayed in the UI and git commands such as add, and push still function as expected as git can accept filenames in utf-8 encoding because "Git is to some extent character encoding agnostic." see: https://git-scm.com/docs/git-commit/2.13.4#_discussion
1 parent 0d71ee3 commit 6f4d215

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

jupyterlab_git/git.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import re
66
import subprocess
77
from urllib.parse import unquote
8+
from codecs import decode, escape_decode
89

910
import pexpect
1011
import tornado
@@ -262,6 +263,8 @@ async def status(self, current_path):
262263
to1 = to1[1:]
263264
if to1.endswith('"'):
264265
to1 = to1[:-1]
266+
to1 = decode(escape_decode(to1)[0],'utf-8')
267+
from_path = decode(escape_decode(from_path)[0],'utf-8')
265268
result.append({"x": line[0], "y": line[1], "to": to1, "from": from_path})
266269
return {"code": code, "files": result}
267270

0 commit comments

Comments
 (0)