Allow filter: none to disable the implicit blob:none for sparse checkout

When sparse-checkout is set and filter is not, checkout fetches with
--filter=blob:none. If the sparse patterns keep most of the repository,
the following checkout fetches each blob lazily from the promisor remote,
which is slower than one full pack.

Setting filter to 'none' now fetches without a filter. 'none' is not a
valid git filter-spec, so no existing workflow can depend on it.

The effective filter is now resolved in input-helper, so
git-source-provider has one decision point.
This commit is contained in:
Jellyfrog 2026-10-02 01:45:20 +02:00
parent f548e57e54
commit 4fba4c42af
8 changed files with 110 additions and 22 deletions

View file

@ -181,8 +181,6 @@ export async function getSource(settings: IGitSourceSettings): Promise<void> {
if (settings.filter) {
fetchOptions.filter = settings.filter
} else if (settings.sparseCheckout) {
fetchOptions.filter = 'blob:none'
}
if (settings.fetchDepth <= 0) {

View file

@ -30,7 +30,8 @@ export interface IGitSourceSettings {
clean: boolean
/**
* The filter determining which objects to include
* The filter determining which objects to include.
* Defaults to 'blob:none' when sparse checkout is set, unless the input is 'none'.
*/
filter: string | undefined

View file

@ -100,14 +100,6 @@ export async function getInputs(): Promise<IGitSourceSettings> {
result.clean = (core.getInput('clean') || 'true').toUpperCase() === 'TRUE'
core.debug(`clean = ${result.clean}`)
// Filter
const filter = core.getInput('filter')
if (filter) {
result.filter = filter
}
core.debug(`filter = ${result.filter}`)
// Sparse checkout
const sparseCheckout = core.getMultilineInput('sparse-checkout')
if (sparseCheckout.length) {
@ -115,6 +107,20 @@ export async function getInputs(): Promise<IGitSourceSettings> {
core.debug(`sparse checkout = ${result.sparseCheckout}`)
}
// Filter
// Sparse checkout implies 'blob:none' unless a filter is given.
// 'none' disables the filter.
const filter = core.getInput('filter')
if (filter.toUpperCase() === 'NONE') {
result.filter = undefined
} else if (filter) {
result.filter = filter
} else if (result.sparseCheckout) {
result.filter = 'blob:none'
}
core.debug(`filter = ${result.filter}`)
result.sparseCheckoutConeMode =
(core.getInput('sparse-checkout-cone-mode') || 'true').toUpperCase() ===
'TRUE'