From 0458faa502e9992a4305bfbb282fbee344d505bf Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Wed, 10 Mar 2021 23:35:44 -0500 Subject: manifest: allow toplevel project checkouts Re-allow checking out projects to the top of the repo client checkout. We add checks to prevent checking out files under .repo/ as that path is only managed by us, and projects cannot inject content or settings into it. Bug: https://crbug.com/gerrit/14156 Bug: https://crbug.com/gerrit/14200 Change-Id: Id6bf9e882f5be748442b2c35bbeaee3549410b25 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/299623 Reviewed-by: Michael Mortensen Tested-by: Mike Frysinger --- project.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'project.py') diff --git a/project.py b/project.py index bc385f20..2567c57d 100644 --- a/project.py +++ b/project.py @@ -1227,6 +1227,18 @@ class Project(object): self.CleanPublishedCache(all_refs) revid = self.GetRevisionId(all_refs) + # Special case the root of the repo client checkout. Make sure it doesn't + # contain files being checked out to dirs we don't allow. + if self.relpath == '.': + PROTECTED_PATHS = {'.repo'} + paths = set(self.work_git.ls_tree('-z', '--name-only', '--', revid).split('\0')) + bad_paths = paths & PROTECTED_PATHS + if bad_paths: + syncbuf.fail(self, + 'Refusing to checkout project that writes to protected ' + 'paths: %s' % (', '.join(bad_paths),)) + return + def _doff(): self._FastForward(revid) self._CopyAndLinkFiles() -- cgit v1.2.3-54-g00ecf