Skip to content

Commit 0d196b3

Browse files
committed
WIP: add a test for push --path-walk not reusing deltas
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent 39887e4 commit 0d196b3

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

t/t5590-push-path-walk.sh

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/bin/sh
2+
3+
test_description='verify that push respects `pack.usePathWalk`'
4+
5+
TEST_PASSES_SANITIZE_LEAK=true
6+
. ./test-lib.sh
7+
. "$TEST_DIRECTORY"/lib-pack.sh
8+
9+
test_expect_success 'setup bare repository and clone' '
10+
git init --bare -b main bare.git &&
11+
git --git-dir bare.git commit-tree -m initial $EMPTY_TREE >head_oid &&
12+
git --git-dir bare.git update-ref refs/heads/main $(cat head_oid) &&
13+
git clone --bare bare.git clone.git
14+
'
15+
test_expect_success 'avoid reusing deltified objects' '
16+
x="0123456789abcdef" &&
17+
printf "$x$x$x$x$x$x$x$x" >x128 &&
18+
printf "$x$x$x$x$x$x$x$x$x$x$x$x$x$x$x$x" >x256 &&
19+
oid128=$(git hash-object x128) &&
20+
oid256=$(git hash-object x256) &&
21+
22+
pack=clone.git/objects/pack/pack-tmp.pack &&
23+
pack_header 2 >$pack &&
24+
25+
# add x256 as a non-deltified object, using uncompressed zlib for simplicity
26+
# 0x30 = OBJ_BLOB << 4, 0x80 = size larger than 15, 0x0 = lower 4 bits of size, 0x10 = bits 5-9 of size (size = 256)
27+
printf "\xb0\x10" >>$pack &&
28+
# Uncompressed zlib stream always starts with 0x78 0x01 0x01, followed
29+
# by two bytes encoding the size, little endian, then two bytes with
30+
# the bitwise-complement of that size, then the payload, and then the
31+
# Adler32 checksum. For some reason, the checksum is in big-endian format.
32+
printf "\x78\x01\x01\0\x01\xff\xfe" >>$pack &&
33+
cat x256 >>$pack &&
34+
# Manually-computed Adler32 checksum: 0xd7ae4621
35+
printf "\xd7\xae\x46\x21" >>$pack &&
36+
37+
# add x128 as a very badly deltified object
38+
# 0x60 = OBJ_OFS_DELTA << 4, 0x80 = total size larger than 15, 0x4 = lower 4 bits of size, 0x03 = bits 5-9 of size (size = 128 * 3 + 2 + 2)
39+
printf "\xe4\x18" >>$pack &&
40+
# 0x010d = size (i.e. the relative negative offset) of the previous object (x256, used as base object)
41+
# encoded as 0x80 | ((0x010d >> 7) - 1), 0x010d & 0x7f
42+
printf "\x81\x0d" >>$pack &&
43+
# Uncompressed zlib stream, as before, size = 2 + 2 + 128 * 3 (i.e. 0x184)
44+
printf "\x78\x01\x01\x84\x01\x7b\xfe" >>$pack &&
45+
# base object size = 0x0100 (encoded as 0x80 | (0x0100 & 0x7f), 0x0100 >> 7
46+
printf "\x80\x02" >>$pack &&
47+
# object size = 0x80 (encoded as 0x80 | (0x80 & 0x7f), 0x80 >> 7
48+
printf "\x80\x01" >>$pack &&
49+
# enourmously badly-deltified object: copy every single byte individually
50+
# 0x80 = copy, 0x01 = use 1 byte to encode the offset (0), 0x10 = use 1 byte to encode the size (1, i.e. 0x01)
51+
printf "$(printf "\\\\x91\\\\x%02x\\\\x01" $(test_seq 0 127))" >>$pack &&
52+
# Manually-computed Adler32 checksum: 0x99c369c4
53+
printf "\x99\xc3\x69\xc4" >>$pack &&
54+
55+
pack_trailer $pack &&
56+
git index-pack -v $pack
57+
'
58+
59+
test_done

0 commit comments

Comments
 (0)