A sparse checkout's blob:none filter persists into later full checkouts on self-hosted runners
On a self-hosted runner that reuses the workspace, a job that uses sparse-checkout leaves the repository a partial clone, and later jobs that check out the same repository without sparse-checkout stay partial. Their fetches keep applying blob:none, so historical blobs are missing even with fetch-depth: 0.
#1475 fixed the same leftover for the sparse-checkout settings (via #1598), but not for the partial-clone filter that the sparse checkout also sets.
Versions
actions/checkout v7.0.1 (3d3c42e) and main (src/ is identical at both), git 2.43.0 on the runner, 2.54.0 for the replay below.
Steps to reproduce
Two jobs of one repository run one after the other on the same self-hosted runner:
# Job 1
- uses: actions/checkout@v7
with:
sparse-checkout: .github
# Job 2, later, same runner
- uses: actions/checkout@v7
with:
fetch-depth: 0
- run: |
git config --get remote.origin.promisor
git config --get remote.origin.partialclonefilter
git rev-list --objects --all --missing=print | grep -c '^?'
The same thing replayed with the git commands the action runs, against this repository:
work=$(mktemp -d) && cd "$work"
url=https://github.com/actions/checkout.git
sha=$(git ls-remote "$url" refs/heads/main | cut -f1)
git init -q w && cd w
git remote add origin "$url"
# Job 1: sparse-checkout
git -c protocol.version=2 fetch -q --no-tags --prune --no-recurse-submodules \
--filter=blob:none --depth=1 origin "+$sha:refs/remotes/origin/main"
git sparse-checkout set .github
git checkout -q --force -B main refs/remotes/origin/main
# Job 2 in the same directory: fetch-depth: 0, no sparse-checkout
git sparse-checkout disable
git config --unset extensions.worktreeConfig || true
git -c protocol.version=2 fetch -q --no-tags --prune --no-recurse-submodules \
--unshallow origin '+refs/heads/*:refs/remotes/origin/*' '+refs/tags/*:refs/tags/*'
git checkout -q --force -B main refs/remotes/origin/main
git config --get remote.origin.promisor # true
git config --get remote.origin.partialclonefilter # blob:none
git rev-list --objects --all --missing=print | grep -c '^?' # 1172
Expected
Job 2 gets a full clone, as it would in a fresh workspace: no promisor remote, no filter, no missing objects.
Actual
remote.origin.promisor=true and remote.origin.partialclonefilter=blob:none stay in .git/config. Job 2's fetch has no --filter on its command line, but git applies the stored filter (GIT_TRACE_PACKET shows fetch> filter blob:none), so 1172 objects are missing after --unshallow.
Most git commands then fetch each missing blob lazily, so the job usually still works. It fails when a missing blob has to be read without that, for example:
- with
persist-credentials: falseon a private repository, where the lazy fetch has no credentials; - in a second repository that borrows objects through
.git/objects/info/alternates, which fails witherror: invalid object 100644 <blob> for '<path>'andfatal: git-write-tree: error building trees.
It persists until the workspace is deleted, and every later sparse job on the runner sets it again.
Cause
- A sparse checkout fetches with
blob:nonewhen nofilteris given (src/git-source-provider.ts#L182-L186). git recordsremote.origin.promisorandremote.origin.partialclonefilterthe first time a repository fetches with--filter, and later fetches from that remote apply the stored filter. - On a later run without
sparse-checkout, the action callsdisableSparseCheckout()(src/git-source-provider.ts#L252-L258), which runsgit sparse-checkout disableand unsetsextensions.worktreeConfig(src/git-command-manager.ts#L196-L200). Nothing insrc/touchesremote.origin.promisororremote.origin.partialclonefilter, andgit-directory-helper.tskeeps the existing repository.
Suggested fix
When neither filter nor sparse-checkout is set and the existing repository has remote.origin.promisor, either delete the repository and clone fresh, or unset remote.origin.promisor and remote.origin.partialclonefilter and then fetch with --refetch (git 2.36+). Unsetting the two keys without --refetch is not enough once history was fetched with the filter: a plain fetch afterwards still leaves the 1172 objects missing, and with the promisor gone git can no longer fetch them lazily, so reading an old blob fails with fatal: unable to read <blob>. With --refetch after unsetting, the replay above ends with no missing objects.
Workaround
Run this after actions/checkout in jobs that need a full clone on a self-hosted runner:
if git config --get remote.origin.promisor > /dev/null; then
git config --unset-all remote.origin.promisor
git config --unset-all remote.origin.partialclonefilter || true
git fetch --refetch --no-tags origin '+refs/heads/*:refs/remotes/origin/*' '+refs/tags/*:refs/tags/*' "$(git rev-parse HEAD)"
fi
Or avoid sparse-checkout and filter on runners that reuse their workspace.
Related: #1475, #1598, #1992, #2249.