bazel, checkout: Rebase git_repository() changes

Rebase changes to repos that are pulled into the build using Bazel
git_repository() rules. Then use those changes from Bazel by adding
--override_repository arguments.

Bug: b/349670891
Change-Id: Ie7e32504d0c6a64b945071cb0134eaf57bfb556a
Reviewed-on: https://pigweed-review.googlesource.com/c/infra/recipes/+/223993
Presubmit-Verified: CQ Bot Account <pigweed-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ted Pudlik <tpudlik@google.com>
Commit-Queue: Rob Mohr <mohrr@google.com>
Lint: Lint 🤖 <android-build-ayeaye@system.gserviceaccount.com>
diff --git a/recipe_modules/bazel/api.py b/recipe_modules/bazel/api.py
index fcf54ee..6a14117 100644
--- a/recipe_modules/bazel/api.py
+++ b/recipe_modules/bazel/api.py
@@ -31,7 +31,7 @@
 @dataclasses.dataclass
 class BazelRunner:
     api: recipe_api.RecipeApi
-    checkout_root: config_types.Path
+    checkout: checkout_api.CheckoutContext
     options: Options
     _bazel: config_types.Path | None = None
 
@@ -55,9 +55,22 @@
         self.api.step('bazel version', [self._bazel, 'version'])
         return self._bazel
 
+    def _override_args(self) -> list[str]:
+        if self.api.path.exists(self.checkout.root / 'MODULE.bazel'):
+            # We're in a bzlmod-managed workspace.
+            flag = "--override_module"  # pragma: no cover
+        else:
+            # We're in a traditional workspace.
+            flag = "--override_repository"
+
+        return [
+            f'{flag}={repo}={path}'
+            for repo, path in self.checkout.bazel_overrides.items()
+        ]
+
     def run(self, **kwargs) -> None:
         config_name = self.options.config_path or 'pigweed.json'
-        config_path = self.checkout_root / config_name
+        config_path = self.checkout.root / config_name
         self.api.path.mock_add_file(config_path)
 
         config = {}
@@ -97,10 +110,12 @@
             else:
                 base_args.append('--remote_upload_local_results=true')
 
+        base_args.extend(self._override_args())
+
         success = True
 
         with (
-            self.api.context(cwd=self.checkout_root),
+            self.api.context(cwd=self.checkout.root),
             self.api.defer.context() as defer,
         ):
             for invocation in self.options.invocations:
@@ -218,7 +233,7 @@
         checkout: checkout_api.CheckoutContext,
         options: Options | None,
     ) -> BazelRunner:
-        return BazelRunner(self.m, checkout.root, options)
+        return BazelRunner(self.m, checkout, options)
 
     def _read(self, path: config_types.Path, num_nearby_lines: int):
         lines = [''] * num_nearby_lines
diff --git a/recipe_modules/bazel/test_api.py b/recipe_modules/bazel/test_api.py
index 2e7e1c9..1228f3e 100644
--- a/recipe_modules/bazel/test_api.py
+++ b/recipe_modules/bazel/test_api.py
@@ -35,6 +35,7 @@
     commit = "1111111111111111111111111111111111111111",
     remote = "https://pigweed.googlesource.com/pigweed/pigweed.git",
     git_repository_attribute_test = "ignored",
+    strip_prefix = "pw_toolchain_bazel",
 )
 
 git_repository(
diff --git a/recipe_modules/bazel/tests/full.proto b/recipe_modules/bazel/tests/full.proto
index 5835a21..91d5704 100644
--- a/recipe_modules/bazel/tests/full.proto
+++ b/recipe_modules/bazel/tests/full.proto
@@ -21,4 +21,7 @@
 message InputProperties {
   // Bazel module options.
   recipe_modules.pigweed.bazel.Options bazel_options = 1;
+
+  // List of repository names that will be overridden when calling bazel.
+  repeated string overrides = 2;
 }
diff --git a/recipe_modules/bazel/tests/full.py b/recipe_modules/bazel/tests/full.py
index 4e86858..604fb2a 100644
--- a/recipe_modules/bazel/tests/full.py
+++ b/recipe_modules/bazel/tests/full.py
@@ -16,6 +16,7 @@
 from __future__ import annotations
 
 import dataclasses
+import re
 from typing import Generator, TYPE_CHECKING
 
 from PB.recipe_modules.pigweed.bazel.tests.full import InputProperties
@@ -28,6 +29,7 @@
     'pigweed/bazel',
     'recipe_engine/buildbucket',
     'recipe_engine/path',
+    'recipe_engine/properties',
 ]
 
 PROPERTIES = InputProperties
@@ -36,12 +38,22 @@
 @dataclasses.dataclass
 class _FakeCheckoutContext:
     root: config_types.Path
+    bazel_overrides: dict[str, config_types.Path] = dataclasses.field(
+        default_factory=dict
+    )
 
 
 def RunSteps(api, props):  # pylint: disable=invalid-name
+    overrides = {}
+    for override in props.overrides:
+        overrides[override] = api.path.start_dir / 'bazel_repos' / override
+
     # pylint: disable=missing-function-docstring
     runner = api.bazel.new_runner(
-        checkout=_FakeCheckoutContext(api.path.start_dir),
+        checkout=_FakeCheckoutContext(
+            root=api.path.start_dir,
+            bazel_overrides=overrides,
+        ),
         options=props.bazel_options,
     )
     runner.run()
@@ -51,17 +63,43 @@
 
 
 def GenTests(api) -> Generator[recipe_test_api.TestData, None, None]:
+    def contains_override(step: str, name: str, bzlmod=False, invert=False):
+        flag = '--module_override' if bzlmod else '--override_repository'
+        pattern = re.compile(rf'{flag}={name}=.*')
+        check = post_process.StepCommandContains
+        if invert:
+            check = post_process.StepCommandDoesNotContain
+        return api.post_process(check, step, pattern)
+
+    def lacks_override(step: str, name: str, bzlmod=False):
+        return contains_override(
+            step=step, name=name, bzlmod=bzlmod, invert=True
+        )
+
     yield api.test(
-        'fixed',
+        'fixed-bazelisk',
         api.bazel.properties(bazelisk_version='1.19.0'),
         api.post_process(post_process.MustRun, 'ensure bazelisk'),
         api.post_process(post_process.DropExpectation),
     )
 
     yield api.test(
-        'latest',
+        'latest-without-overrides',
         api.bazel.properties(program=['default']),
         api.post_process(post_process.MustRun, 'ensure bazelisk'),
+        lacks_override('default.test //...', 'pigweed'),
+        lacks_override('default.test //...', 'thirdparty'),
+        api.post_process(post_process.DropExpectation),
+    )
+
+    yield api.test(
+        'latest-with-overrides',
+        api.bazel.properties(program=['default']),
+        api.properties(overrides=['pigweed', 'thirdparty']),
+        api.post_process(post_process.MustRun, 'ensure bazelisk'),
+        contains_override('default.test //...', 'pigweed'),
+        contains_override('default.test //...', 'thirdparty'),
+        lacks_override('default.test //...', 'additional'),
         api.post_process(post_process.DropExpectation),
     )
 
