Commit eb0d445
refactor: Use git config --show-scope for reliable level detection
Context:
The original implementation inferred GitConfigurationLevel by parsing
file paths from config origins (e.g., checking if path contains
"/.gitconfig" for global). This approach is error-prone because:
- Path conventions vary across platforms and Git installations
- System config can be in multiple locations (prefix-dependent)
- Custom config paths break the path-based detection
- Worktree configs weren't handled
Justification:
Git's --show-scope flag directly reports whether each config entry is
from system, global, local, worktree, or command line scope. Using this
flag eliminates path-parsing heuristics and defers to Git's
authoritative knowledge of config scope.
Implementation:
- Replaced DetermineLevel() path-parsing logic with ParseScope() that
maps Git's scope strings directly to GitConfigurationLevel enum
- Updated ConfigCache.Load() to parse scope field from git output
- Updated EnsureCacheLoaded() to include --show-scope flag
- ConfigCacheEntry constructor now accepts level directly
Scope parsing maps: system/global/local/worktree → enum values,
treating worktree as local (both are repository-specific).
All 52 tests pass with this change.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>1 parent 625d254 commit eb0d445
File tree
1 file changed
+38
-29
lines changed1 file changed
+38
-29
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
120 | | - | |
| 120 | + | |
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
124 | | - | |
| 124 | + | |
125 | 125 | | |
126 | 126 | | |
127 | | - | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
128 | 131 | | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
151 | 141 | | |
152 | 142 | | |
153 | 143 | | |
| |||
167 | 157 | | |
168 | 158 | | |
169 | 159 | | |
| 160 | + | |
170 | 161 | | |
171 | 162 | | |
172 | 163 | | |
173 | 164 | | |
174 | 165 | | |
175 | 166 | | |
176 | 167 | | |
| 168 | + | |
177 | 169 | | |
178 | 170 | | |
179 | 171 | | |
180 | 172 | | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
181 | 190 | | |
182 | 191 | | |
183 | 192 | | |
| |||
224 | 233 | | |
225 | 234 | | |
226 | 235 | | |
227 | | - | |
| 236 | + | |
228 | 237 | | |
229 | 238 | | |
230 | 239 | | |
| |||
359 | 368 | | |
360 | 369 | | |
361 | 370 | | |
362 | | - | |
| 371 | + | |
363 | 372 | | |
364 | 373 | | |
365 | 374 | | |
| |||
372 | 381 | | |
373 | 382 | | |
374 | 383 | | |
375 | | - | |
376 | | - | |
| 384 | + | |
| 385 | + | |
377 | 386 | | |
378 | 387 | | |
379 | 388 | | |
| |||
0 commit comments