Commit a83262b
review
- 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 <codex@openai.com>1 parent 738e940 commit a83262b
3 files changed
Lines changed: 517 additions & 98 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | 7 | | |
9 | 8 | | |
10 | 9 | | |
11 | 10 | | |
12 | | - | |
13 | 11 | | |
14 | 12 | | |
15 | 13 | | |
16 | | - | |
17 | 14 | | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
18 | 33 | | |
19 | 34 | | |
20 | 35 | | |
| |||
46 | 61 | | |
47 | 62 | | |
48 | 63 | | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
| 64 | + | |
66 | 65 | | |
67 | 66 | | |
68 | 67 | | |
| |||
793 | 792 | | |
794 | 793 | | |
795 | 794 | | |
796 | | - | |
797 | | - | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
798 | 798 | | |
799 | 799 | | |
800 | 800 | | |
| |||
886 | 886 | | |
887 | 887 | | |
888 | 888 | | |
889 | | - | |
890 | | - | |
891 | | - | |
892 | | - | |
893 | 889 | | |
894 | 890 | | |
895 | 891 | | |
896 | 892 | | |
897 | | - | |
| 893 | + | |
| 894 | + | |
898 | 895 | | |
899 | 896 | | |
900 | 897 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
8 | 11 | | |
9 | 12 | | |
| 13 | + | |
10 | 14 | | |
11 | 15 | | |
12 | 16 | | |
13 | 17 | | |
14 | 18 | | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | 19 | | |
22 | 20 | | |
23 | 21 | | |
| |||
148 | 146 | | |
149 | 147 | | |
150 | 148 | | |
151 | | - | |
152 | | - | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
153 | 152 | | |
154 | 153 | | |
155 | 154 | | |
| |||
259 | 258 | | |
260 | 259 | | |
261 | 260 | | |
262 | | - | |
| 261 | + | |
263 | 262 | | |
264 | 263 | | |
265 | 264 | | |
| |||
277 | 276 | | |
278 | 277 | | |
279 | 278 | | |
280 | | - | |
281 | | - | |
282 | | - | |
283 | | - | |
284 | | - | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | | - | |
289 | | - | |
290 | | - | |
291 | | - | |
292 | | - | |
293 | | - | |
294 | | - | |
295 | | - | |
| 279 | + | |
296 | 280 | | |
297 | 281 | | |
298 | | - | |
| 282 | + | |
299 | 283 | | |
300 | 284 | | |
301 | 285 | | |
302 | 286 | | |
303 | 287 | | |
304 | 288 | | |
305 | | - | |
| 289 | + | |
306 | 290 | | |
307 | | - | |
| 291 | + | |
308 | 292 | | |
309 | 293 | | |
310 | 294 | | |
| |||
317 | 301 | | |
318 | 302 | | |
319 | 303 | | |
320 | | - | |
321 | | - | |
322 | | - | |
323 | | - | |
324 | | - | |
325 | | - | |
326 | | - | |
327 | | - | |
328 | | - | |
329 | | - | |
330 | | - | |
331 | | - | |
332 | | - | |
333 | | - | |
334 | | - | |
335 | | - | |
336 | | - | |
337 | | - | |
338 | | - | |
339 | | - | |
340 | | - | |
341 | | - | |
342 | | - | |
343 | | - | |
344 | | - | |
345 | | - | |
346 | | - | |
347 | | - | |
348 | | - | |
349 | | - | |
350 | | - | |
351 | | - | |
352 | | - | |
353 | | - | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
354 | 357 | | |
355 | | - | |
356 | | - | |
357 | | - | |
358 | | - | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
359 | 362 | | |
360 | 363 | | |
361 | 364 | | |
| |||
385 | 388 | | |
386 | 389 | | |
387 | 390 | | |
388 | | - | |
389 | | - | |
390 | | - | |
391 | | - | |
392 | | - | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
393 | 397 | | |
394 | 398 | | |
395 | 399 | | |
| |||
458 | 462 | | |
459 | 463 | | |
460 | 464 | | |
| 465 | + | |
461 | 466 | | |
462 | 467 | | |
463 | 468 | | |
| |||
0 commit comments