Skip to content

Commit 7103d25

Browse files
grnchgitster
authored andcommitted
remote-curl: main test case for the OS command line overflow
This is main test case for the original problem that triggered this patch series. We create a repo with 50k tags and then test whether git-clone over the smart HTTP protocol succeeds. Note that we construct the repo in a slightly different way than the original script used to reproduce the problem. This is because the original script just created 50k tags all pointing to the same commit, so if there was a bug where remote-curl.c was not passing all the refs to fetch-pack we wouldn't know. The clone would succeed even if only one tag was passed, because all the other tags were pointing at the same SHA and would be considered present. Instead we create a repo with 50k independent (dangling) commits and then tag each of those commits with a unique tag. This way if one of the tags is not given to fetch-pack, later stages of the clone would complain about it. This allows us to test both that the command line overflow was fixed, as well as that it was fixed in a way that doesn't leave out any of the refs. Signed-off-by: Ivan Todoroski <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b2a9f4d commit 7103d25

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

t/t5551-http-fetch.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,5 +109,36 @@ test_expect_success 'follow redirects (302)' '
109109
git clone $HTTPD_URL/smart-redir-temp/repo.git --quiet repo-t
110110
'
111111

112+
test -n "$GIT_TEST_LONG" && test_set_prereq EXPENSIVE
113+
114+
test_expect_success EXPENSIVE 'create 50,000 tags in the repo' '
115+
(
116+
cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
117+
for i in `seq 50000`
118+
do
119+
echo "commit refs/heads/too-many-refs"
120+
echo "mark :$i"
121+
echo "committer git <[email protected]> $i +0000"
122+
echo "data 0"
123+
echo "M 644 inline bla.txt"
124+
echo "data 4"
125+
echo "bla"
126+
# make every commit dangling by always
127+
# rewinding the branch after each commit
128+
echo "reset refs/heads/too-many-refs"
129+
echo "from :1"
130+
done | git fast-import --export-marks=marks &&
131+
132+
# now assign tags to all the dangling commits we created above
133+
tag=$(perl -e "print \"bla\" x 30") &&
134+
sed -e "s/^:\(.\+\) \(.\+\)$/\2 refs\/tags\/$tag-\1/" <marks >>packed-refs
135+
)
136+
'
137+
138+
test_expect_success EXPENSIVE 'clone the 50,000 tag repo to check OS command line overflow' '
139+
git clone $HTTPD_URL/smart/repo.git too-many-refs 2>err &&
140+
test_line_count = 0 err
141+
'
142+
112143
stop_httpd
113144
test_done

0 commit comments

Comments
 (0)