filter-repo: allow importing into a bare repository

If we are using --stdin, it should be okay to import into a bare repo,
but the checks were enforcing that we were in a clone with a packfile.
Relax the check to work within a bare repo as well.

Signed-off-by: Elijah Newren <newren@gmail.com>
This commit is contained in:
Elijah Newren 2019-01-16 11:39:23 -08:00
parent 6fffed6bb1
commit 59f3947857

View File

@ -2415,12 +2415,14 @@ class RepoFilter(object):
# Make sure repo is fully packed, just like a fresh clone would be
output = subprocess.check_output('git count-objects -v'.split())
stats = dict(x.split(': ') for x in output.splitlines())
if stats['count'] != '0' or stats['packs'] != '1':
num_packs = int(stats['packs'])
if stats['count'] != '0' or num_packs > 1:
abort("expected freshly packed repo")
# Make sure there is precisely one remote, named "origin"
# Make sure there is precisely one remote, named "origin"...or that this
# is a new bare repo with no packs and no remotes
output = subprocess.check_output('git remote'.split()).strip()
if output != "origin":
if not (output == "origin" or (num_packs == 0 and not output)):
abort("expected one remote, origin")
# Avoid letting people running with weird setups and overwriting GIT_DIR