summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/fetch2/git.py
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/bb/fetch2/git.py')
-rw-r--r--bitbake/lib/bb/fetch2/git.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/bitbake/lib/bb/fetch2/git.py b/bitbake/lib/bb/fetch2/git.py
index aa972c5cf4..534c93d3c5 100644
--- a/bitbake/lib/bb/fetch2/git.py
+++ b/bitbake/lib/bb/fetch2/git.py
@@ -196,6 +196,8 @@ class Git(FetchMethod):
196 depth_default = 1 196 depth_default = 1
197 ud.shallow_depths = collections.defaultdict(lambda: depth_default) 197 ud.shallow_depths = collections.defaultdict(lambda: depth_default)
198 198
199 revs_default = d.getVar("BB_GIT_SHALLOW_REVS", True)
200 ud.shallow_revs = []
199 ud.branches = {} 201 ud.branches = {}
200 for pos, name in enumerate(ud.names): 202 for pos, name in enumerate(ud.names):
201 branch = branches[pos] 203 branch = branches[pos]
@@ -213,7 +215,14 @@ class Git(FetchMethod):
213 raise bb.fetch2.FetchError("Invalid depth for BB_GIT_SHALLOW_DEPTH_%s: %s" % (name, shallow_depth)) 215 raise bb.fetch2.FetchError("Invalid depth for BB_GIT_SHALLOW_DEPTH_%s: %s" % (name, shallow_depth))
214 ud.shallow_depths[name] = shallow_depth 216 ud.shallow_depths[name] = shallow_depth
215 217
218 revs = d.getVar("BB_GIT_SHALLOW_REVS_%s" % name)
219 if revs is not None:
220 ud.shallow_revs.extend(revs.split())
221 elif revs_default is not None:
222 ud.shallow_revs.extend(revs_default.split())
223
216 if (ud.shallow and 224 if (ud.shallow and
225 not ud.shallow_revs and
217 all(ud.shallow_depths[n] == 0 for n in ud.names)): 226 all(ud.shallow_depths[n] == 0 for n in ud.names)):
218 # Shallow disabled for this URL 227 # Shallow disabled for this URL
219 ud.shallow = False 228 ud.shallow = False
@@ -261,6 +270,9 @@ class Git(FetchMethod):
261 if ud.bareclone: 270 if ud.bareclone:
262 tarballname = "%s_bare" % tarballname 271 tarballname = "%s_bare" % tarballname
263 272
273 if ud.shallow_revs:
274 tarballname = "%s_%s" % (tarballname, "_".join(sorted(ud.shallow_revs)))
275
264 for name, revision in sorted(ud.revisions.items()): 276 for name, revision in sorted(ud.revisions.items()):
265 tarballname = "%s_%s" % (tarballname, ud.revisions[name][:7]) 277 tarballname = "%s_%s" % (tarballname, ud.revisions[name][:7])
266 depth = ud.shallow_depths[name] 278 depth = ud.shallow_depths[name]
@@ -413,7 +425,11 @@ class Git(FetchMethod):
413 runfetchcmd("%s update-ref %s %s" % (ud.basecmd, ref, revision), d, workdir=dest) 425 runfetchcmd("%s update-ref %s %s" % (ud.basecmd, ref, revision), d, workdir=dest)
414 426
415 # Map srcrev+depths to revisions 427 # Map srcrev+depths to revisions
416 shallow_revisions = runfetchcmd("%s rev-parse %s" % (ud.basecmd, " ".join(to_parse)), d, workdir=dest).splitlines() 428 parsed_depths = runfetchcmd("%s rev-parse %s" % (ud.basecmd, " ".join(to_parse)), d, workdir=dest)
429
430 # Resolve specified revisions
431 parsed_revs = runfetchcmd("%s rev-parse %s" % (ud.basecmd, " ".join('"%s^{}"' % r for r in ud.shallow_revs)), d, workdir=dest)
432 shallow_revisions = parsed_depths.splitlines() + parsed_revs.splitlines()
417 433
418 # Apply extra ref wildcards 434 # Apply extra ref wildcards
419 all_refs = runfetchcmd('%s for-each-ref "--format=%%(refname)"' % ud.basecmd, 435 all_refs = runfetchcmd('%s for-each-ref "--format=%%(refname)"' % ud.basecmd,