Merge branch 'ab/refs-various-fixes'
[alt-git.git] / t / t9302-fast-import-unpack-limit.sh
blobd8b1f9442e8f6e020d2e3ff736cf4853f3b47036
1 #!/bin/sh
2 test_description='test git fast-import unpack limit'
4 TEST_PASSES_SANITIZE_LEAK=true
5 . ./test-lib.sh
7 test_expect_success 'create loose objects on import' '
8 test_tick &&
9 cat >input <<-INPUT_END &&
10 commit refs/heads/main
11 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
12 data <<COMMIT
13 initial
14 COMMIT
16 done
17 INPUT_END
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
25 test_expect_success 'bigger packs are preserved' '
26 test_tick &&
27 cat >input <<-INPUT_END &&
28 commit refs/heads/main
29 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
30 data <<COMMIT
31 incremental should create a pack
32 COMMIT
33 from refs/heads/main^0
35 commit refs/heads/branch
36 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
37 data <<COMMIT
38 branch
39 COMMIT
41 done
42 INPUT_END
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
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" &&
53 before=$(git rev-parse refs/heads/main^0) &&
55 cat <<-INPUT_END &&
56 blob
57 mark :1
58 data 6
59 hello
61 commit refs/heads/main
62 mark :2
63 committer $id
64 data <<COMMIT
65 checkpoint after this
66 COMMIT
67 from refs/heads/main^0
68 M 100644 :1 hello
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
79 n=0 &&
80 from=$before &&
81 while test x"$from" = x"$before"
83 if test $n -gt 30
84 then
85 echo >&2 "checkpoint did not update branch" &&
86 exit 1
87 else
88 n=$(($n + 1))
89 fi &&
90 sleep 1 &&
91 from=$(git rev-parse refs/heads/main^0)
92 done &&
93 cat <<-INPUT_END &&
94 commit refs/heads/main
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
107 test_done