]>
Commit | Line | Data |
---|---|---|
d9545c7f EW |
1 | #!/bin/sh |
2 | test_description='test git fast-import unpack limit' | |
4567e9c5 ÆAB |
3 | |
4 | TEST_PASSES_SANITIZE_LEAK=true | |
d9545c7f EW |
5 | . ./test-lib.sh |
6 | ||
7 | test_expect_success 'create loose objects on import' ' | |
8 | test_tick && | |
9 | cat >input <<-INPUT_END && | |
a881baa2 | 10 | commit refs/heads/main |
d9545c7f EW |
11 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
12 | data <<COMMIT | |
13 | initial | |
14 | COMMIT | |
15 | ||
16 | done | |
17 | INPUT_END | |
18 | ||
19 | git -c fastimport.unpackLimit=2 fast-import --done <input && | |
20 | git fsck --no-progress && | |
21 | test $(find .git/objects/?? -type f | wc -l) -eq 2 && | |
22 | test $(find .git/objects/pack -type f | wc -l) -eq 0 | |
23 | ' | |
24 | ||
25 | test_expect_success 'bigger packs are preserved' ' | |
26 | test_tick && | |
27 | cat >input <<-INPUT_END && | |
a881baa2 | 28 | commit refs/heads/main |
d9545c7f EW |
29 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
30 | data <<COMMIT | |
31 | incremental should create a pack | |
32 | COMMIT | |
a881baa2 | 33 | from refs/heads/main^0 |
d9545c7f EW |
34 | |
35 | commit refs/heads/branch | |
36 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
37 | data <<COMMIT | |
38 | branch | |
39 | COMMIT | |
40 | ||
41 | done | |
42 | INPUT_END | |
43 | ||
44 | git -c fastimport.unpackLimit=2 fast-import --done <input && | |
45 | git fsck --no-progress && | |
46 | test $(find .git/objects/?? -type f | wc -l) -eq 2 && | |
47 | test $(find .git/objects/pack -type f | wc -l) -eq 2 | |
48 | ' | |
49 | ||
d2986d0f EW |
50 | test_expect_success 'lookups after checkpoint works' ' |
51 | hello_id=$(echo hello | git hash-object --stdin -t blob) && | |
52 | id="$GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE" && | |
a881baa2 | 53 | before=$(git rev-parse refs/heads/main^0) && |
d2986d0f EW |
54 | ( |
55 | cat <<-INPUT_END && | |
56 | blob | |
57 | mark :1 | |
58 | data 6 | |
59 | hello | |
60 | ||
a881baa2 | 61 | commit refs/heads/main |
d2986d0f EW |
62 | mark :2 |
63 | committer $id | |
64 | data <<COMMIT | |
65 | checkpoint after this | |
66 | COMMIT | |
a881baa2 | 67 | from refs/heads/main^0 |
d2986d0f EW |
68 | M 100644 :1 hello |
69 | ||
70 | # pre-checkpoint | |
71 | cat-blob :1 | |
72 | cat-blob $hello_id | |
73 | checkpoint | |
74 | # post-checkpoint | |
75 | cat-blob :1 | |
76 | cat-blob $hello_id | |
77 | INPUT_END | |
78 | ||
79 | n=0 && | |
80 | from=$before && | |
81 | while test x"$from" = x"$before" | |
82 | do | |
83 | if test $n -gt 30 | |
84 | then | |
cff4243d | 85 | echo >&2 "checkpoint did not update branch" && |
d2986d0f EW |
86 | exit 1 |
87 | else | |
88 | n=$(($n + 1)) | |
89 | fi && | |
90 | sleep 1 && | |
a881baa2 | 91 | from=$(git rev-parse refs/heads/main^0) |
d2986d0f EW |
92 | done && |
93 | cat <<-INPUT_END && | |
a881baa2 | 94 | commit refs/heads/main |
d2986d0f EW |
95 | committer $id |
96 | data <<COMMIT | |
97 | make sure from "unpacked sha1 reference" works, too | |
98 | COMMIT | |
99 | from $from | |
100 | INPUT_END | |
101 | echo done | |
102 | ) | git -c fastimport.unpackLimit=100 fast-import --done && | |
103 | test $(find .git/objects/?? -type f | wc -l) -eq 6 && | |
104 | test $(find .git/objects/pack -type f | wc -l) -eq 2 | |
105 | ' | |
106 | ||
d9545c7f | 107 | test_done |