summaryrefslogtreecommitdiffstats
path: root/command.py
diff options
context:
space:
mode:
authorMark E. Hamilton <mhamilt@sandia.gov>2016-02-23 18:10:42 -0700
committerDavid Pursehouse <david.pursehouse@sonymobile.com>2016-04-08 00:07:52 +0000
commitf9fe3e14d2b56140c90a8969892e06aa71127305 (patch)
tree5065ff8c40f8a7c8cf4574dd7afa6f573e76ca53 /command.py
parentbdb866ea7630b1aecad0ddc7d72939e67ff39816 (diff)
downloadgit-repo-f9fe3e14d2b56140c90a8969892e06aa71127305.tar.gz
repo: Repo does not always handle '.' parameter correctly
The repo script allows a manifest to specify a '.' as the path the top-level directory, which co-locates the .git and .repo directories, and places files from the git repository at the top-level: <project name="proj_name" path="." /> <project name="sierra.other.git" path="other" /> Most commands work correctly with this setup. Some commands, however, fail to find the project. For instance, 'repo sync' works, and 'repo sync .' works in a sub-project ('other' in this case) but 'repo sync .' in the top-level directory fails with the error: error: project . not found There are two reasons for this: 1. The self.worktree attribute of the Project object is not normalized, so with a '.' for path its value would be '/my/project/root/.'. This is fine when used as a path, since it's the same path as '/my/project/root', but when used in a string comparison it fails. This commit applies os.path.normpath() to that value before storing it. 2. The _GetProjectByPath method in command.py was not checking the path against manifest.topdir, so even once it was normalized the project was not found. This commit adds a check against manifest.topdir if the loop drops out without finding a project. Change-Id: Ic84d053f1bbb5a357cad566805d5a326ae8246d2
Diffstat (limited to 'command.py')
-rw-r--r--command.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/command.py b/command.py
index bc2f9501..2ff0a344 100644
--- a/command.py
+++ b/command.py
@@ -119,6 +119,11 @@ class Command(object):
119 except KeyError: 119 except KeyError:
120 oldpath = path 120 oldpath = path
121 path = os.path.dirname(path) 121 path = os.path.dirname(path)
122 if not project and path == manifest.topdir:
123 try:
124 project = self._by_path[path]
125 except KeyError:
126 pass
122 else: 127 else:
123 try: 128 try:
124 project = self._by_path[path] 129 project = self._by_path[path]