summaryrefslogtreecommitdiffstats
path: root/subcmds/grep.py
diff options
context:
space:
mode:
authorLaMont Jones <lamontjones@google.com>2021-11-18 22:40:18 +0000
committerLaMont Jones <lamontjones@google.com>2022-02-17 21:57:55 +0000
commitcc879a97c3e2614d19b15b4661c3cab4d33139c9 (patch)
tree69d225e9f0e9d79fec8f423d9c40c275f0bf3b8c /subcmds/grep.py
parent87cce68b28c34fa86895baa8d7f48307382e6c75 (diff)
downloadgit-repo-cc879a97c3e2614d19b15b4661c3cab4d33139c9.tar.gz
Add multi-manifest support with <submanifest> elementv2.22
To be addressed in another change: - a partial `repo sync` (with a list of projects/paths to sync) requires `--this-tree-only`. Change-Id: I6c7400bf001540e9d7694fa70934f8f204cb5f57 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/322657 Tested-by: LaMont Jones <lamontjones@google.com> Reviewed-by: Mike Frysinger <vapier@google.com>
Diffstat (limited to 'subcmds/grep.py')
-rw-r--r--subcmds/grep.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/subcmds/grep.py b/subcmds/grep.py
index 8ac4ba14..93c9ae51 100644
--- a/subcmds/grep.py
+++ b/subcmds/grep.py
@@ -172,15 +172,16 @@ contain a line that matches both expressions:
172 return (project, p.Wait(), p.stdout, p.stderr) 172 return (project, p.Wait(), p.stdout, p.stderr)
173 173
174 @staticmethod 174 @staticmethod
175 def _ProcessResults(full_name, have_rev, _pool, out, results): 175 def _ProcessResults(full_name, have_rev, opt, _pool, out, results):
176 git_failed = False 176 git_failed = False
177 bad_rev = False 177 bad_rev = False
178 have_match = False 178 have_match = False
179 _RelPath = lambda p: p.RelPath(local=opt.this_manifest_only)
179 180
180 for project, rc, stdout, stderr in results: 181 for project, rc, stdout, stderr in results:
181 if rc < 0: 182 if rc < 0:
182 git_failed = True 183 git_failed = True
183 out.project('--- project %s ---' % project.relpath) 184 out.project('--- project %s ---' % _RelPath(project))
184 out.nl() 185 out.nl()
185 out.fail('%s', stderr) 186 out.fail('%s', stderr)
186 out.nl() 187 out.nl()
@@ -192,7 +193,7 @@ contain a line that matches both expressions:
192 if have_rev and 'fatal: ambiguous argument' in stderr: 193 if have_rev and 'fatal: ambiguous argument' in stderr:
193 bad_rev = True 194 bad_rev = True
194 else: 195 else:
195 out.project('--- project %s ---' % project.relpath) 196 out.project('--- project %s ---' % _RelPath(project))
196 out.nl() 197 out.nl()
197 out.fail('%s', stderr.strip()) 198 out.fail('%s', stderr.strip())
198 out.nl() 199 out.nl()
@@ -208,13 +209,13 @@ contain a line that matches both expressions:
208 rev, line = line.split(':', 1) 209 rev, line = line.split(':', 1)
209 out.write("%s", rev) 210 out.write("%s", rev)
210 out.write(':') 211 out.write(':')
211 out.project(project.relpath) 212 out.project(_RelPath(project))
212 out.write('/') 213 out.write('/')
213 out.write("%s", line) 214 out.write("%s", line)
214 out.nl() 215 out.nl()
215 elif full_name: 216 elif full_name:
216 for line in r: 217 for line in r:
217 out.project(project.relpath) 218 out.project(_RelPath(project))
218 out.write('/') 219 out.write('/')
219 out.write("%s", line) 220 out.write("%s", line)
220 out.nl() 221 out.nl()
@@ -239,7 +240,7 @@ contain a line that matches both expressions:
239 cmd_argv.append(args[0]) 240 cmd_argv.append(args[0])
240 args = args[1:] 241 args = args[1:]
241 242
242 projects = self.GetProjects(args) 243 projects = self.GetProjects(args, all_manifests=not opt.this_manifest_only)
243 244
244 full_name = False 245 full_name = False
245 if len(projects) > 1: 246 if len(projects) > 1:
@@ -259,7 +260,7 @@ contain a line that matches both expressions:
259 opt.jobs, 260 opt.jobs,
260 functools.partial(self._ExecuteOne, cmd_argv), 261 functools.partial(self._ExecuteOne, cmd_argv),
261 projects, 262 projects,
262 callback=functools.partial(self._ProcessResults, full_name, have_rev), 263 callback=functools.partial(self._ProcessResults, full_name, have_rev, opt),
263 output=out, 264 output=out,
264 ordered=True) 265 ordered=True)
265 266