Enable sparse index to fix Git LFS performance with sparse checkouts

This commit is contained in:
Alexander Vostres 2026-03-17 22:15:29 +02:00
parent 0c366fd6a8
commit 23441d43ee
3 changed files with 13 additions and 3 deletions

View file

@ -11,6 +11,7 @@ import * as stateHelper from './state-helper'
import * as urlHelper from './url-helper'
import {
MinimumGitSparseCheckoutVersion,
MinimumGitSparseIndexVersion,
IGitCommandManager
} from './git-command-manager'
import {IGitSourceSettings} from './git-source-settings'
@ -232,9 +233,9 @@ export async function getSource(settings: IGitSourceSettings): Promise<void> {
core.endGroup()
}
let gitVersion = await git.version()
// Sparse checkout
if (!settings.sparseCheckout) {
let gitVersion = await git.version()
// no need to disable sparse-checkout if the installed git runtime doesn't even support it.
if (gitVersion.checkMinimum(MinimumGitSparseCheckoutVersion)) {
await git.disableSparseCheckout()
@ -246,6 +247,10 @@ export async function getSource(settings: IGitSourceSettings): Promise<void> {
} else {
await git.sparseCheckoutNonConeMode(settings.sparseCheckout)
}
if (gitVersion.checkMinimum(MinimumGitSparseIndexVersion)) {
await git.config('index.sparse', 'true', false)
}
core.endGroup()
}