From 59f3947857c5ec8a8cb178ba20b3f972308b3bd7 Mon Sep 17 00:00:00 2001 From: Elijah Newren Date: Wed, 16 Jan 2019 11:39:23 -0800 Subject: [PATCH] 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 --- git-filter-repo | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/git-filter-repo b/git-filter-repo index 50e9659..92581ee 100755 --- a/git-filter-repo +++ b/git-filter-repo @@ -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