From cc879a97c3e2614d19b15b4661c3cab4d33139c9 Mon Sep 17 00:00:00 2001 From: LaMont Jones Date: Thu, 18 Nov 2021 22:40:18 +0000 Subject: Add multi-manifest support with element 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 Reviewed-by: Mike Frysinger --- subcmds/grep.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'subcmds/grep.py') 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: return (project, p.Wait(), p.stdout, p.stderr) @staticmethod - def _ProcessResults(full_name, have_rev, _pool, out, results): + def _ProcessResults(full_name, have_rev, opt, _pool, out, results): git_failed = False bad_rev = False have_match = False + _RelPath = lambda p: p.RelPath(local=opt.this_manifest_only) for project, rc, stdout, stderr in results: if rc < 0: git_failed = True - out.project('--- project %s ---' % project.relpath) + out.project('--- project %s ---' % _RelPath(project)) out.nl() out.fail('%s', stderr) out.nl() @@ -192,7 +193,7 @@ contain a line that matches both expressions: if have_rev and 'fatal: ambiguous argument' in stderr: bad_rev = True else: - out.project('--- project %s ---' % project.relpath) + out.project('--- project %s ---' % _RelPath(project)) out.nl() out.fail('%s', stderr.strip()) out.nl() @@ -208,13 +209,13 @@ contain a line that matches both expressions: rev, line = line.split(':', 1) out.write("%s", rev) out.write(':') - out.project(project.relpath) + out.project(_RelPath(project)) out.write('/') out.write("%s", line) out.nl() elif full_name: for line in r: - out.project(project.relpath) + out.project(_RelPath(project)) out.write('/') out.write("%s", line) out.nl() @@ -239,7 +240,7 @@ contain a line that matches both expressions: cmd_argv.append(args[0]) args = args[1:] - projects = self.GetProjects(args) + projects = self.GetProjects(args, all_manifests=not opt.this_manifest_only) full_name = False if len(projects) > 1: @@ -259,7 +260,7 @@ contain a line that matches both expressions: opt.jobs, functools.partial(self._ExecuteOne, cmd_argv), projects, - callback=functools.partial(self._ProcessResults, full_name, have_rev), + callback=functools.partial(self._ProcessResults, full_name, have_rev, opt), output=out, ordered=True) -- cgit v1.2.3-54-g00ecf