diff --git a/recipe_modules/bazel/tests/retrieve_git_repository_attributes.expected/success.json b/recipe_modules/bazel/tests/retrieve_git_repository_attributes.expected/success.json
index 55ab12b..ac569ba 100644
--- a/recipe_modules/bazel/tests/retrieve_git_repository_attributes.expected/success.json
+++ b/recipe_modules/bazel/tests/retrieve_git_repository_attributes.expected/success.json
@@ -552,6 +552,7 @@
       "@@@STEP_LOG_LINE@WORKSPACE@    commit = \"1111111111111111111111111111111111111111\",@@@",
       "@@@STEP_LOG_LINE@WORKSPACE@    remote = \"https://pigweed.googlesource.com/pigweed/pigweed.git\",@@@",
       "@@@STEP_LOG_LINE@WORKSPACE@    git_repository_attribute_test = \"ignored\",@@@",
+      "@@@STEP_LOG_LINE@WORKSPACE@    strip_prefix = \"pw_toolchain_bazel\",@@@",
       "@@@STEP_LOG_LINE@WORKSPACE@)@@@",
       "@@@STEP_LOG_LINE@WORKSPACE@@@@",
       "@@@STEP_LOG_LINE@WORKSPACE@git_repository(@@@",
@@ -587,7 +588,7 @@
     "cmd": [],
     "name": "debug",
     "~followup_annotations": [
-      "@@@STEP_SUMMARY_TEXT@[{'commit': '1111111111111111111111111111111111111111', 'name': 'pigweed', 'remote': 'https://pigweed.googlesource.com/pigweed/pigweed.git', 'git_repository_attribute_test': 'ignored'}]@@@"
+      "@@@STEP_SUMMARY_TEXT@[{'commit': '1111111111111111111111111111111111111111', 'remote': 'https://pigweed.googlesource.com/pigweed/pigweed.git', 'git_repository_attribute_test': 'ignored', 'name': 'pigweed', 'strip_prefix': 'pw_toolchain_bazel'}]@@@"
     ]
   },
   {
@@ -619,6 +620,14 @@
     ]
   },
   {
+    "cmd": [],
+    "name": "pigweed.strip_prefix",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@",
+      "@@@STEP_SUMMARY_TEXT@pw_toolchain_bazel@@@"
+    ]
+  },
+  {
     "name": "$result"
   }
 ]
\ No newline at end of file
diff --git a/recipe_modules/bazel/tests/update_commit_hash.expected/equiv.json b/recipe_modules/bazel/tests/update_commit_hash.expected/equiv.json
index 5bd8af8..67a05bf 100644
--- a/recipe_modules/bazel/tests/update_commit_hash.expected/equiv.json
+++ b/recipe_modules/bazel/tests/update_commit_hash.expected/equiv.json
@@ -552,6 +552,7 @@
       "@@@STEP_LOG_LINE@WORKSPACE@    commit = \"1111111111111111111111111111111111111111\",@@@",
       "@@@STEP_LOG_LINE@WORKSPACE@    remote = \"https://pigweed.googlesource.com/pigweed/pigweed.git\",@@@",
       "@@@STEP_LOG_LINE@WORKSPACE@    git_repository_attribute_test = \"ignored\",@@@",
+      "@@@STEP_LOG_LINE@WORKSPACE@    strip_prefix = \"pw_toolchain_bazel\",@@@",
       "@@@STEP_LOG_LINE@WORKSPACE@)@@@",
       "@@@STEP_LOG_LINE@WORKSPACE@@@@",
       "@@@STEP_LOG_LINE@WORKSPACE@git_repository(@@@",
@@ -591,7 +592,7 @@
       "--json-output",
       "/path/to/tmp/json",
       "copy",
-      "git_repository(\n    name = \"other-repo\"\n    remote = \"https://pigweed.googlesource.com/other/repo.git\",\n    commit = \"invalid commit line won't be found\",\n)\n\ngit_repository(\n    name = \"pigweed\",\n    # ROLL: Warning: this entry is automatically updated.\n    # ROLL: Last updated 2012-05-14.\n    # ROLL: By https://cr-buildbucket.appspot.com/build/0.\n    commit = \"ffffffffffffffffffffffffffffffffffffffff\",\n    remote = \"https://pigweed.googlesource.com/pigweed/equiv\",\n    git_repository_attribute_test = \"ignored\",\n)\n\ngit_repository(\n    name = \"missing final quote/comma so will miss this line\n    remote = \"https://pigweed.googlesource.com/third/repo.git\",\n    commit = \"2222222222222222222222222222222222222222\",\n)\n",
+      "git_repository(\n    name = \"other-repo\"\n    remote = \"https://pigweed.googlesource.com/other/repo.git\",\n    commit = \"invalid commit line won't be found\",\n)\n\ngit_repository(\n    name = \"pigweed\",\n    # ROLL: Warning: this entry is automatically updated.\n    # ROLL: Last updated 2012-05-14.\n    # ROLL: By https://cr-buildbucket.appspot.com/build/0.\n    commit = \"ffffffffffffffffffffffffffffffffffffffff\",\n    remote = \"https://pigweed.googlesource.com/pigweed/equiv\",\n    git_repository_attribute_test = \"ignored\",\n    strip_prefix = \"pw_toolchain_bazel\",\n)\n\ngit_repository(\n    name = \"missing final quote/comma so will miss this line\n    remote = \"https://pigweed.googlesource.com/third/repo.git\",\n    commit = \"2222222222222222222222222222222222222222\",\n)\n",
       "[START_DIR]/co/WORKSPACE"
     ],
     "infra_step": true,
@@ -611,6 +612,7 @@
       "@@@STEP_LOG_LINE@WORKSPACE@    commit = \"ffffffffffffffffffffffffffffffffffffffff\",@@@",
       "@@@STEP_LOG_LINE@WORKSPACE@    remote = \"https://pigweed.googlesource.com/pigweed/equiv\",@@@",
       "@@@STEP_LOG_LINE@WORKSPACE@    git_repository_attribute_test = \"ignored\",@@@",
+      "@@@STEP_LOG_LINE@WORKSPACE@    strip_prefix = \"pw_toolchain_bazel\",@@@",
       "@@@STEP_LOG_LINE@WORKSPACE@)@@@",
       "@@@STEP_LOG_LINE@WORKSPACE@@@@",
       "@@@STEP_LOG_LINE@WORKSPACE@git_repository(@@@",
diff --git a/recipe_modules/bazel/tests/update_commit_hash.expected/success.json b/recipe_modules/bazel/tests/update_commit_hash.expected/success.json
index 439192d..5aae314 100644
--- a/recipe_modules/bazel/tests/update_commit_hash.expected/success.json
+++ b/recipe_modules/bazel/tests/update_commit_hash.expected/success.json
@@ -552,6 +552,7 @@
       "@@@STEP_LOG_LINE@WORKSPACE@    commit = \"1111111111111111111111111111111111111111\",@@@",
       "@@@STEP_LOG_LINE@WORKSPACE@    remote = \"https://pigweed.googlesource.com/pigweed/pigweed.git\",@@@",
       "@@@STEP_LOG_LINE@WORKSPACE@    git_repository_attribute_test = \"ignored\",@@@",
+      "@@@STEP_LOG_LINE@WORKSPACE@    strip_prefix = \"pw_toolchain_bazel\",@@@",
       "@@@STEP_LOG_LINE@WORKSPACE@)@@@",
       "@@@STEP_LOG_LINE@WORKSPACE@@@@",
       "@@@STEP_LOG_LINE@WORKSPACE@git_repository(@@@",
