summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Frysinger <vapier@google.com>2020-02-10 17:10:03 -0500
committerMike Frysinger <vapier@google.com>2020-02-10 23:19:31 +0000
commitae625410057cdf8e905282161af7cf1b353d3cc3 (patch)
tree8751e4e6ba3ca707647ea6bfd7787a2fb611cd59
parent83a3227b62c936b346b825b333fc2ca65528ecfd (diff)
downloadgit-repo-ae625410057cdf8e905282161af7cf1b353d3cc3.tar.gz
manifest_xml: allow src=. with symlinks
Some Android/Nest manifests are using <linkfile> with src="." to create stable paths to specific projects. Allow that specific use case as it seems reasonable to support. Bug: https://crbug.com/gerrit/11218 Change-Id: I5eadec257cd58ba0f8687c590ddc250a7a414a85 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/254276 Reviewed-by: Michael Mortensen <mmortensen@google.com> Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Mike Frysinger <vapier@google.com>
-rw-r--r--manifest_xml.py12
-rw-r--r--tests/test_manifest_xml.py2
2 files changed, 9 insertions, 5 deletions
diff --git a/manifest_xml.py b/manifest_xml.py
index 035cc61b..b92b2675 100644
--- a/manifest_xml.py
+++ b/manifest_xml.py
@@ -985,11 +985,13 @@ class XmlManifest(object):
985 # Assume paths might be used on case-insensitive filesystems. 985 # Assume paths might be used on case-insensitive filesystems.
986 path = path.lower() 986 path = path.lower()
987 987
988 # We don't really need to reject '.' here, but there shouldn't really be a 988 # Some people use src="." to create stable links to projects. Lets allow
989 # need to ever use it, so no need to accept it either. 989 # that but reject all other uses of "." to keep things simple.
990 for part in set(path.split(os.path.sep)): 990 parts = path.split(os.path.sep)
991 if part in {'.', '..', '.git'} or part.startswith('.repo'): 991 if parts != ['.']:
992 return 'bad component: %s' % (part,) 992 for part in set(parts):
993 if part in {'.', '..', '.git'} or part.startswith('.repo'):
994 return 'bad component: %s' % (part,)
993 995
994 if not symlink and path.endswith(os.path.sep): 996 if not symlink and path.endswith(os.path.sep):
995 return 'dirs not allowed' 997 return 'dirs not allowed'
diff --git a/tests/test_manifest_xml.py b/tests/test_manifest_xml.py
index ecc84ad7..b6ec5b86 100644
--- a/tests/test_manifest_xml.py
+++ b/tests/test_manifest_xml.py
@@ -49,6 +49,8 @@ class ManifestValidateFilePaths(unittest.TestCase):
49 # We allow symlinks to end in a slash since we allow them to point to dirs 49 # We allow symlinks to end in a slash since we allow them to point to dirs
50 # in general. Technically the slash isn't necessary. 50 # in general. Technically the slash isn't necessary.
51 check('foo/', 'bar') 51 check('foo/', 'bar')
52 # We allow a single '.' to get a reference to the project itself.
53 check('.', 'bar')
52 54
53 def test_bad_paths(self): 55 def test_bad_paths(self):
54 """Make sure bad paths (src & dest) are rejected.""" 56 """Make sure bad paths (src & dest) are rejected."""