Skip to content

Commit e142017

Browse files
authored
dulwich: use worktree, since repo stage is deprecated (#447)
1 parent fd8f308 commit e142017

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/scmrepo/git/backend/dulwich/__init__.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -333,8 +333,10 @@ def add(
333333

334334
paths = [paths] if isinstance(paths, str) else list(paths)
335335

336+
worktree = self.repo.get_worktree()
337+
336338
if update and not paths:
337-
self.repo.stage(list(self.repo.open_index()))
339+
worktree.stage(list(self.repo.open_index()))
338340
return
339341

340342
files: list[bytes] = [
@@ -345,13 +347,13 @@ def add(
345347
if os.name == "nt":
346348
# NOTE: we need git/unix separator to compare against index
347349
# paths but repo.stage() expects to be called with OS paths
348-
self.repo.stage(
350+
worktree.stage(
349351
[fname for fname in files if fname.replace(b"\\", b"/") in index]
350352
)
351353
else:
352-
self.repo.stage([fname for fname in files if fname in index])
354+
worktree.stage([fname for fname in files if fname in index])
353355
else:
354-
self.repo.stage(files)
356+
worktree.stage(files)
355357

356358
def _expand_paths(self, paths: list[str], force: bool = False) -> Iterator[str]:
357359
for path in paths:

0 commit comments

Comments
 (0)