Skip to content

Commit 6322bb8

Browse files
RajivTSfacebook-github-bot
authored andcommitted
Integration test highlighting failure in shallow clone with submodule
Summary: When shallow cloning a repo from Mononoke Git, we fetch all the objects from the root trees of the boundary commits. Before deciding to include them in the packfile, we filter out the ones specified by the filter criteria. One of the filter criteria is the size. For most entries in the Git Tree, the size constraint makes sense. As long as the entry is a blob or a tree, we look at the size to decide if it should be included or not. However, when the entry is a submodule, the concept of size makes sense. The current version of the code doesn't make an explicit bypass for submodule entry but instead tries to fetch its size and fails. This integration test highlights that problem Differential Revision: D71734349 fbshipit-source-id: 6e310cfba3096e88a8afad6785f9904d3dec5329
1 parent 9deaf12 commit 6322bb8

1 file changed

Lines changed: 80 additions & 0 deletions

File tree

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Copyright (c) Meta Platforms, Inc. and affiliates.
2+
#
3+
# This software may be used and distributed according to the terms of the
4+
# GNU General Public License found in the LICENSE file in the root
5+
# directory of this source tree.
6+
7+
$ . "${TEST_FIXTURES}/library.sh"
8+
Disable Mercurial types as they do not support git submodules
9+
$ DISABLED_DERIVED_DATA="filenodes hgchangesets hg_augmented_manifests" setup_common_config blob_files
10+
$ GIT_REPO_ORIGIN="${TESTTMP}/origin/repo-git"
11+
$ GIT_REPO_SUBMODULE="${TESTTMP}/origin/repo-submodule"
12+
$ GIT_REPO="${TESTTMP}/repo-git"
13+
14+
# Setup submodule git repository
15+
$ mkdir -p "$GIT_REPO_SUBMODULE"
16+
$ cd "$GIT_REPO_SUBMODULE"
17+
$ git init -q
18+
$ echo "this is submodule file1" > sub_file1
19+
$ git add sub_file1
20+
$ git commit -q -am "Add submodule file1"
21+
$ echo "this is submodule file2" > sub_file2
22+
$ git add sub_file2
23+
$ git commit -q -am "Add submodule file2"
24+
25+
# Setup git repository
26+
$ mkdir -p "$GIT_REPO_ORIGIN"
27+
$ cd "$GIT_REPO_ORIGIN"
28+
$ git init -q
29+
# Add few regular commits
30+
$ echo "this is file1" > file1
31+
$ git add file1
32+
$ git commit -qam "Add file1"
33+
$ git tag -a -m "new tag" first_tag
34+
$ echo "this is file2" > file2
35+
$ git add file2
36+
$ git commit -qam "Add file2"
37+
$ echo "this is file3" > file3
38+
$ git add file3
39+
$ git commit -qam "Add file3"
40+
$ git tag -a empty_tag -m ""
41+
# Add a submodule in this repository
42+
$ git submodule add "$GIT_REPO_SUBMODULE"
43+
Cloning into '$TESTTMP/origin/repo-git/repo-submodule'...
44+
done.
45+
$ git add .
46+
$ git commit -q -am "Add a new submodule"
47+
$ cd "$TESTTMP"
48+
$ git clone "$GIT_REPO_ORIGIN"
49+
Cloning into 'repo-git'...
50+
done.
51+
52+
# Import the repo into Mononoke
53+
$ cd "$TESTTMP"
54+
$ quiet gitimport "$GIT_REPO_ORIGIN" --generate-bookmarks full-repo
55+
56+
# Start up the Mononoke Git Service
57+
$ mononoke_git_service
58+
59+
# Perform a shallow clone of the repo with depth = 2 and list the commits. This should work because the submodule is not
60+
# present at this depth
61+
$ cd "$TESTTMP"
62+
$ quiet git_client clone $MONONOKE_GIT_SERVICE_BASE_URL/$REPONAME.git --depth=2
63+
$ rm -rf $REPONAME
64+
65+
# Perform a shallow clone of the repo with depth = 1 and list the commits. This should fail because we try to fetch the
66+
# size of the submodule
67+
$ git_client clone $MONONOKE_GIT_SERVICE_BASE_URL/$REPONAME.git --depth=1
68+
Cloning into 'repo'...
69+
remote: Converting HAVE Git commits to Bonsais
70+
remote: Converting WANT Git commits to Bonsais
71+
remote: Collecting Bonsai commits to send to client
72+
remote: Counting number of objects to be sent in packfile
73+
remote: Error while calculating object count during fetch
74+
75+
Caused by:
76+
0: Error while listing all entries from GitTree for changeset ChangesetId(Blake2(*)) (glob)
77+
1: No metadata for de0c53cc213a98b1382aec1dcbcb01bf088273e4
78+
fatal: early EOF
79+
fatal: fetch-pack: invalid index-pack output
80+
[128]

0 commit comments

Comments
 (0)