Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d986a59

Browse filesBrowse files
authored
Merge pull request #1778 from stegm/fix_index_with_pathlike
Fix if items of Index is of type PathLike
2 parents c398d79 + 6e4cee4 commit d986a59
Copy full SHA for d986a59

File tree

2 files changed

+8
-6
lines changed
Filter options

2 files changed

+8
-6
lines changed

‎git/index/base.py

Copy file name to clipboardExpand all lines: git/index/base.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -940,7 +940,7 @@ def _items_to_rela_paths(
940940
for item in items:
941941
if isinstance(item, (BaseIndexEntry, (Blob, Submodule))):
942942
paths.append(self._to_relative_path(item.path))
943-
elif isinstance(item, str):
943+
elif isinstance(item, (str, os.PathLike)):
944944
paths.append(self._to_relative_path(item))
945945
else:
946946
raise TypeError("Invalid item type: %r" % item)

‎test/test_index.py

Copy file name to clipboardExpand all lines: test/test_index.py
+7-5Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -558,14 +558,16 @@ def test_index_mutation(self, rw_repo):
558558
def mixed_iterator():
559559
count = 0
560560
for entry in index.entries.values():
561-
type_id = count % 4
562-
if type_id == 0: # path
561+
type_id = count % 5
562+
if type_id == 0: # path (str)
563563
yield entry.path
564-
elif type_id == 1: # blob
564+
elif type_id == 1: # path (PathLike)
565+
yield Path(entry.path)
566+
elif type_id == 2: # blob
565567
yield Blob(rw_repo, entry.binsha, entry.mode, entry.path)
566-
elif type_id == 2: # BaseIndexEntry
568+
elif type_id == 3: # BaseIndexEntry
567569
yield BaseIndexEntry(entry[:4])
568-
elif type_id == 3: # IndexEntry
570+
elif type_id == 4: # IndexEntry
569571
yield entry
570572
else:
571573
raise AssertionError("Invalid Type")

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.