Skip to content

Commit b1fae48

Browse files
committed
filter-repo: relax the definition of freshly packed
transfer.unpackLimit defaults to 100, meaning that if less than 100 objects exist in the repository, git will automatically unpack the objects to be loose as part of the clone operation. So, if there are no packs and less than 100 objects, consider the repo to be freshly packed for purposes of our fresh clone sanity checks. Signed-off-by: Elijah Newren <[email protected]>
1 parent fe33fc4 commit b1fae48

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

git-filter-repo

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2846,11 +2846,17 @@ class RepoFilter(object):
28462846
" (%s)\n"
28472847
"To override, use --force.") % reason)
28482848

2849-
# Make sure repo is fully packed, just like a fresh clone would be
2849+
# Make sure repo is fully packed, just like a fresh clone would be.
2850+
# Note that transfer.unpackLimit defaults to 100, meaning that a
2851+
# repository with no packs and less than 100 objects should be considered
2852+
# fully packed.
28502853
output = subproc.check_output('git count-objects -v'.split())
28512854
stats = dict(x.split(b': ') for x in output.splitlines())
28522855
num_packs = int(stats[b'packs'])
2853-
if stats[b'count'] != b'0' or num_packs > 1:
2856+
num_loose_objects = int(stats[b'count'])
2857+
if num_packs > 1 or \
2858+
(num_packs == 1 and num_loose_objects > 0) or \
2859+
num_loose_objects >= 100:
28542860
abort(_("expected freshly packed repo"))
28552861

28562862
# Make sure there is precisely one remote, named "origin"...or that this

0 commit comments

Comments
 (0)