3 test_description='git repack --geometric works correctly'
7 GIT_TEST_MULTI_PACK_INDEX=0
10 midx=$objdir/pack/multi-pack-index
12 test_expect_success '--geometric with no packs' '
14 test_when_finished "rm -fr geometric" &&
18 git repack --geometric 2 >out &&
19 test_i18ngrep "Nothing new to pack" out
23 test_expect_success '--geometric with one pack' '
25 test_when_finished "rm -fr geometric" &&
32 git repack --geometric 2 >out &&
34 test_i18ngrep "Nothing new to pack" out
38 test_expect_success '--geometric with an intact progression' '
40 test_when_finished "rm -fr geometric" &&
44 # These packs already form a geometric progression.
45 test_commit_bulk --start=1 1 && # 3 objects
46 test_commit_bulk --start=2 2 && # 6 objects
47 test_commit_bulk --start=4 4 && # 12 objects
49 find $objdir/pack -name "*.pack" | sort >expect &&
50 git repack --geometric 2 -d &&
51 find $objdir/pack -name "*.pack" | sort >actual &&
53 test_cmp expect actual
57 test_expect_success '--geometric with loose objects' '
59 test_when_finished "rm -fr geometric" &&
63 # These packs already form a geometric progression.
64 test_commit_bulk --start=1 1 && # 3 objects
65 test_commit_bulk --start=2 2 && # 6 objects
66 # The loose objects are packed together, breaking the
68 test_commit loose && # 3 objects
70 find $objdir/pack -name "*.pack" | sort >before &&
71 git repack --geometric 2 -d &&
72 find $objdir/pack -name "*.pack" | sort >after &&
74 comm -13 before after >new &&
75 comm -23 before after >removed &&
77 test_line_count = 1 new &&
78 test_must_be_empty removed &&
80 git repack --geometric 2 -d &&
81 find $objdir/pack -name "*.pack" | sort >after &&
83 # The progression (3, 3, 6) is combined into one new pack.
84 test_line_count = 1 after
88 test_expect_success '--geometric with small-pack rollup' '
90 test_when_finished "rm -fr geometric" &&
94 test_commit_bulk --start=1 1 && # 3 objects
95 test_commit_bulk --start=2 1 && # 3 objects
96 find $objdir/pack -name "*.pack" | sort >small &&
97 test_commit_bulk --start=3 4 && # 12 objects
98 test_commit_bulk --start=7 8 && # 24 objects
99 find $objdir/pack -name "*.pack" | sort >before &&
101 git repack --geometric 2 -d &&
103 # Three packs in total; two of the existing large ones, and one
105 find $objdir/pack -name "*.pack" | sort >after &&
106 test_line_count = 3 after &&
107 comm -3 small before | tr -d "\t" >large &&
108 grep -qFf large after
112 test_expect_success '--geometric with small- and large-pack rollup' '
113 git init geometric &&
114 test_when_finished "rm -fr geometric" &&
118 # size(small1) + size(small2) > size(medium) / 2
119 test_commit_bulk --start=1 1 && # 3 objects
120 test_commit_bulk --start=2 1 && # 3 objects
121 test_commit_bulk --start=2 3 && # 7 objects
122 test_commit_bulk --start=6 9 && # 27 objects &&
124 find $objdir/pack -name "*.pack" | sort >before &&
126 git repack --geometric 2 -d &&
128 find $objdir/pack -name "*.pack" | sort >after &&
129 comm -12 before after >untouched &&
131 # Two packs in total; the largest pack from before running "git
132 # repack", and one new one.
133 test_line_count = 1 untouched &&
134 test_line_count = 2 after
138 test_expect_success '--geometric ignores kept packs' '
139 git init geometric &&
140 test_when_finished "rm -fr geometric" &&
144 test_commit kept && # 3 objects
145 test_commit pack && # 3 objects
147 KEPT=$(git pack-objects --revs $objdir/pack/pack <<-EOF
151 PACK=$(git pack-objects --revs $objdir/pack/pack <<-EOF
157 # neither pack contains more than twice the number of objects in
158 # the other, so they should be combined. but, marking one as
159 # .kept on disk will "freeze" it, so the pack structure should
161 touch $objdir/pack/pack-$KEPT.keep &&
163 find $objdir/pack -name "*.pack" | sort >before &&
164 git repack --geometric 2 -d &&
165 find $objdir/pack -name "*.pack" | sort >after &&
167 # both packs should still exist
168 test_path_is_file $objdir/pack/pack-$KEPT.pack &&
169 test_path_is_file $objdir/pack/pack-$PACK.pack &&
171 # and no new packs should be created
172 test_cmp before after &&
174 # Passing --pack-kept-objects causes packs with a .keep file to
176 git repack --geometric 2 -d --pack-kept-objects &&
178 find $objdir/pack -name "*.pack" >after &&
179 test_line_count = 1 after