Commit e9e271b
fix: Clone into dangling submodule metadata symlink targets on Windows
rubber stamp
<!-- agent -->
Removing a submodule retains its metadata alias but deletes the target.
Adding the same submodule again then passes a dangling directory symlink
to git clone --separate-git-dir. Git for Windows fails while copying its
template files through that alias. Both native-realpath and simulated
Windows 3.7 remove-leaf cases reproduced this failure locally.
When the metadata destination is a leaf symlink, pass its target to Git
and leave the alias intact. Resolve relative targets against the link's
parent, create missing target parents through the existing clone setup,
and let Git create the repository directory itself. Precreating that
directory is insufficient because Git rejects an existing separate git
repository destination.
Read the link explicitly because Python 3.7 on Windows cannot resolve a
dangling link with Path.resolve(). Normalize the Windows namespace prefix
returned by newer os.readlink implementations, including UNC targets,
and use forward slashes before passing the path through Git's URL logic.
The shared clone helper covers add() and initialization through update().
Add regression coverage for direct cloning through absolute and relative
dangling metadata links with missing target parents. Verify that the link
and its stored target are retained, metadata is created at the target,
and the resulting checkout works under both realpath modes.
Validation: 61 focused tests passed on Windows/Python 3.10 with
HIDE_WINDOWS_KNOWN_ERRORS=0, including both reported failures. Ruff 0.16.5
lint and formatting checks and git diff --check passed. Native Python 3.7
and UNC network shares were not available for execution. A broader run
also exposed sharing violations in sibling-reinitialization tests before
cloning; a representative case also failed with the unchanged HEAD clone
helper loaded in memory. That separate removal issue is not changed here.
Assisted-by: GPT 6.0
Co-authored-by: GPT 6.0 <codex@openai.com>1 parent 958002b commit e9e271b
2 files changed
Lines changed: 31 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
377 | 377 | | |
378 | 378 | | |
379 | 379 | | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
380 | 392 | | |
381 | 393 | | |
382 | 394 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
451 | 451 | | |
452 | 452 | | |
453 | 453 | | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
454 | 473 | | |
455 | 474 | | |
456 | 475 | | |
| |||
0 commit comments