fix: make `submodule.update()` after `submodule.deinit()` work · gitpython-developers/GitPython@72895f4 · GitHub
Skip to content

Commit 72895f4

Browse files
codexByron
andcommitted
fix: make submodule.update() after submodule.deinit() work
Git's `submodule deinit` command removes the submodule checkout but retains its repository under the parent repository's `.git/modules` directory. Submodule.update() previously treated the missing checkout as a completely uninitialized submodule and attempted to clone it again. The clone could not reuse the existing module repository, preventing a deinitialized submodule from being initialized again through GitPython. Detect a valid retained repository before entering the clone path. Restore the checkout's `.git` file and the module repository's worktree configuration, reset the retained repository to recreate its index and working tree, and restore the submodule URL in the parent configuration. Continue using the existing clone behavior when no valid retained repository is available. Co-authored-by: Sebastian Thiel <sebastian.thiel@icloud.com>
1 parent e87854b commit 72895f4

2 files changed

Lines changed: 142 additions & 71 deletions

File tree

git/objects/submodule/base.py

Lines changed: 69 additions & 71 deletions

test/test_submodule.py

Lines changed: 73 additions & 0 deletions

0 commit comments

Comments
 (0)