mirror of
https://github.com/newren/git-filter-repo.git
synced 2024-07-06 18:32:14 +02:00
filter-repo: move git_dir determination into function for future re-use
Signed-off-by: Elijah Newren <newren@gmail.com>
This commit is contained in:
parent
4fed91af18
commit
40f90c9cb8
@ -1119,6 +1119,10 @@ def is_repository_bare():
|
||||
output = subprocess.check_output('git rev-parse --is-bare-repository'.split())
|
||||
return (output.strip() == 'true')
|
||||
|
||||
def determine_git_dir():
|
||||
output = subprocess.check_output('git rev-parse --git-dir'.split())
|
||||
return output.strip()
|
||||
|
||||
def sanity_check(refs, is_bare):
|
||||
def abort(reason):
|
||||
raise SystemExit(
|
||||
@ -1140,7 +1144,7 @@ def sanity_check(refs, is_bare):
|
||||
|
||||
# Avoid letting people running with weird setups and overwriting GIT_DIR
|
||||
# elsewhere
|
||||
git_dir = subprocess.check_output('git rev-parse --git-dir'.split()).strip()
|
||||
git_dir = determine_git_dir()
|
||||
if is_bare and git_dir != '.':
|
||||
abort("GIT_DIR must be .")
|
||||
elif not is_bare and git_dir != '.git':
|
||||
@ -1208,8 +1212,12 @@ def tweak_commit(args, commit):
|
||||
|
||||
def run_fast_filter():
|
||||
args = get_args()
|
||||
|
||||
# Determine basic repository information
|
||||
orig_refs = get_refs()
|
||||
is_bare = is_repository_bare()
|
||||
|
||||
# Do sanity checks
|
||||
if not args.force:
|
||||
sanity_check(orig_refs, is_bare)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user