@@ -591,7 +592,7 @@
       "--json-output",
       "/path/to/tmp/json",
       "copy",
-      "git_repository(\n    name = \"other-repo\"\n    remote = \"https://pigweed.googlesource.com/other/repo.git\",\n    commit = \"invalid commit line won't be found\",\n)\n\ngit_repository(\n    name = \"pigweed\",\n    # ROLL: Warning: this entry is automatically updated.\n    # ROLL: Last updated 2012-05-14.\n    # ROLL: By https://cr-buildbucket.appspot.com/build/0.\n    commit = \"ffffffffffffffffffffffffffffffffffffffff\",\n    remote = \"https://pigweed.googlesource.com/pigweed/pigweed\",\n    git_repository_attribute_test = \"ignored\",\n)\n\ngit_repository(\n    name = \"missing final quote/comma so will miss this line\n    remote = \"https://pigweed.googlesource.com/third/repo.git\",\n    commit = \"2222222222222222222222222222222222222222\",\n)\n",
+      "git_repository(\n    name = \"other-repo\"\n    remote = \"https://pigweed.googlesource.com/other/repo.git\",\n    commit = \"invalid commit line won't be found\",\n)\n\ngit_repository(\n    name = \"pigweed\",\n    # ROLL: Warning: this entry is automatically updated.\n    # ROLL: Last updated 2012-05-14.\n    # ROLL: By https://cr-buildbucket.appspot.com/build/0.\n    commit = \"ffffffffffffffffffffffffffffffffffffffff\",\n    remote = \"https://pigweed.googlesource.com/pigweed/pigweed\",\n    git_repository_attribute_test = \"ignored\",\n    strip_prefix = \"pw_toolchain_bazel\",\n)\n\ngit_repository(\n    name = \"missing final quote/comma so will miss this line\n    remote = \"https://pigweed.googlesource.com/third/repo.git\",\n    commit = \"2222222222222222222222222222222222222222\",\n)\n",
       "[START_DIR]/co/WORKSPACE"
     ],
     "infra_step": true,
@@ -611,6 +612,7 @@
       "@@@STEP_LOG_LINE@WORKSPACE@    commit = \"ffffffffffffffffffffffffffffffffffffffff\",@@@",
       "@@@STEP_LOG_LINE@WORKSPACE@    remote = \"https://pigweed.googlesource.com/pigweed/pigweed\",@@@",
       "@@@STEP_LOG_LINE@WORKSPACE@    git_repository_attribute_test = \"ignored\",@@@",
+      "@@@STEP_LOG_LINE@WORKSPACE@    strip_prefix = \"pw_toolchain_bazel\",@@@",
       "@@@STEP_LOG_LINE@WORKSPACE@)@@@",
       "@@@STEP_LOG_LINE@WORKSPACE@@@@",
       "@@@STEP_LOG_LINE@WORKSPACE@git_repository(@@@",
diff --git a/recipe_modules/checkout/api.py b/recipe_modules/checkout/api.py
index 514c837..509e873 100644
--- a/recipe_modules/checkout/api.py
+++ b/recipe_modules/checkout/api.py
@@ -217,6 +217,7 @@
     manifest: Manifest | None = None  # Parsed repo manifest.
     # Path to a JSON file containing metadata about the triggering changes.
     changes_json: config_types.Path | None = None
+    bazel_overrides: dict[str, config_types.Path] = attrs.field(factory=dict)
 
     # Current revision number.
     def revision(self) -> str:
@@ -1449,6 +1450,9 @@
         ):
             return
 
+        repos_dir = self.m.path.start_dir / 'bazel_repos'
+        self.m.file.ensure_directory(f'mkdir {repos_dir}', repos_dir)
+
         with self.m.step.nest('workspace'):
             workspace_changed = False
 
@@ -1468,28 +1472,46 @@
 
                         with self.m.step.nest(workspace):
 
-                            update_result = self.m.bazel.update_commit_hash(
-                                checkout=ctx,
-                                project_remote=change.remote,
-                                new_revision=(
-                                    change.current_revision or change.branch
-                                ),
-                                path=workspace_path,
-                                replace_remote=True,
+                            repos = (
+                                self.m.bazel.retrieve_git_repository_attributes(
+                                    checkout=ctx,
+                                    project_remote=change.remote,
+                                    path=workspace_path,
+                                )
                             )
-                            if update_result:
-                                change.path = workspace
-                                change.applied = True
-                                workspace_changed = True
-                                break
 
-            if workspace_changed:
-                with self.m.context(cwd=ctx.root):
-                    patch_file = self.m.path.mkstemp()
-                    self.m.git.diff(patch_file=patch_file)
-                    self.m.file.read_text('diff', patch_file)
+                            if not repos:
+                                continue
 
-        return
+                            # Things will be much simpler if we assume all
+                            # entries with a url matching the change have
+                            # identical remote URLs.
+                            remotes = list(set(x['remote'] for x in repos))
+                            assert len(remotes) == 1
+                            remote = remotes[0]
+
+                            name = remote
+                            name = name.replace('http://', '')
+                            name = name.replace('https://', '')
+                            name = name.replace('sso://', '')
+                            name = name.replace('.git.corp.google.com', '')
+                            name = name.replace('.googlesource.com', '')
+                            name = name.replace('/', '_')
+                            path = repos_dir / name
+
+                            self.m.git_checkout(
+                                remote,
+                                path=path,
+                                step_name=f'checkout {name}',
+                                ignore_build_input=True,
+                            )
+
+                            self._apply_change(ctx, change, path)
+
+                            for repo in repos:
+                                if 'strip_prefix' in repo:
+                                    path = path / repo['strip_prefix']
+                                ctx.bazel_overrides[repo['name']] = path
 
     def _configure_insteadof(self, ctx: CheckoutContext):
         """Configure git to use some urls in place of others."""
diff --git a/recipe_modules/checkout/tests/workspace.expected/found.json b/recipe_modules/checkout/tests/workspace.expected/found.json
index f0e1fae..08fe45c 100644
--- a/recipe_modules/checkout/tests/workspace.expected/found.json
+++ b/recipe_modules/checkout/tests/workspace.expected/found.json
@@ -3,7 +3,7 @@
     "cmd": [],
     "name": "checkout foo",
     "~followup_annotations": [
-      "@@@STEP_LINK@applied pigweed:123456 (WORKSPACE)@https://pigweed-review.googlesource.com/c/123456@@@"
+      "@@@STEP_LINK@applied pigweed:123456 (../bazel_repos/pigweed_pigweed_pigweed.git)@https://pigweed-review.googlesource.com/c/123456@@@"
     ]
   },
   {
@@ -1169,6 +1169,36 @@
     ]
   },
   {
+    "cmd": [
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "ensure-directory",
+      "--mode",
+      "0o777",
+      "[START_DIR]/bazel_repos"
+    ],
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout foo.mkdir [START_DIR]/bazel_repos",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
     "cmd": [],
     "name": "checkout foo.workspace",
     "~followup_annotations": [
@@ -1234,6 +1264,7 @@
       "@@@STEP_LOG_LINE@WORKSPACE@    commit = \"1111111111111111111111111111111111111111\",@@@",
       "@@@STEP_LOG_LINE@WORKSPACE@    remote = \"https://pigweed.googlesource.com/pigweed/pigweed.git\",@@@",
       "@@@STEP_LOG_LINE@WORKSPACE@    git_repository_attribute_test = \"ignored\",@@@",
+      "@@@STEP_LOG_LINE@WORKSPACE@    strip_prefix = \"pw_toolchain_bazel\",@@@",
       "@@@STEP_LOG_LINE@WORKSPACE@)@@@",
       "@@@STEP_LOG_LINE@WORKSPACE@@@@",
       "@@@STEP_LOG_LINE@WORKSPACE@git_repository(@@@",
@@ -1269,15 +1300,24 @@
     ]
   },
   {
+    "cmd": [],
+    "name": "checkout foo.workspace.pigweed:123456.WORKSPACE.checkout pigweed_pigweed_pigweed.git",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@4@@@",
+      "@@@STEP_TEXT@https://pigweed.googlesource.com/pigweed/pigweed.git@@@"
+    ]
+  },
+  {
     "cmd": [
       "vpython3",
       "-u",
       "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
       "--json-output",
       "/path/to/tmp/json",
-      "copy",
-      "git_repository(\n    name = \"other-repo\"\n    remote = \"https://pigweed.googlesource.com/other/repo.git\",\n    commit = \"invalid commit line won't be found\",\n)\n\ngit_repository(\n    name = \"pigweed\",\n    # ROLL: Warning: this entry is automatically updated.\n    # ROLL: Last updated 2012-05-14.\n    # ROLL: By https://cr-buildbucket.appspot.com/build/8945511751514863184.\n    commit = \"ffffffffffffffffffffffffffffffffffffffff\",\n    remote = \"https://pigweed.googlesource.com/pigweed/pigweed\",\n    git_repository_attribute_test = \"ignored\",\n)\n\ngit_repository(\n    name = \"missing final quote/comma so will miss this line\n    remote = \"https://pigweed.googlesource.com/third/repo.git\",\n    commit = \"2222222222222222222222222222222222222222\",\n)\n",
-      "[START_DIR]/co/WORKSPACE"
+      "ensure-directory",
+      "--mode",
+      "0o777",
+      "[START_DIR]/bazel_repos/pigweed_pigweed_pigweed.git"
     ],
     "infra_step": true,
     "luci_context": {
@@ -1292,70 +1332,17 @@
         "hostname": "rdbhost"
       }
     },
