Since Git 2.54.0, a cherry-pick in a blob:none partial clone can try to lazy-fetch a blob that the cherry-pick has just written to the local object store. The server never had that blob, so the fetch fails and the command dies:
Auto-merging dev-tools/go.mod Auto-merging go.mod Auto-merging testing/go.mod [bp fatal: remote error: upload-pack: not our ref 201d4490be49318c26485d10869070ae44d3e7ef fatal: could not fetch 929ed29a43110d65cb7d581c4028e3f183088c3c from promisor remote
The commit itself has been written. The failure happens while the commit summary is printed. 201d4490 is the result of the content merge of dev-tools/go.mod. It is stored as a loose object in the clone, and "git cat-file -t" with GIT_NO_LAZY_FETCH=1 reports it as a blob after the failure.
Reproduction (needs network access to github.com, takes a few seconds):
git init -q repro && cd repro
git config core.repositoryformatversion 1
git config user.name t && git config user.email t@example.com
git remote add origin https://github.com/elastic/fleet-server
git config remote.origin.promisor true
git config remote.origin.partialclonefilter blob:none
git sparse-checkout set --no-cone --stdin </dev/null
git fetch --quiet --no-tags --depth=2 origin \
+refs/heads/9.4:refs/remotes/origin/9.4 \
8e9bf0673fe59a12c889b0c087319077c4138103
git checkout --quiet -b bp origin/9.4
git cherry-pick -x 8e9bf0673fe59a12c889b0c087319077c4138103The 9.4 branch moves over time, so the exact object ids may change, but the shape of the failure should not.
Results:
- Fails on 2.54.0, 2.55.0, 2.56.0, 2.56.1 and master (7fb6055e67).
- Succeeds on 2.47.3, 2.48.1, 2.50.1, 2.52.0 and 2.53.0.
- "git bisect" between v2.53.0 and v2.54.0 names:
5946a564cd odb/source: make `read_object_info()` function pluggableMy reading of that commit: before it, a lookup miss without OBJECT_INFO_QUICK called odb_reprepare(), which also dropped the loose object cache. Since then, the second read flushes only the packfile store. The loose object cache is filled per fan-out directory and is not updated when an object is written. So once a directory has been scanned, a loose object written into it afterwards stays invisible to OBJECT_INFO_QUICK lookups such as the OBJECT_INFO_FOR_PREFETCH check in the diff prefetch. git then puts that object in the promisor fetch. In the case above, the base blob of dev-tools/go.mod (2070e6a...) and the merged blob (201d449...) share the "20/" directory, which fits.
To check this, I applied the change below on master. With it, the reproduction succeeds:
--- a/odb/source-files.c +++ b/odb/source-files.c @@ static enum odb_read_status odb_source_files_read_object_info( for (struct odb_files_dir *dir = files->dirs; dir; dir = dir->next) { - if (retry) + if (retry) { odb_source_prepare(&dir->packed->base, ODB_PREPARE_FLUSH_CACHES); + odb_source_prepare(&dir->loose->base, ODB_PREPARE_FLUSH_CACHES); + } This is a check, not a proposed fix. Updating the loose cache when an object is written may be the better fix. I'm happy to test patches against this reproduction. We run git this way in production (blob:none partial clones, cherry-pick, merge-tree). This hit cherry-picks in several unrelated public and private repositories, and on each repository it fails the same way on every attempt. We have gone back to 2.53 until this is fixed.