-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Description
I have a repository which is relatively large, so I create other repositories as clones of it with "git clone -s" to avoid duplicating the big pack files everywhere.
I then use some automated tools which perform their own "git clone -s" to do analysis and builds of that same source code, including using libgit2 on the second clone.
Unfortunately, libgit2 does not find the objects in the recursive clone, although regular "git log" works fine there.
Reproduction:
mkdir base && cd base
git init
echo "File1" >file1.txt
git add file1.txt
git commit -m 'Add file1'
cd ..
git clone -s base branch
git clone -s branch build-tree
test "x$(cat branch/.git/objects/info/alternates)" = "x${PWD}/base/.git/objects" || echo "Unexpected 'git clone' result"
test "x$(cat build-tree/.git/objects/info/alternates)" = "x${PWD}/branch/.git/objects" || echo "Unexpected 'git clone' result"
cd build-tree
git log
$MY_BUILD_TOOL ## <== uses libgit2 revwalk
Expected result:
- libgit2 revwalk iterates over the commit.
Actual result:
- libgit2 revwalk returns error -3, indicating that it cannot find the HEAD commit.
It looks relatively trivial to modify src/odb.c to make "add_default_backends()" call "load_alternates()" (which then recursively calls "add_default_backends" again), but it would be prone to infinite recursion if you had a loop. I'm not exactly convinced that's a problem, but it should probably break the loop somewhere.