-    "name": "checkout foo.workspace.pigweed:123456.WORKSPACE.write new WORKSPACE",
+    "name": "checkout foo.workspace.pigweed:123456.WORKSPACE.checkout pigweed_pigweed_pigweed.git.makedirs",
     "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@4@@@",
-      "@@@STEP_LOG_LINE@WORKSPACE@git_repository(@@@",
-      "@@@STEP_LOG_LINE@WORKSPACE@    name = \"other-repo\"@@@",
-      "@@@STEP_LOG_LINE@WORKSPACE@    remote = \"https://pigweed.googlesource.com/other/repo.git\",@@@",
-      "@@@STEP_LOG_LINE@WORKSPACE@    commit = \"invalid commit line won't be found\",@@@",
-      "@@@STEP_LOG_LINE@WORKSPACE@)@@@",
-      "@@@STEP_LOG_LINE@WORKSPACE@@@@",
-      "@@@STEP_LOG_LINE@WORKSPACE@git_repository(@@@",
-      "@@@STEP_LOG_LINE@WORKSPACE@    name = \"pigweed\",@@@",
-      "@@@STEP_LOG_LINE@WORKSPACE@    # ROLL: Warning: this entry is automatically updated.@@@",
-      "@@@STEP_LOG_LINE@WORKSPACE@    # ROLL: Last updated 2012-05-14.@@@",
-      "@@@STEP_LOG_LINE@WORKSPACE@    # ROLL: By https://cr-buildbucket.appspot.com/build/8945511751514863184.@@@",
-      "@@@STEP_LOG_LINE@WORKSPACE@    commit = \"ffffffffffffffffffffffffffffffffffffffff\",@@@",
-      "@@@STEP_LOG_LINE@WORKSPACE@    remote = \"https://pigweed.googlesource.com/pigweed/pigweed\",@@@",
-      "@@@STEP_LOG_LINE@WORKSPACE@    git_repository_attribute_test = \"ignored\",@@@",
-      "@@@STEP_LOG_LINE@WORKSPACE@)@@@",
-      "@@@STEP_LOG_LINE@WORKSPACE@@@@",
-      "@@@STEP_LOG_LINE@WORKSPACE@git_repository(@@@",
-      "@@@STEP_LOG_LINE@WORKSPACE@    name = \"missing final quote/comma so will miss this line@@@",
-      "@@@STEP_LOG_LINE@WORKSPACE@    remote = \"https://pigweed.googlesource.com/third/repo.git\",@@@",
-      "@@@STEP_LOG_LINE@WORKSPACE@    commit = \"2222222222222222222222222222222222222222\",@@@",
-      "@@@STEP_LOG_LINE@WORKSPACE@)@@@",
-      "@@@STEP_LOG_END@WORKSPACE@@@"
+      "@@@STEP_NEST_LEVEL@5@@@"
     ]
   },
   {
     "cmd": [
       "git",
-      "diff",
-      "HEAD"
+      "init"
     ],
-    "cwd": "[START_DIR]/co",
-    "luci_context": {
-      "realm": {
-        "name": "project:try"
-      },
-      "resultdb": {
-        "current_invocation": {
-          "name": "invocations/build:8945511751514863184",
-          "update_token": "token"
-        },
-        "hostname": "rdbhost"
-      }
-    },
-    "name": "checkout foo.workspace.git diff",
-    "timeout": 300.0,
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@2@@@"
-    ]
-  },
-  {
-    "cmd": [
-      "vpython3",
-      "-u",
-      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
-      "--json-output",
-      "/path/to/tmp/json",
-      "copy",
-      "[CLEANUP]/tmp_tmp_2",
-      "/path/to/tmp/"
-    ],
-    "cwd": "[START_DIR]/co",
+    "cwd": "[START_DIR]/bazel_repos/pigweed_pigweed_pigweed.git",
     "infra_step": true,
     "luci_context": {
       "realm": {
@@ -1369,10 +1356,949 @@
         "hostname": "rdbhost"
       }
     },
-    "name": "checkout foo.workspace.diff",
+    "name": "checkout foo.workspace.pigweed:123456.WORKSPACE.checkout pigweed_pigweed_pigweed.git.git init",
+    "timeout": 300.0,
     "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@2@@@",
-      "@@@STEP_LOG_END@tmp_tmp_2@@@"
+      "@@@STEP_NEST_LEVEL@5@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "remote",
+      "add",
+      "origin",
+      "https://pigweed.googlesource.com/pigweed/pigweed.git"
+    ],
+    "cwd": "[START_DIR]/bazel_repos/pigweed_pigweed_pigweed.git",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout foo.workspace.pigweed:123456.WORKSPACE.checkout pigweed_pigweed_pigweed.git.git remote",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@5@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "config",
+      "core.longpaths",
+      "true"
+    ],
+    "cwd": "[START_DIR]/bazel_repos/pigweed_pigweed_pigweed.git",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout foo.workspace.pigweed:123456.WORKSPACE.checkout pigweed_pigweed_pigweed.git.set core.longpaths",
+    "timeout": 300.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@5@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "config",
+      "fetch.uriprotocols",
+      "https"
+    ],
+    "cwd": "[START_DIR]/bazel_repos/pigweed_pigweed_pigweed.git",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout foo.workspace.pigweed:123456.WORKSPACE.checkout pigweed_pigweed_pigweed.git.set fetch.uriprotocols",
+    "timeout": 300.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@5@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "checkout foo.workspace.pigweed:123456.WORKSPACE.checkout pigweed_pigweed_pigweed.git.cache",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@5@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "copy",
+      "",
+      "[CACHE]/git/.GUARD_FILE"
+    ],
+    "cwd": "[START_DIR]/bazel_repos/pigweed_pigweed_pigweed.git",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout foo.workspace.pigweed:123456.WORKSPACE.checkout pigweed_pigweed_pigweed.git.cache.write git cache guard file",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@6@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "ensure-directory",
+      "--mode",
+      "0o777",
+      "[CACHE]/git/pigweed.googlesource.com-pigweed-pigweed.git"
+    ],
+    "cwd": "[START_DIR]/bazel_repos/pigweed_pigweed_pigweed.git",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout foo.workspace.pigweed:123456.WORKSPACE.checkout pigweed_pigweed_pigweed.git.cache.makedirs",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@6@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "init",
+      "--bare"
+    ],
+    "cwd": "[CACHE]/git/pigweed.googlesource.com-pigweed-pigweed.git",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout foo.workspace.pigweed:123456.WORKSPACE.checkout pigweed_pigweed_pigweed.git.cache.git init",
+    "timeout": 300.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@6@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "config",
+      "remote.origin.url",
+      "https://pigweed.googlesource.com/pigweed/pigweed.git"
+    ],
+    "cwd": "[CACHE]/git/pigweed.googlesource.com-pigweed-pigweed.git",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout foo.workspace.pigweed:123456.WORKSPACE.checkout pigweed_pigweed_pigweed.git.cache.remote set-url",
+    "timeout": 300.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@6@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "config",
+      "core.longpaths",
+      "true"
+    ],
+    "cwd": "[CACHE]/git/pigweed.googlesource.com-pigweed-pigweed.git",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout foo.workspace.pigweed:123456.WORKSPACE.checkout pigweed_pigweed_pigweed.git.cache.set core.longpaths",
+    "timeout": 300.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@6@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "config",
+      "fetch.uriprotocols",
+      "https"
+    ],
+    "cwd": "[CACHE]/git/pigweed.googlesource.com-pigweed-pigweed.git",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout foo.workspace.pigweed:123456.WORKSPACE.checkout pigweed_pigweed_pigweed.git.cache.set fetch.uriprotocols",
+    "timeout": 300.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@6@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "config",
+      "--replace-all",
+      "remote.origin.fetch",
+      "+refs/heads/*:refs/heads/*",
+      "\\+refs/heads/\\*:.*"
+    ],
+    "cwd": "[CACHE]/git/pigweed.googlesource.com-pigweed-pigweed.git",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout foo.workspace.pigweed:123456.WORKSPACE.checkout pigweed_pigweed_pigweed.git.cache.replace fetch configs",
+    "timeout": 300.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@6@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "fetch",
+      "--prune",
+      "--tags",
+      "--jobs",
+      "4",
+      "origin"
+    ],
+    "cwd": "[CACHE]/git/pigweed.googlesource.com-pigweed-pigweed.git",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout foo.workspace.pigweed:123456.WORKSPACE.checkout pigweed_pigweed_pigweed.git.cache.git fetch",
+    "timeout": 1200.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@6@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "ensure-directory",
+      "--mode",
+      "0o777",
+      "[START_DIR]/bazel_repos/pigweed_pigweed_pigweed.git/.git/objects/info"
+    ],
+    "cwd": "[START_DIR]/bazel_repos/pigweed_pigweed_pigweed.git",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout foo.workspace.pigweed:123456.WORKSPACE.checkout pigweed_pigweed_pigweed.git.cache.makedirs object/info",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@6@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "copy",
+      "[CACHE]/git/pigweed.googlesource.com-pigweed-pigweed.git/objects\n",
+      "[START_DIR]/bazel_repos/pigweed_pigweed_pigweed.git/.git/objects/info/alternates"
+    ],
+    "cwd": "[START_DIR]/bazel_repos/pigweed_pigweed_pigweed.git",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout foo.workspace.pigweed:123456.WORKSPACE.checkout pigweed_pigweed_pigweed.git.cache.alternates",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@6@@@",
+      "@@@STEP_LOG_LINE@alternates@[CACHE]/git/pigweed.googlesource.com-pigweed-pigweed.git/objects@@@",
+      "@@@STEP_LOG_END@alternates@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "remove",
+      "[CACHE]/git/.GUARD_FILE"
+    ],
+    "cwd": "[START_DIR]/bazel_repos/pigweed_pigweed_pigweed.git",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout foo.workspace.pigweed:123456.WORKSPACE.checkout pigweed_pigweed_pigweed.git.cache.remove git cache guard file",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@6@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "fetch",
+      "--tags",
+      "--jobs",
+      "4",
+      "origin",
+      "main"
+    ],
+    "cwd": "[START_DIR]/bazel_repos/pigweed_pigweed_pigweed.git",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout foo.workspace.pigweed:123456.WORKSPACE.checkout pigweed_pigweed_pigweed.git.git fetch",
+    "timeout": 1200.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@5@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "checkout",
+      "-f",
+      "FETCH_HEAD"
+    ],
+    "cwd": "[START_DIR]/bazel_repos/pigweed_pigweed_pigweed.git",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout foo.workspace.pigweed:123456.WORKSPACE.checkout pigweed_pigweed_pigweed.git.git checkout",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@5@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "rev-parse",
+      "HEAD"
+    ],
+    "cwd": "[START_DIR]/bazel_repos/pigweed_pigweed_pigweed.git",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout foo.workspace.pigweed:123456.WORKSPACE.checkout pigweed_pigweed_pigweed.git.git rev-parse",
+    "timeout": 300.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@5@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "clean",
+      "-f",
+      "-d",
+      "-x"
+    ],
+    "cwd": "[START_DIR]/bazel_repos/pigweed_pigweed_pigweed.git",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout foo.workspace.pigweed:123456.WORKSPACE.checkout pigweed_pigweed_pigweed.git.git clean",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@5@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "checkout foo.workspace.pigweed:123456.WORKSPACE.checkout pigweed_pigweed_pigweed.git.submodule",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@5@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "submodule",
+      "sync"
+    ],
+    "cwd": "[START_DIR]/bazel_repos/pigweed_pigweed_pigweed.git",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout foo.workspace.pigweed:123456.WORKSPACE.checkout pigweed_pigweed_pigweed.git.submodule.git submodule sync",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@6@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "submodule",
+      "update",
+      "--init",
+      "--jobs",
+      "4"
+    ],
+    "cwd": "[START_DIR]/bazel_repos/pigweed_pigweed_pigweed.git",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout foo.workspace.pigweed:123456.WORKSPACE.checkout pigweed_pigweed_pigweed.git.submodule.git submodule update",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@6@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "checkout foo.workspace.pigweed:123456.WORKSPACE.apply pigweed:123456",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@4@@@",
+      "@@@STEP_SUMMARY_TEXT@../bazel_repos/pigweed_pigweed_pigweed.git@@@",
+      "@@@STEP_LINK@gerrit@https://pigweed-review.googlesource.com/c/123456@@@",
+      "@@@STEP_LINK@gitiles@https://pigweed.googlesource.com/pigweed/pigweed/+/refs/changes/56/123456/7@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "checkout foo.workspace.pigweed:123456.WORKSPACE.apply pigweed:123456.timeout 10s",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@5@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "fetch",
+      "--jobs",
+      "4",
+      "https://pigweed.googlesource.com/pigweed/pigweed",
+      "refs/changes/56/123456/7",
+      "--no-recurse-submodules"
+    ],
+    "cwd": "[START_DIR]/bazel_repos/pigweed_pigweed_pigweed.git",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout foo.workspace.pigweed:123456.WORKSPACE.apply pigweed:123456.git fetch patch",
+    "timeout": 1200.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@5@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "checkout",
+      "--force",
+      "-b",
+      "working",
+      "FETCH_HEAD"
+    ],
+    "cwd": "[START_DIR]/bazel_repos/pigweed_pigweed_pigweed.git",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout foo.workspace.pigweed:123456.WORKSPACE.apply pigweed:123456.git checkout patch",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@5@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "remote",
+      "add",
+      "https___pigweed_googlesource_com_pigweed_pigweed",
+      "https://pigweed.googlesource.com/pigweed/pigweed"
+    ],
+    "cwd": "[START_DIR]/bazel_repos/pigweed_pigweed_pigweed.git",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout foo.workspace.pigweed:123456.WORKSPACE.apply pigweed:123456.git remote add",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@5@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "checkout foo.workspace.pigweed:123456.WORKSPACE.apply pigweed:123456.timeout 10s (2)",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@5@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "fetch",
+      "--jobs",
+      "4",
+      "https___pigweed_googlesource_com_pigweed_pigweed",
+      "refs/heads/main"
+    ],
+    "cwd": "[START_DIR]/bazel_repos/pigweed_pigweed_pigweed.git",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout foo.workspace.pigweed:123456.WORKSPACE.apply pigweed:123456.git fetch branch",
+    "timeout": 1200.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@5@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "branch",
+      "--set-upstream-to=https___pigweed_googlesource_com_pigweed_pigweed/main"
+    ],
+    "cwd": "[START_DIR]/bazel_repos/pigweed_pigweed_pigweed.git",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout foo.workspace.pigweed:123456.WORKSPACE.apply pigweed:123456.git set upstream",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@5@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "log",
+      "--oneline",
+      "-n",
+      "10"
+    ],
+    "cwd": "[START_DIR]/bazel_repos/pigweed_pigweed_pigweed.git",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout foo.workspace.pigweed:123456.WORKSPACE.apply pigweed:123456.pre-rebase log",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@5@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "rebase",
+      "https___pigweed_googlesource_com_pigweed_pigweed/main"
+    ],
+    "cwd": "[START_DIR]/bazel_repos/pigweed_pigweed_pigweed.git",
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout foo.workspace.pigweed:123456.WORKSPACE.apply pigweed:123456.git rebase",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@5@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "rev-parse",
+      "https___pigweed_googlesource_com_pigweed_pigweed/main"
+    ],
+    "cwd": "[START_DIR]/bazel_repos/pigweed_pigweed_pigweed.git",
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout foo.workspace.pigweed:123456.WORKSPACE.apply pigweed:123456.git rev-parse",
+    "timeout": 300.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@5@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "log",
+      "--oneline",
+      "-n",
+      "10"
+    ],
+    "cwd": "[START_DIR]/bazel_repos/pigweed_pigweed_pigweed.git",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout foo.workspace.pigweed:123456.WORKSPACE.apply pigweed:123456.post-rebase log",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@5@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "checkout foo.workspace.pigweed:123456.WORKSPACE.apply pigweed:123456.timeout 10s (3)",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@5@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "checkout",
+      "--detach"
+    ],
+    "cwd": "[START_DIR]/bazel_repos/pigweed_pigweed_pigweed.git",
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout foo.workspace.pigweed:123456.WORKSPACE.apply pigweed:123456.detach",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@5@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "submodule",
+      "update",
+      "--init",
+      "--recursive",
+      "--jobs",
+      "4"
+    ],
+    "cwd": "[START_DIR]/bazel_repos/pigweed_pigweed_pigweed.git",
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout foo.workspace.pigweed:123456.WORKSPACE.apply pigweed:123456.git submodule update",
+    "timeout": 600,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@5@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "checkout",
+      "-"
+    ],
+    "cwd": "[START_DIR]/bazel_repos/pigweed_pigweed_pigweed.git",
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout foo.workspace.pigweed:123456.WORKSPACE.apply pigweed:123456.reattach",
+    "timeout": 600.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@5@@@"
     ]
   },
   {
@@ -1431,7 +2357,7 @@
     "name": "checkout foo.status",
     "~followup_annotations": [
       "@@@STEP_NEST_LEVEL@1@@@",
-      "@@@STEP_SUMMARY_TEXT@applied [Change(number=123456, remote='https://pigweed.googlesource.com/pigweed/pigweed', ref='refs/changes/56/123456/7', rebase=True, project='pigweed/pigweed', branch='main', gerrit_name='pigweed', submitted=False, patchset=7, path='WORKSPACE', base=None, base_type=None, is_merge=False, commit_message='', topic=None, current_revision='ffffffffffffffffffffffffffffffffffffffff')]\nnot applied []@@@"
+      "@@@STEP_SUMMARY_TEXT@applied [Change(number=123456, remote='https://pigweed.googlesource.com/pigweed/pigweed', ref='refs/changes/56/123456/7', rebase=True, project='pigweed/pigweed', branch='main', gerrit_name='pigweed', submitted=False, patchset=7, path='../bazel_repos/pigweed_pigweed_pigweed.git', base='REMOTE_BRANCH_REMOTE_BRANCH_REMOTE_BRANCH_', base_type='remote_branch_tip', is_merge=False, commit_message='', topic=None, current_revision='ffffffffffffffffffffffffffffffffffffffff')]\nnot applied []@@@"
     ]
   },
   {
@@ -1582,7 +2508,7 @@
     "cmd": [],
     "name": "applied_changes",
     "~followup_annotations": [
-      "@@@STEP_SUMMARY_TEXT@[Change(number=123456, remote='https://pigweed.googlesource.com/pigweed/pigweed', ref='refs/changes/56/123456/7', rebase=True, project='pigweed/pigweed', branch='main', gerrit_name='pigweed', submitted=False, patchset=7, path='WORKSPACE', base=None, base_type=None, is_merge=False, commit_message='', topic=None, current_revision='ffffffffffffffffffffffffffffffffffffffff')]@@@"
+      "@@@STEP_SUMMARY_TEXT@[Change(number=123456, remote='https://pigweed.googlesource.com/pigweed/pigweed', ref='refs/changes/56/123456/7', rebase=True, project='pigweed/pigweed', branch='main', gerrit_name='pigweed', submitted=False, patchset=7, path='../bazel_repos/pigweed_pigweed_pigweed.git', base='REMOTE_BRANCH_REMOTE_BRANCH_REMOTE_BRANCH_', base_type='remote_branch_tip', is_merge=False, commit_message='', topic=None, current_revision='ffffffffffffffffffffffffffffffffffffffff')]@@@"
     ]
   },
   {
diff --git a/recipe_modules/checkout/tests/workspace.expected/not-found.json b/recipe_modules/checkout/tests/workspace.expected/not-found.json
index 1b5ee0f..3bfacba 100644
--- a/recipe_modules/checkout/tests/workspace.expected/not-found.json
+++ b/recipe_modules/checkout/tests/workspace.expected/not-found.json
@@ -1169,6 +1169,36 @@
     ]
   },
   {
+    "cmd": [
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "ensure-directory",
+      "--mode",
+      "0o777",
+      "[START_DIR]/bazel_repos"
+    ],
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout foo.mkdir [START_DIR]/bazel_repos",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
     "cmd": [],
     "name": "checkout foo.workspace",
     "~followup_annotations": [
@@ -1234,6 +1264,7 @@
       "@@@STEP_LOG_LINE@WORKSPACE@    commit = \"1111111111111111111111111111111111111111\",@@@",
       "@@@STEP_LOG_LINE@WORKSPACE@    remote = \"https://pigweed.googlesource.com/pigweed/pigweed.git\",@@@",
       "@@@STEP_LOG_LINE@WORKSPACE@    git_repository_attribute_test = \"ignored\",@@@",
+      "@@@STEP_LOG_LINE@WORKSPACE@    strip_prefix = \"pw_toolchain_bazel\",@@@",
       "@@@STEP_LOG_LINE@WORKSPACE@)@@@",
       "@@@STEP_LOG_LINE@WORKSPACE@@@@",
       "@@@STEP_LOG_LINE@WORKSPACE@git_repository(@@@",
@@ -1269,13 +1300,6 @@
     ]
   },
   {
-    "cmd": [],
-    "name": "checkout foo.workspace.x:123456.WORKSPACE.could not find remote https://x.googlesource.com/bar in [START_DIR]/co/WORKSPACE",
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@4@@@"
-    ]
-  },
-  {
     "cmd": [
       "git",
       "clean",
diff --git a/recipes/bazel_roller.expected/backwards.json b/recipes/bazel_roller.expected/backwards.json
index 753bd4f..33dab05 100644
--- a/recipes/bazel_roller.expected/backwards.json
+++ b/recipes/bazel_roller.expected/backwards.json
@@ -1549,6 +1549,7 @@
       "@@@STEP_LOG_LINE@WORKSPACE@    commit = \"1111111111111111111111111111111111111111\",@@@",
       "@@@STEP_LOG_LINE@WORKSPACE@    remote = \"https://pigweed.googlesource.com/pigweed/pigweed.git\",@@@",
       "@@@STEP_LOG_LINE@WORKSPACE@    git_repository_attribute_test = \"ignored\",@@@",
+      "@@@STEP_LOG_LINE@WORKSPACE@    strip_prefix = \"pw_toolchain_bazel\",@@@",
       "@@@STEP_LOG_LINE@WORKSPACE@)@@@",
       "@@@STEP_LOG_LINE@WORKSPACE@@@@",
       "@@@STEP_LOG_LINE@WORKSPACE@git_repository(@@@",
@@ -1588,7 +1589,7 @@
       "--json-output",
       "/path/to/tmp/json",
       "copy",
-      "git_repository(\n    name = \"other-repo\"\n    remote = \"https://pigweed.googlesource.com/other/repo.git\",\n    commit = \"invalid commit line won't be found\",\n)\n\ngit_repository(\n    name = \"pigweed\",\n    # ROLL: Warning: this entry is automatically updated.\n    # ROLL: Last updated 2012-05-14.\n    # ROLL: By https://cr-buildbucket.appspot.com/build/0.\n    commit = \"2222222222222222222222222222222222222222\",\n    remote = \"https://pigweed.googlesource.com/pigweed/pigweed.git\",\n    git_repository_attribute_test = \"ignored\",\n)\n\ngit_repository(\n    name = \"missing final quote/comma so will miss this line\n    remote = \"https://pigweed.googlesource.com/third/repo.git\",\n    commit = \"2222222222222222222222222222222222222222\",\n)\n",
+      "git_repository(\n    name = \"other-repo\"\n    remote = \"https://pigweed.googlesource.com/other/repo.git\",\n    commit = \"invalid commit line won't be found\",\n)\n\ngit_repository(\n    name = \"pigweed\",\n    # ROLL: Warning: this entry is automatically updated.\n    # ROLL: Last updated 2012-05-14.\n    # ROLL: By https://cr-buildbucket.appspot.com/build/0.\n    commit = \"2222222222222222222222222222222222222222\",\n    remote = \"https://pigweed.googlesource.com/pigweed/pigweed.git\",\n    git_repository_attribute_test = \"ignored\",\n    strip_prefix = \"pw_toolchain_bazel\",\n)\n\ngit_repository(\n    name = \"missing final quote/comma so will miss this line\n    remote = \"https://pigweed.googlesource.com/third/repo.git\",\n    commit = \"2222222222222222222222222222222222222222\",\n)\n",
       "[START_DIR]/co/WORKSPACE"
     ],
     "infra_step": true,
@@ -1608,6 +1609,7 @@
       "@@@STEP_LOG_LINE@WORKSPACE@    commit = \"2222222222222222222222222222222222222222\",@@@",
       "@@@STEP_LOG_LINE@WORKSPACE@    remote = \"https://pigweed.googlesource.com/pigweed/pigweed.git\",@@@",
       "@@@STEP_LOG_LINE@WORKSPACE@    git_repository_attribute_test = \"ignored\",@@@",
+      "@@@STEP_LOG_LINE@WORKSPACE@    strip_prefix = \"pw_toolchain_bazel\",@@@",
       "@@@STEP_LOG_LINE@WORKSPACE@)@@@",
       "@@@STEP_LOG_LINE@WORKSPACE@@@@",
       "@@@STEP_LOG_LINE@WORKSPACE@git_repository(@@@",
diff --git a/recipes/bazel_roller.expected/no-trigger.json b/recipes/bazel_roller.expected/no-trigger.json
index a00f56b..ce916a2 100644
--- a/recipes/bazel_roller.expected/no-trigger.json
+++ b/recipes/bazel_roller.expected/no-trigger.json
@@ -1549,6 +1549,7 @@
       "@@@STEP_LOG_LINE@WORKSPACE@    commit = \"1111111111111111111111111111111111111111\",@@@",
       "@@@STEP_LOG_LINE@WORKSPACE@    remote = \"https://pigweed.googlesource.com/pigweed/pigweed.git\",@@@",
       "@@@STEP_LOG_LINE@WORKSPACE@    git_repository_attribute_test = \"ignored\",@@@",
+      "@@@STEP_LOG_LINE@WORKSPACE@    strip_prefix = \"pw_toolchain_bazel\",@@@",
       "@@@STEP_LOG_LINE@WORKSPACE@)@@@",
       "@@@STEP_LOG_LINE@WORKSPACE@@@@",
       "@@@STEP_LOG_LINE@WORKSPACE@git_repository(@@@",
@@ -1588,7 +1589,7 @@
       "--json-output",
       "/path/to/tmp/json",
       "copy",
-      "git_repository(\n    name = \"other-repo\"\n    remote = \"https://pigweed.googlesource.com/other/repo.git\",\n    commit = \"invalid commit line won't be found\",\n)\n\ngit_repository(\n    name = \"pigweed\",\n    # ROLL: Warning: this entry is automatically updated.\n    # ROLL: Last updated 2012-05-14.\n    # ROLL: By https://cr-buildbucket.appspot.com/build/0.\n    commit = \"2222222222222222222222222222222222222222\",\n    remote = \"https://pigweed.googlesource.com/pigweed/pigweed.git\",\n    git_repository_attribute_test = \"ignored\",\n)\n\ngit_repository(\n    name = \"missing final quote/comma so will miss this line\n    remote = \"https://pigweed.googlesource.com/third/repo.git\",\n    commit = \"2222222222222222222222222222222222222222\",\n)\n",
+      "git_repository(\n    name = \"other-repo\"\n    remote = \"https://pigweed.googlesource.com/other/repo.git\",\n    commit = \"invalid commit line won't be found\",\n)\n\ngit_repository(\n    name = \"pigweed\",\n    # ROLL: Warning: this entry is automatically updated.\n    # ROLL: Last updated 2012-05-14.\n    # ROLL: By https://cr-buildbucket.appspot.com/build/0.\n    commit = \"2222222222222222222222222222222222222222\",\n    remote = \"https://pigweed.googlesource.com/pigweed/pigweed.git\",\n    git_repository_attribute_test = \"ignored\",\n    strip_prefix = \"pw_toolchain_bazel\",\n)\n\ngit_repository(\n    name = \"missing final quote/comma so will miss this line\n    remote = \"https://pigweed.googlesource.com/third/repo.git\",\n    commit = \"2222222222222222222222222222222222222222\",\n)\n",
       "[START_DIR]/co/WORKSPACE"
     ],
     "infra_step": true,
