git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Unable to shallow fetch repository when using a object database populated by shallow fetches.

From
ZZopolis4 <creatorsmithmdt@gmail.com>
Date
May 22, 2024, 06:27 UTC
Message-ID
<CAEYL+X_R_0wfaP3UR2eDaBkaGXDAi_wSo=t9xK2DgiCm3+T6HQ@mail.gmail.com>

What did you do before the bug happened? (Steps to reproduce your issue) Create cache directory: cd /tmp mkdir cache cd cache git init --bare git config --local receive.shallowUpdate true export GIT_ALTERNATE_OBJECT_DIRECTORIES=/tmp/cache/objects

Populate cache with shallow repository: cd /tmp mkdir repo1 cd repo1 git init git fetch --depth 1 https://github.com/crystal-lang/crystal git checkout FETCH_HEAD git push /tmp/cache HEAD:refs/heads/crystal

Attempt to shallow fetch other unrelated repository: cd /tmp mkdir broken cd broken git init git fetch --depth 1 https://github.com/mint-lang/mint

What did you expect to happen? (Expected behavior) The mint repository to successfully fetch.

What happened instead? (Actual behavior)

Initialized empty Git repository in /tmp/broken/.git/ error: Could not read 2ac4b3fb4325328d347344ae738bb38d4675b82e remote: Enumerating objects: 1759, done. remote: Counting objects: 100% (1759/1759), done. remote: Compressing objects: 100% (1325/1325), done. remote: Total 1759 (delta 645), reused 833 (delta 416), pack-reused 0 Receiving objects: 100% (1759/1759), 678.36 KiB | 6.22 MiB/s, done. Resolving deltas: 100% (645/645), done. error: Could not read 2ac4b3fb4325328d347344ae738bb38d4675b82e fatal: Failed to traverse parents of commit b563cbacb3ab1af88f4ba48c1877eb3823f3a69d error: remote did not send all necessary objects

What's different between what you expected and what actually happened?
Fetching the mint repository failed rather than succeeding.
Anything else you want to add:
If the final command is replaced with 'git fetch
https://github.com/mint-lang/mint', errors are thrown but the fetch
completes successfully.
Initialized empty Git repository in /tmp/broken/.git/
error: Could not read 2ac4b3fb4325328d347344ae738bb38d4675b82e
remote: Enumerating objects: 19928, done.
remote: Counting objects: 100% (5185/5185), done.
remote: Compressing objects: 100% (1519/1519), done.
remote: Total 19928 (delta 4223), reused 3674 (delta 3666), pack-reused 14743
Receiving objects: 100% (19928/19928), 4.17 MiB | 4.54 MiB/s, done.
Resolving deltas: 100% (14600/14600), done.
From https://github.com/mint-lang/mint
 * branch              HEAD       -> FETCH_HEAD

Also, when the command to fetch the crystal repository is replaced with 'git fetch https://github.com/crystal-lang/crystal', everything works without issue.

Presumably, this means the issue lies in shallow fetching when using a shallow object database, as making either of these non-shallow means the fetch completes successfully. (Admittedly, errors are still thrown if a non-shallow fetch is performed using a shallow object database)

I was also able to reproduce the issue on git 2.45.1, but using the satmandu/crewbuild:amd64 docker container as I do not have access to git 2.45.1 on debian sid.

[System Info] git version: git version 2.43.0 cpu: x86_64 no commit associated with this build sizeof-long: 8 sizeof-size_t: 8 shell-path: /bin/sh uname: Linux 6.8.9-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.8.9-1 (2024-05-15) x86_64 compiler info: gnuc: 13.2 libc info: glibc: 2.38 $SHELL (typically, interactive shell): /usr/bin/fish

[Enabled Hooks]
Message 1 of 1 in “Unable to shallow fetch repository when using a object database populated by shallow fetches.”
  1. Zopolis4May 22, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.