diff options
Diffstat (limited to 'bitbake/lib/bb/fetch2/git.py')
| -rw-r--r-- | bitbake/lib/bb/fetch2/git.py | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/bitbake/lib/bb/fetch2/git.py b/bitbake/lib/bb/fetch2/git.py index 250109bf9e..aa972c5cf4 100644 --- a/bitbake/lib/bb/fetch2/git.py +++ b/bitbake/lib/bb/fetch2/git.py | |||
| @@ -72,6 +72,7 @@ Supported SRC_URI options are: | |||
| 72 | 72 | ||
| 73 | import collections | 73 | import collections |
| 74 | import errno | 74 | import errno |
| 75 | import fnmatch | ||
| 75 | import os | 76 | import os |
| 76 | import re | 77 | import re |
| 77 | import subprocess | 78 | import subprocess |
| @@ -180,6 +181,7 @@ class Git(FetchMethod): | |||
| 180 | ud.cloneflags += " --mirror" | 181 | ud.cloneflags += " --mirror" |
| 181 | 182 | ||
| 182 | ud.shallow = d.getVar("BB_GIT_SHALLOW") == "1" | 183 | ud.shallow = d.getVar("BB_GIT_SHALLOW") == "1" |
| 184 | ud.shallow_extra_refs = (d.getVar("BB_GIT_SHALLOW_EXTRA_REFS") or "").split() | ||
| 183 | 185 | ||
| 184 | depth_default = d.getVar("BB_GIT_SHALLOW_DEPTH") | 186 | depth_default = d.getVar("BB_GIT_SHALLOW_DEPTH") |
| 185 | if depth_default is not None: | 187 | if depth_default is not None: |
| @@ -265,8 +267,13 @@ class Git(FetchMethod): | |||
| 265 | if depth: | 267 | if depth: |
| 266 | tarballname = "%s-%s" % (tarballname, depth) | 268 | tarballname = "%s-%s" % (tarballname, depth) |
| 267 | 269 | ||
| 270 | shallow_refs = [] | ||
| 268 | if not ud.nobranch: | 271 | if not ud.nobranch: |
| 269 | tarballname = "%s_%s" % (tarballname, "_".join(sorted(ud.branches.values())).replace('/', '.')) | 272 | shallow_refs.extend(ud.branches.values()) |
| 273 | if ud.shallow_extra_refs: | ||
| 274 | shallow_refs.extend(r.replace('refs/heads/', '').replace('*', 'ALL') for r in ud.shallow_extra_refs) | ||
| 275 | if shallow_refs: | ||
| 276 | tarballname = "%s_%s" % (tarballname, "_".join(sorted(shallow_refs)).replace('/', '.')) | ||
| 270 | 277 | ||
| 271 | fetcher = self.__class__.__name__.lower() | 278 | fetcher = self.__class__.__name__.lower() |
| 272 | ud.shallowtarball = '%sshallow_%s.tar.gz' % (fetcher, tarballname) | 279 | ud.shallowtarball = '%sshallow_%s.tar.gz' % (fetcher, tarballname) |
| @@ -408,6 +415,19 @@ class Git(FetchMethod): | |||
| 408 | # Map srcrev+depths to revisions | 415 | # Map srcrev+depths to revisions |
| 409 | shallow_revisions = runfetchcmd("%s rev-parse %s" % (ud.basecmd, " ".join(to_parse)), d, workdir=dest).splitlines() | 416 | shallow_revisions = runfetchcmd("%s rev-parse %s" % (ud.basecmd, " ".join(to_parse)), d, workdir=dest).splitlines() |
| 410 | 417 | ||
| 418 | # Apply extra ref wildcards | ||
| 419 | all_refs = runfetchcmd('%s for-each-ref "--format=%%(refname)"' % ud.basecmd, | ||
| 420 | d, workdir=dest).splitlines() | ||
| 421 | for r in ud.shallow_extra_refs: | ||
| 422 | if not ud.bareclone: | ||
| 423 | r = r.replace('refs/heads/', 'refs/remotes/origin/') | ||
| 424 | |||
| 425 | if '*' in r: | ||
| 426 | matches = filter(lambda a: fnmatch.fnmatchcase(a, r), all_refs) | ||
| 427 | shallow_branches.extend(matches) | ||
| 428 | else: | ||
| 429 | shallow_branches.append(r) | ||
| 430 | |||
| 411 | # Make the repository shallow | 431 | # Make the repository shallow |
| 412 | shallow_cmd = ['git', 'make-shallow', '-s'] | 432 | shallow_cmd = ['git', 'make-shallow', '-s'] |
| 413 | for b in shallow_branches: | 433 | for b in shallow_branches: |
