test(git): cover the false-positive class the header fix also removes (#10547)

The old anchored regex matched neither branch on a `[section "sub"]key = value`
line, so the parser never left `[core]` and credited the next indented line to
it — reporting sparse for a worktree git says is not. Fails on the pre-fix
parser (returns true where git reports unset).
This commit is contained in:
Brennan Benson 2026-07-25 04:36:40 -07:00 committed by GitHub
parent baf25785e0
commit 159057c5d4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 11 additions and 0 deletions

View File

@ -174,6 +174,17 @@ describe('parseCoreSparseCheckoutFlag', () => {
expect(parseCoreSparseCheckoutFlag('[core "sub"] sparseCheckout = true\n')).toBeUndefined()
})
it('leaves [core] when a subsection header carries its own same-line assignment', () => {
// A `[section "sub"]key = value` line matched neither branch of the old anchored regex, so the
// parser never left `[core]` and credited the next indented line to it — a bogus sparse badge.
// Git reports core.sparseCheckout as unset here.
expect(
parseCoreSparseCheckoutFlag(
'[core]\n[core "sub"]worktreeConfig = x\n\tsparseCheckout = true\n'
)
).toBeUndefined()
})
it('honors the last assignment across mixed same-line and indented forms', () => {
expect(
parseCoreSparseCheckoutFlag(