@@ -1608,6 +1609,7 @@
       "@@@STEP_LOG_LINE@WORKSPACE@    commit = \"2222222222222222222222222222222222222222\",@@@",
       "@@@STEP_LOG_LINE@WORKSPACE@    remote = \"https://pigweed.googlesource.com/pigweed/pigweed.git\",@@@",
       "@@@STEP_LOG_LINE@WORKSPACE@    git_repository_attribute_test = \"ignored\",@@@",
+      "@@@STEP_LOG_LINE@WORKSPACE@    strip_prefix = \"pw_toolchain_bazel\",@@@",
       "@@@STEP_LOG_LINE@WORKSPACE@)@@@",
       "@@@STEP_LOG_LINE@WORKSPACE@@@@",
       "@@@STEP_LOG_LINE@WORKSPACE@git_repository(@@@",
diff --git a/recipes/bazel_roller.expected/success.json b/recipes/bazel_roller.expected/success.json
index 67d00a7..cfe7f6a 100644
--- a/recipes/bazel_roller.expected/success.json
+++ b/recipes/bazel_roller.expected/success.json
@@ -1818,6 +1818,7 @@
       "@@@STEP_LOG_LINE@WORKSPACE@    commit = \"1111111111111111111111111111111111111111\",@@@",
       "@@@STEP_LOG_LINE@WORKSPACE@    remote = \"https://pigweed.googlesource.com/pigweed/pigweed.git\",@@@",
       "@@@STEP_LOG_LINE@WORKSPACE@    git_repository_attribute_test = \"ignored\",@@@",
