Skip to content

Commit f165743

Browse files
committed
Merge branch 'ts/unpacklimit-config-fix' into HEAD
* ts/unpacklimit-config-fix: SQUASH??? Fix the order of consuming unpackLimit config settings.
2 parents 51ce82a + 4c77743 commit f165743

File tree

3 files changed

+38
-9
lines changed

3 files changed

+38
-9
lines changed

builtin/receive-pack.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2527,10 +2527,10 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix)
25272527
if (cert_nonce_seed)
25282528
push_cert_nonce = prepare_push_cert_nonce(service_dir, time(NULL));
25292529

2530-
if (0 <= transfer_unpack_limit)
2531-
unpack_limit = transfer_unpack_limit;
2532-
else if (0 <= receive_unpack_limit)
2530+
if (0 <= receive_unpack_limit)
25332531
unpack_limit = receive_unpack_limit;
2532+
else if (0 <= transfer_unpack_limit)
2533+
unpack_limit = transfer_unpack_limit;
25342534

25352535
switch (determine_protocol_version_server()) {
25362536
case protocol_v2:

fetch-pack.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1911,10 +1911,10 @@ static void fetch_pack_setup(void)
19111911
if (did_setup)
19121912
return;
19131913
fetch_pack_config();
1914-
if (0 <= transfer_unpack_limit)
1915-
unpack_limit = transfer_unpack_limit;
1916-
else if (0 <= fetch_unpack_limit)
1914+
if (0 <= fetch_unpack_limit)
19171915
unpack_limit = fetch_unpack_limit;
1916+
else if (0 <= transfer_unpack_limit)
1917+
unpack_limit = transfer_unpack_limit;
19181918
did_setup = 1;
19191919
}
19201920

t/t5546-receive-limits.sh

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,26 @@ TEST_PASSES_SANITIZE_LEAK=true
99
# When the limit is 1, `git receive-pack` will call `git index-pack`.
1010
# When the limit is 10000, `git receive-pack` will call `git unpack-objects`.
1111

12+
validate_store_type () {
13+
git -C dest count-objects -v >actual &&
14+
case "$store_type" in
15+
index)
16+
grep "^count: 0$" actual ;;
17+
unpack)
18+
grep "^packs: 0$" actual ;;
19+
esac || {
20+
echo "store_type is $store_type"
21+
cat actual
22+
false;
23+
}
24+
}
25+
1226
test_pack_input_limit () {
13-
case "$1" in
14-
index) unpack_limit=1 ;;
15-
unpack) unpack_limit=10000 ;;
27+
store_type=$1
28+
29+
case "$store_type" in
30+
index) unpack_limit=1 other_limit=10000 ;;
31+
unpack) unpack_limit=10000 other_limit=1 ;;
1632
esac
1733

1834
test_expect_success 'prepare destination repository' '
@@ -43,6 +59,19 @@ test_pack_input_limit () {
4359
git --git-dir=dest config receive.maxInputSize 0 &&
4460
git push dest HEAD
4561
'
62+
63+
test_expect_success 'prepare destination repository (once more)' '
64+
rm -fr dest &&
65+
git --bare init dest
66+
'
67+
68+
test_expect_success 'receive trumps transfer' '
69+
git --git-dir=dest config receive.unpacklimit "$unpack_limit" &&
70+
git --git-dir=dest config transfer.unpacklimit "$other_limit" &&
71+
git push dest HEAD &&
72+
validate_store_type
73+
'
74+
4675
}
4776

4877
test_expect_success "create known-size (1024 bytes) commit" '

0 commit comments

Comments
 (0)