Skip to content

Commit d1169be

Browse files
committed
Merge branch 'dd/upload-pack-stateless-eof'
"git fetch --depth=<n>" over the stateless RPC / smart HTTP transport handled EOF from the client poorly at the server end. * dd/upload-pack-stateless-eof: upload-pack: allow stateless client EOF just prior to haves
2 parents e31aba4 + fb3d1a0 commit d1169be

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

t/t5530-upload-pack-error.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,23 @@ test_expect_success 'upload-pack fails due to error in pack-objects enumeration'
8888
grep "pack-objects died" output.err
8989
'
9090

91+
test_expect_success 'upload-pack tolerates EOF just after stateless client wants' '
92+
test_commit initial &&
93+
head=$(git rev-parse HEAD) &&
94+
95+
{
96+
packetize "want $head" &&
97+
packetize "shallow $head" &&
98+
packetize "deepen 1" &&
99+
printf "0000"
100+
} >request &&
101+
102+
printf "0000" >expect &&
103+
104+
git upload-pack --stateless-rpc . <request >actual &&
105+
test_cmp expect actual
106+
'
107+
91108
test_expect_success 'create empty repository' '
92109
93110
mkdir foo &&

upload-pack.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1344,7 +1344,18 @@ void upload_pack(struct upload_pack_options *options)
13441344
PACKET_READ_DIE_ON_ERR_PACKET);
13451345

13461346
receive_needs(&data, &reader);
1347-
if (data.want_obj.nr) {
1347+
1348+
/*
1349+
* An EOF at this exact point in negotiation should be
1350+
* acceptable from stateless clients as they will consume the
1351+
* shallow list before doing subsequent rpc with haves/etc.
1352+
*/
1353+
if (data.stateless_rpc)
1354+
reader.options |= PACKET_READ_GENTLE_ON_EOF;
1355+
1356+
if (data.want_obj.nr &&
1357+
packet_reader_peek(&reader) != PACKET_READ_EOF) {
1358+
reader.options &= ~PACKET_READ_GENTLE_ON_EOF;
13481359
get_common_commits(&data, &reader);
13491360
create_pack_file(&data, NULL);
13501361
}

0 commit comments

Comments
 (0)