+      "@@@STEP_LOG_LINE@WORKSPACE@    strip_prefix = \"pw_toolchain_bazel\",@@@",
       "@@@STEP_LOG_LINE@WORKSPACE@)@@@",
       "@@@STEP_LOG_LINE@WORKSPACE@@@@",
       "@@@STEP_LOG_LINE@WORKSPACE@git_repository(@@@",
@@ -1857,7 +1858,7 @@
       "--json-output",
       "/path/to/tmp/json",
       "copy",
-      "git_repository(\n    name = \"other-repo\"\n    remote = \"https://pigweed.googlesource.com/other/repo.git\",\n    commit = \"invalid commit line won't be found\",\n)\n\ngit_repository(\n    name = \"pigweed\",\n    # ROLL: Warning: this entry is automatically updated.\n    # ROLL: Last updated 2012-05-14.\n    # ROLL: By https://cr-buildbucket.appspot.com/build/8945511751514863184.\n    commit = \"2d72510e447ab60a9728aeea2362d8be2cbd7789\",\n    remote = \"https://pigweed.googlesource.com/pigweed/pigweed.git\",\n    git_repository_attribute_test = \"ignored\",\n)\n\ngit_repository(\n    name = \"missing final quote/comma so will miss this line\n    remote = \"https://pigweed.googlesource.com/third/repo.git\",\n    commit = \"2222222222222222222222222222222222222222\",\n)\n",
+      "git_repository(\n    name = \"other-repo\"\n    remote = \"https://pigweed.googlesource.com/other/repo.git\",\n    commit = \"invalid commit line won't be found\",\n)\n\ngit_repository(\n    name = \"pigweed\",\n    # ROLL: Warning: this entry is automatically updated.\n    # ROLL: Last updated 2012-05-14.\n    # ROLL: By https://cr-buildbucket.appspot.com/build/8945511751514863184.\n    commit = \"2d72510e447ab60a9728aeea2362d8be2cbd7789\",\n    remote = \"https://pigweed.googlesource.com/pigweed/pigweed.git\",\n    git_repository_attribute_test = \"ignored\",\n    strip_prefix = \"pw_toolchain_bazel\",\n)\n\ngit_repository(\n    name = \"missing final quote/comma so will miss this line\n    remote = \"https://pigweed.googlesource.com/third/repo.git\",\n    commit = \"2222222222222222222222222222222222222222\",\n)\n",
       "[START_DIR]/co/WORKSPACE"
     ],
     "infra_step": true,
