Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add speedup_options cache #857

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion alibuild_helpers/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,21 @@
}
"""Customised timeout for some commands."""

# Don't recalculate this every time we need it.
_clone_speedup_cache = None
def clone_speedup_options():
"""Return a list of options supported by the system git which speed up cloning."""
for filter_option in ("--filter=tree:0", "--filter=blob:none"):
valid_options = ("--filter=tree:0", "--filter=blob:none")
global _clone_speedup_cache
if _clone_speedup_cache is not None:
return _clone_speedup_cache
for filter_option in valid_options:
_, out = getstatusoutput("LANG=C git clone " + filter_option)
if "unknown option" not in out and "invalid filter-spec" not in out:
_clone_speedup_cache = [filter_option]
return [filter_option]
debug("Git: no speedup_options filters supported. Tried using (%s)", ", ".join(valid_options))
_clone_speedup_cache = []
return []


Expand Down
Loading