diff options
author | Mike Frysinger <vapier@google.com> | 2021-03-10 23:35:44 -0500 |
---|---|---|
committer | Mike Frysinger <vapier@google.com> | 2021-03-12 16:31:14 +0000 |
commit | 0458faa502e9992a4305bfbb282fbee344d505bf (patch) | |
tree | a91a10bd124b06c55c3a8ca522143d810070d1a6 /project.py | |
parent | 68d5d4dfe5375be53f935c8b72060a56801dda24 (diff) | |
download | git-repo-0458faa502e9992a4305bfbb282fbee344d505bf.tar.gz |
manifest: allow toplevel project checkoutsv2.13.5
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 <mmortensen@google.com>
Tested-by: Mike Frysinger <vapier@google.com>
Diffstat (limited to 'project.py')
-rw-r--r-- | project.py | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -1227,6 +1227,18 @@ class Project(object): | |||
1227 | self.CleanPublishedCache(all_refs) | 1227 | self.CleanPublishedCache(all_refs) |
1228 | revid = self.GetRevisionId(all_refs) | 1228 | revid = self.GetRevisionId(all_refs) |
1229 | 1229 | ||
1230 | # Special case the root of the repo client checkout. Make sure it doesn't | ||
1231 | # contain files being checked out to dirs we don't allow. | ||
1232 | if self.relpath == '.': | ||
1233 | PROTECTED_PATHS = {'.repo'} | ||
1234 | paths = set(self.work_git.ls_tree('-z', '--name-only', '--', revid).split('\0')) | ||
1235 | bad_paths = paths & PROTECTED_PATHS | ||
1236 | if bad_paths: | ||
1237 | syncbuf.fail(self, | ||
1238 | 'Refusing to checkout project that writes to protected ' | ||
1239 | 'paths: %s' % (', '.join(bad_paths),)) | ||
1240 | return | ||
1241 | |||
1230 | def _doff(): | 1242 | def _doff(): |
1231 | self._FastForward(revid) | 1243 | self._FastForward(revid) |
1232 | self._CopyAndLinkFiles() | 1244 | self._CopyAndLinkFiles() |