浏览代码

Support bytes paths in dulwich.index.

Jelmer Vernooij 6 年之前
父节点
当前提交
9857bb44d9
共有 1 个文件被更改,包括 6 次插入1 次删除
  1. 6 1
      dulwich/index.py

+ 6 - 1
dulwich/index.py

@@ -590,6 +590,10 @@ def read_submodule_head(path):
     """
     from dulwich.errors import NotGitRepository
     from dulwich.repo import Repo
+    # Repo currently expects a "str", so decode if necessary.
+    # TODO(jelmer): Perhaps move this into Repo() ?
+    if not isinstance(path, str):
+        path = path.decode(sys.getfilesystemencoding())
     try:
         repo = Repo(path)
     except NotGitRepository:
@@ -690,12 +694,13 @@ def index_entry_from_path(path, object_store=None):
         save new blobs in
     :return: An index entry
     """
+    assert isinstance(path, bytes)
     try:
         st = os.lstat(path)
         blob = blob_from_path_and_stat(path, st)
     except EnvironmentError as e:
         if e.errno == errno.EISDIR:
-            if os.path.exists(os.path.join(path, '.git')):
+            if os.path.exists(os.path.join(path, b'.git')):
                 head = read_submodule_head(path)
                 if head is None:
                     return None