Skip to content

Commit c61a614

Browse files
singiamtelktf
authored andcommitted
Include clone_speedup_options in git fetch
This change is not only performance related, it should also fix the missing blob object errors. Fetching with --filter=tree:0 should always be more resilient to missing objects upstream ``` sh-5.1$ git fetch -f https://github.com/alisw/alibuild-recipe-tools +refs/tags/*:refs/tags/* +refs/heads/*:refs/heads/* remote: Enumerating objects: 8, done. remote: Counting objects: 100% (8/8), done. remote: Compressing objects: 100% (4/4), done. remote: Total 6 (delta 2), reused 6 (delta 2), pack-reused 0 Unpacking objects: 100% (6/6), 806 bytes | 806.00 KiB/s, done. fatal: missing blob object '6f314120ba0359d1f73ad7d1d4a7f171fb36e8ac' error: https://github.com/alisw/alibuild-recipe-tools did not send all necessary objects ```
1 parent 0fbd8b6 commit c61a614

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

alibuild_helpers/git.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,13 @@
88
"""How many seconds to let any git command execute before being terminated."""
99

1010

11+
# Don't recalculate this every time we need it.
12+
_clone_speedup_cache = None
1113
def clone_speedup_options():
1214
"""Return a list of options supported by the system git which speed up cloning."""
15+
if _clone_speedup_cache is not None:
16+
return _clone_speedup_cache
17+
1318
for filter_option in ("--filter=tree:0", "--filter=blob:none"):
1419
_, out = getstatusoutput("LANG=C git clone " + filter_option)
1520
if "unknown option" not in out and "invalid filter-spec" not in out:
@@ -63,7 +68,7 @@ def checkoutCmd(self, ref):
6368
return ["checkout", "-f", ref]
6469

6570
def fetchCmd(self, source, *refs):
66-
return ["fetch", "-f", source, *refs]
71+
return ["fetch", "-f"] + clone_speedup_options() + [source, *refs]
6772

6873
def setWriteUrlCmd(self, url):
6974
return ["remote", "set-url", "--push", "origin", url]

0 commit comments

Comments
 (0)