Commit 4f37e54
feat: Cache config entries by type for typed queries
Context:
The config cache only stored raw (untyped) values, so Bool and Path
queries always fell back to spawning individual git processes. Since
Git's --type flag canonicalizes values (e.g., expanding ~/... for
paths, normalizing yes/on/1 to true for bools), serving these from
the raw cache would return incorrect values.
Justification:
Instead of bypassing the cache for typed queries, we maintain a
separate cache per GitConfigurationType. Each cache is loaded with
the appropriate --type flag passed to 'git config list', so Git
performs canonicalization during the bulk load. This preserves the
correctness guarantee while extending the performance benefit to
all query types.
The cache result is now authoritative when loaded: if a key is not
found in the cache, we return 'not found' directly rather than
falling back to an individual git process call. This avoids a
redundant process spawn when the key genuinely doesn't exist.
Implementation:
Changed _cache from a single ConfigCache to a Dictionary keyed by
GitConfigurationType. EnsureCacheLoaded() now accepts a type
parameter and passes --no-type, --type=bool, or --type=path to the
git config list command. InvalidateCache() clears all type-specific
caches on any write operation.
Renamed TypedQuery_DoesNotUseCache test to
TypedQuery_CanonicalizesValues since typed queries now use their
own type-specific cache rather than bypassing the cache entirely.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 625d254 commit 4f37e54
File tree
2 files changed
+63
-23
lines changed2 files changed
+63
-23
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
634 | 634 | | |
635 | 635 | | |
636 | 636 | | |
637 | | - | |
| 637 | + | |
638 | 638 | | |
639 | 639 | | |
640 | 640 | | |
| |||
647 | 647 | | |
648 | 648 | | |
649 | 649 | | |
650 | | - | |
| 650 | + | |
| 651 | + | |
651 | 652 | | |
652 | 653 | | |
653 | 654 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
336 | 337 | | |
337 | 338 | | |
338 | 339 | | |
339 | | - | |
| 340 | + | |
340 | 341 | | |
341 | 342 | | |
342 | 343 | | |
| |||
351 | 352 | | |
352 | 353 | | |
353 | 354 | | |
354 | | - | |
| 355 | + | |
355 | 356 | | |
356 | 357 | | |
357 | | - | |
| 358 | + | |
358 | 359 | | |
359 | | - | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
360 | 389 | | |
| 390 | + | |
361 | 391 | | |
362 | | - | |
| 392 | + | |
363 | 393 | | |
364 | 394 | | |
365 | 395 | | |
| |||
369 | 399 | | |
370 | 400 | | |
371 | 401 | | |
372 | | - | |
| 402 | + | |
373 | 403 | | |
374 | 404 | | |
375 | 405 | | |
| |||
383 | 413 | | |
384 | 414 | | |
385 | 415 | | |
386 | | - | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
387 | 420 | | |
388 | 421 | | |
389 | 422 | | |
390 | 423 | | |
391 | 424 | | |
392 | 425 | | |
393 | 426 | | |
394 | | - | |
395 | | - | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
396 | 432 | | |
397 | | - | |
| 433 | + | |
398 | 434 | | |
399 | 435 | | |
400 | 436 | | |
| |||
468 | 504 | | |
469 | 505 | | |
470 | 506 | | |
471 | | - | |
472 | | - | |
| 507 | + | |
473 | 508 | | |
474 | | - | |
475 | | - | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
476 | 513 | | |
477 | | - | |
| 514 | + | |
| 515 | + | |
478 | 516 | | |
479 | 517 | | |
480 | 518 | | |
481 | | - | |
| 519 | + | |
482 | 520 | | |
483 | 521 | | |
484 | 522 | | |
| |||
583 | 621 | | |
584 | 622 | | |
585 | 623 | | |
586 | | - | |
587 | | - | |
| 624 | + | |
588 | 625 | | |
589 | | - | |
590 | | - | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
591 | 630 | | |
592 | | - | |
| 631 | + | |
593 | 632 | | |
594 | 633 | | |
595 | 634 | | |
| |||
0 commit comments