@@ -1889,6 +1890,7 @@
       "@@@STEP_LOG_LINE@WORKSPACE@    commit = \"2d72510e447ab60a9728aeea2362d8be2cbd7789\",@@@",
       "@@@STEP_LOG_LINE@WORKSPACE@    remote = \"https://pigweed.googlesource.com/pigweed/pigweed.git\",@@@",
       "@@@STEP_LOG_LINE@WORKSPACE@    git_repository_attribute_test = \"ignored\",@@@",
+      "@@@STEP_LOG_LINE@WORKSPACE@    strip_prefix = \"pw_toolchain_bazel\",@@@",
       "@@@STEP_LOG_LINE@WORKSPACE@)@@@",
       "@@@STEP_LOG_LINE@WORKSPACE@@@@",
       "@@@STEP_LOG_LINE@WORKSPACE@git_repository(@@@",
diff --git a/recipes/bazel_roller.expected/unrecognized-remote.json b/recipes/bazel_roller.expected/unrecognized-remote.json
index 9d08420..db04dc4 100644
--- a/recipes/bazel_roller.expected/unrecognized-remote.json
+++ b/recipes/bazel_roller.expected/unrecognized-remote.json
@@ -2434,6 +2434,7 @@
       "@@@STEP_LOG_LINE@WORKSPACE@    commit = \"1111111111111111111111111111111111111111\",@@@",
       "@@@STEP_LOG_LINE@WORKSPACE@    remote = \"https://pigweed.googlesource.com/pigweed/pigweed.git\",@@@",
       "@@@STEP_LOG_LINE@WORKSPACE@    git_repository_attribute_test = \"ignored\",@@@",
+      "@@@STEP_LOG_LINE@WORKSPACE@    strip_prefix = \"pw_toolchain_bazel\",@@@",
       "@@@STEP_LOG_LINE@WORKSPACE@)@@@",
       "@@@STEP_LOG_LINE@WORKSPACE@@@@",
       "@@@STEP_LOG_LINE@WORKSPACE@git_repository(@@@",