Skip to content

Commit f01a13c

Browse files
authored
fix: support submodules in worktree (#92)
1 parent 88e541e commit f01a13c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/git_draft/toolbox.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ def _update_tree(sha: SHA, updates: Sequence[_TreeUpdate], repo: Repo) -> SHA:
270270
case _DeleteBlob(path):
271271
blob_shas[path.parent][path.name] = ""
272272
case _:
273-
raise UnreachableError()
273+
raise UnreachableError(f"Unexpected update: {update}")
274274

275275
def visit_tree(sha: SHA, path: PurePosixPath) -> SHA:
276276
old_lines = null_delimited(repo.git("ls-tree", "-z", sha).stdout)
@@ -288,8 +288,10 @@ def visit_tree(sha: SHA, path: PurePosixPath) -> SHA:
288288
case "tree":
289289
new_sha = visit_tree(old_sha, path / name)
290290
new_lines.append(f"040000 tree {new_sha}\t{name}")
291+
case "commit": # Submodule
292+
new_lines.append(line)
291293
case _:
292-
raise UnreachableError()
294+
raise UnreachableError(f"Unexpected line: {line}")
293295

294296
for name, blob_sha in new_blob_shas.items():
295297
if blob_sha:

0 commit comments

Comments
 (0)