2
0
Эх сурвалжийг харах

Support bytes paths in dulwich.index.

Jelmer Vernooij 6 жил өмнө
parent
commit
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