- Add tests - [P2] Disable lazy fetching during no-fetch updates — git/objects/submodule/base.py:865-866 For a partial-cloned submodule (for example, using `--filter=blob:none`), the target commit can be cached while its blobs are missing. Skipping `Remote.fetch` does not prevent the later checkout/reset from implicitly fetching those blobs. I reproduced `update(no_fetch=True)` spawning `git fetch origin ... --stdin` despite this guard. This violates the documented local-only behavior. Disable Git's lazy fetching for commands executed in this mode, including checkout and restoration. - [P2] Propagate no_fetch to recursive root-module updates — git/objects/submodule/root.py:442-442 For repositories with nested submodules, `Repo.submodule_update(no_fetch=True)` still fetches nested remotes. The flag reaches this immediate `sm.update(recursive=False, ...)`, but the subsequent `type(self)(sm.module()).update(...)` call omits it and defaults to `False`. Since root updates recurse by default, offline updates fail even when all required objects are cached. Forward the flag to the recursive call too. - [P2] Skip the branch-change fetch loop when no_fetch is set — git/objects/submodule/root.py:90-90 When `.gitmodules` changes a submodule's configured branch, the branch-change handler still unconditionally calls `remote.fetch(...)` for every remote. Consequently, even `submodule_update(recursive=False, no_fetch=True)` accesses remotes and fails offline, including when the target remote-tracking branch already exists locally. Guard that fetch loop with this flag as well. - [P2] Handle URL changes without requiring freshly fetched refs — git/objects/submodule/root.py:282-283 When a submodule's URL changes with `no_fetch=True`, the newly created `__new_origin__` remote has no refs, so the following `smr.refs` branch check raises `ValueError`. This occurs even when switching to an identical mirror with all required history cached locally, and leaves the temporary remote behind. The no-fetch path must handle the fetch-dependent validation and remote replacement, not merely skip this fetch. - [P2] Allow restoring retained repositories without fetching — git/objects/submodule/base.py:893-896 After `git submodule deinit`, the retained repository under `.git/modules/<name>` can already contain the requested commit. This branch has validated that repository but now rejects `update(init=True, no_fetch=True)` merely because its checkout is empty. Reconnecting the repository and restoring cached contents requires no network access; native `git submodule update --init --no-fetch` succeeds in this case. Allow restoration and conditionally skip the later `fetch_remotes(mrepo)` instead. Assisted-by: GPT 6.0 Co-authored-by: GPT 6.0 <[email protected]>
GitHubJacksonized
submodule: option to update without fetching by jeffro256 · Pull Request #2244 · gitpython-developers/GitPython
Originally published at github.com. Every curse word you see was added by the Samuel L. Jacksonizer, a parody site. Not affiliated with Samuel L. Jackson or github.com.