diff --git a/docs/internal-fs-layout.md b/docs/internal-fs-layout.md index af6a4523..0e830510 100644 --- a/docs/internal-fs-layout.md +++ b/docs/internal-fs-layout.md @@ -163,6 +163,7 @@ User controlled settings are initialized when running `repo init`. | repo.clonefilter | `--clone-filter` | Filter setting when using [partial git clones] | | repo.depth | `--depth` | Create shallow checkouts when cloning | | repo.dissociate | `--dissociate` | Dissociate from any reference/mirrors after initial clone | +| repo.git-lfs | `--git-lfs` | Enable [Git LFS] support | | repo.mirror | `--mirror` | Checkout is a repo mirror | | repo.partialclone | `--partial-clone` | Create [partial git clones] | | repo.partialcloneexclude | `--partial-clone-exclude` | Comma-delimited list of project names (not paths) to exclude while using [partial git clones] | @@ -254,6 +255,7 @@ Repo will create & maintain a few files in the user's home directory. [git-config]: https://git-scm.com/docs/git-config +[Git LFS]: https://git-lfs.github.com/ [git worktree]: https://git-scm.com/docs/git-worktree [gitsubmodules]: https://git-scm.com/docs/gitsubmodules [manifest-format.md]: ./manifest-format.md diff --git a/manifest_xml.py b/manifest_xml.py index 68ead53c..daf85d30 100644 --- a/manifest_xml.py +++ b/manifest_xml.py @@ -666,6 +666,10 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md def HasSubmodules(self): return self.manifestProject.config.GetBoolean('repo.submodules') + @property + def EnableGitLfs(self): + return self.manifestProject.config.GetBoolean('repo.git-lfs') + def GetDefaultGroupsStr(self): """Returns the default group string for the platform.""" return 'default,platform-' + platform.system().lower() diff --git a/project.py b/project.py index 8490d9f9..12257857 100644 --- a/project.py +++ b/project.py @@ -2533,8 +2533,9 @@ class Project(object): for key in ['user.name', 'user.email']: if m.Has(key, include_defaults=False): self.config.SetString(key, m.GetString(key)) - self.config.SetString('filter.lfs.smudge', 'git-lfs smudge --skip -- %f') - self.config.SetString('filter.lfs.process', 'git-lfs filter-process --skip') + if not self.manifest.EnableGitLfs: + self.config.SetString('filter.lfs.smudge', 'git-lfs smudge --skip -- %f') + self.config.SetString('filter.lfs.process', 'git-lfs filter-process --skip') self.config.SetBoolean('core.bare', True if self.manifest.IsMirror else None) except Exception: if init_obj_dir and os.path.exists(self.objdir): diff --git a/repo b/repo index 6d7ce42a..c084b654 100755 --- a/repo +++ b/repo @@ -149,7 +149,7 @@ if not REPO_REV: BUG_URL = 'https://bugs.chromium.org/p/gerrit/issues/entry?template=Repo+tool+issue' # increment this whenever we make important changes to this script -VERSION = (2, 17) +VERSION = (2, 21) # increment this if the MAINTAINER_KEYS block is modified KEYRING_VERSION = (2, 3) @@ -382,6 +382,11 @@ def InitParser(parser, gitc_init=False): group.add_option('--no-clone-bundle', dest='clone_bundle', action='store_false', help='disable use of /clone.bundle on HTTP/HTTPS (default if --partial-clone)') + group.add_option('--git-lfs', action='store_true', + help='enable Git LFS support') + group.add_option('--no-git-lfs', + dest='git_lfs', action='store_false', + help='disable Git LFS support') # Tool. group = parser.add_option_group('repo Version options') diff --git a/subcmds/init.py b/subcmds/init.py index b0db76a4..32c85f79 100644 --- a/subcmds/init.py +++ b/subcmds/init.py @@ -291,6 +291,15 @@ to update the working directory files. if opt.submodules: m.config.SetBoolean('repo.submodules', opt.submodules) + if opt.git_lfs is not None: + if opt.git_lfs: + git_require((2, 17, 0), fail=True, msg='Git LFS support') + + m.config.SetBoolean('repo.git-lfs', opt.git_lfs) + if not is_new: + print('warning: Changing --git-lfs settings will only affect new project checkouts.\n' + ' Existing projects will require manual updates.\n', file=sys.stderr) + if opt.use_superproject is not None: m.config.SetBoolean('repo.superproject', opt.use_superproject)