From cebf227026d3ef9e849a7d7d54bef638544d65ad Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Tue, 26 May 2020 01:02:29 -0400 Subject: [PATCH] manifest: normalize name & path when constructing fs paths If the manifest uses a trailing slash on the name attribute, repo will construct bad internal filesystem paths which confuses tools later on. For example, this manifest entry: Reviewed-by: David Pursehouse --- manifest_xml.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/manifest_xml.py b/manifest_xml.py index b6aef51..f546045 100644 --- a/manifest_xml.py +++ b/manifest_xml.py @@ -978,6 +978,10 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md return project def GetProjectPaths(self, name, path): + # The manifest entries might have trailing slashes. Normalize them to avoid + # unexpected filesystem behavior since we do string concatenation below. + path = path.rstrip('/') + name = name.rstrip('/') use_git_worktrees = False relpath = path if self.IsMirror: @@ -1010,6 +1014,10 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md return os.path.relpath(relpath, parent_relpath) def GetSubprojectPaths(self, parent, name, path): + # The manifest entries might have trailing slashes. Normalize them to avoid + # unexpected filesystem behavior since we do string concatenation below. + path = path.rstrip('/') + name = name.rstrip('/') relpath = self._JoinRelpath(parent.relpath, path) gitdir = os.path.join(parent.gitdir, 'subprojects', '%s.git' % path) objdir = os.path.join(parent.gitdir, 'subproject-objects', '%s.git' % name)