Commit 87c2a39
committed
Return None from submodules.get() for a nested plain repository
libgit2's git_submodule_lookup reports GIT_EEXISTS, not GIT_ENOTFOUND, when
a repository exists at the path but was never registered as a submodule.
check_error turns that into AlreadyExistsError, which get() did not catch, so
it raised instead of returning None as its docstring promises. __contains__
is built on get(), so `name in repo.submodules` raised for the same input.
__getitem__ keeps raising AlreadyExistsError, so callers that need to tell
"a repository is there" from "nothing is there" still can.
Fixes #1405
Assisted-by: Claude Code (Claude Opus 5)1 parent d532da7 commit 87c2a39
2 files changed
Lines changed: 25 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
| 35 | + | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| |||
210 | 210 | | |
211 | 211 | | |
212 | 212 | | |
213 | | - | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
214 | 218 | | |
215 | 219 | | |
216 | 220 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
71 | 90 | | |
72 | 91 | | |
73 | 92 | | |
| |||
0 commit comments