checkout: Add repo cache

Bug: b/523368396
Change-Id: I9ef0a5a180f218572e4ff3a5db27bedfcd705fc6
Reviewed-on: https://pigweed-review.googlesource.com/c/infra/recipes/+/422214
diff --git a/recipe_modules/checkout/api.py b/recipe_modules/checkout/api.py
index 9cef7a3..1000590 100644
--- a/recipe_modules/checkout/api.py
+++ b/recipe_modules/checkout/api.py
@@ -1198,12 +1198,30 @@
                 if ctx.options.repo_sync_timeout_sec:
                     kwargs['timeout'] = ctx.options.repo_sync_timeout_sec
                     kwargs['attempts'] = ctx.options.number_of_attempts
-                self.m.repo.sync(
-                    force_sync=True,
-                    current_branch=True,
-                    jobs=self.m.platform.cpu_count * 3 // 2,
-                    **kwargs,
-                )
+
+                cache = not ctx.options.do_not_cache
+                build = self.m.buildbucket.build
+                if 'pigweed.disable_repo_cache' in build.input.experiments:
+                    cache = False
+
+                if cache:
+                    with self.m.cache.guard('repo'):
+                        cache_dir = self.m.path.cache_dir / 'repo'
+                        self.m.repo.sync(
+                            force_sync=True,
+                            current_branch=True,
+                            jobs=self.m.platform.cpu_count * 3 // 2,
+                            cache_dir=cache_dir,
+                            **kwargs,
+                        )
+                else:
+                    self.m.repo.sync(
+                        force_sync=True,
+                        current_branch=True,
+                        jobs=self.m.platform.cpu_count * 3 // 2,
+                        **kwargs,
+                    )
+
                 self.m.repo.start('base')
 
             if ctx.options.use_trigger:
diff --git a/recipe_modules/checkout/test_api.py b/recipe_modules/checkout/test_api.py
index 188cbca..53ce787 100644
--- a/recipe_modules/checkout/test_api.py
+++ b/recipe_modules/checkout/test_api.py
@@ -160,6 +160,7 @@
         eligible_workspace_paths: Sequence[str] = (),
         use_packfiles: bool = True,
         repo_depth: int | None = None,
+        do_not_cache: bool = False,
     ) -> checkout_options.Options:
         props = checkout_options.Options()
         props.remote = remote
@@ -185,6 +186,7 @@
         props.do_not_use_packfiles = not use_packfiles
         if repo_depth:
             props.repo_depth = repo_depth
+        props.do_not_cache = do_not_cache
         return props
 
     def repo_options(
diff --git a/recipe_modules/checkout/tests/repo.expected/ci.json b/recipe_modules/checkout/tests/repo.expected/ci.json
index 07e21b2..8a4dd45 100644
--- a/recipe_modules/checkout/tests/repo.expected/ci.json
+++ b/recipe_modules/checkout/tests/repo.expected/ci.json
@@ -879,12 +879,51 @@
   },
   {
     "cmd": [
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "ensure-directory",
+      "--mode",
+      "0o777",
+      "[CACHE]/repo"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "name": "checkout pigweed.ensure repo cache dir",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "copy",
+      "",
+      "[CACHE]/repo/.GUARD_FILE"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "name": "checkout pigweed.write repo cache guard file",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
       "RECIPE_MODULE[pigweed::repo]/resources/repo",
       "sync",
       "--force-sync",
       "--current-branch",
       "--jobs",
       "12",
+      "--cache-dir",
+      "[CACHE]/repo",
       "--verbose"
     ],
     "cwd": "[START_DIR]/co",
@@ -897,6 +936,23 @@
   },
   {
     "cmd": [
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "remove",
+      "[CACHE]/repo/.GUARD_FILE"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "name": "checkout pigweed.remove repo cache guard file",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
       "RECIPE_MODULE[pigweed::repo]/resources/repo",
       "start",
       "base",
diff --git a/recipe_modules/checkout/tests/repo.expected/disable_repo_cache_experiment.json b/recipe_modules/checkout/tests/repo.expected/disable_repo_cache_experiment.json
new file mode 100644
index 0000000..44ff731
--- /dev/null
+++ b/recipe_modules/checkout/tests/repo.expected/disable_repo_cache_experiment.json
@@ -0,0 +1,1476 @@
+[
+  {
+    "cmd": [],
+    "name": "checkout pigweed",
+    "~followup_annotations": [
+      "@@@STEP_LINK@applied pigweed:1234 (pigweed_path)@https://pigweed-review.googlesource.com/c/1234@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "checkout pigweed.options",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@",
+      "@@@STEP_SUMMARY_TEXT@remote: \"https://pigweed.googlesource.com/pigweed/manifest\"\nbranch: \"main\"\nuse_repo: true\nmanifest_file: \"default.xml\"\ninitialize_submodules: true\nmatch_branch: true\nuse_trigger: true\n@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "checkout pigweed.options with defaults",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@",
+      "@@@STEP_SUMMARY_TEXT@remote: \"https://pigweed.googlesource.com/pigweed/manifest\"\nbranch: \"main\"\nuse_repo: true\nmanifest_file: \"default.xml\"\ninitialize_submodules: true\nrepo_init_timeout_sec: 120\nrepo_sync_timeout_sec: 900\nnumber_of_attempts: 3\nmatch_branch: true\nsubmodule_timeout_sec: 600\nuse_trigger: true\nmax_attempts: 2\n@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "checkout pigweed.change data",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "checkout pigweed.change data.process gitiles commit",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "checkout pigweed.change data.process gitiles commit.ensure infra/tools/luci/gerrit/${platform}",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@3@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "checkout pigweed.change data.process gitiles commit.ensure infra/tools/luci/gerrit/${platform}.get packages",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@4@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "copy",
+      "RECIPE_MODULE[fuchsia::gerrit]/resources/cipd.ensure",
+      "/path/to/tmp/"
+    ],
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.change data.process gitiles commit.ensure infra/tools/luci/gerrit/${platform}.get packages.read ensure file",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@5@@@",
+      "@@@STEP_LOG_LINE@cipd.ensure@infra/tools/luci/gerrit/${platform} version:pinned-version@@@",
+      "@@@STEP_LOG_END@cipd.ensure@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "checkout pigweed.change data.process gitiles commit.ensure infra/tools/luci/gerrit/${platform}.install infra/tools/luci/gerrit",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@4@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "ensure-directory",
+      "--mode",
+      "0o777",
+      "[START_DIR]/cipd_tool/infra/tools/luci/gerrit/0e548aa33f8113a45a5b3b62201e114e98e63d00f97296912380138f44597b07"
+    ],
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.change data.process gitiles commit.ensure infra/tools/luci/gerrit/${platform}.install infra/tools/luci/gerrit.ensure package directory",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@5@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "cipd",
+      "ensure",
+      "-root",
+      "[START_DIR]/cipd_tool/infra/tools/luci/gerrit/0e548aa33f8113a45a5b3b62201e114e98e63d00f97296912380138f44597b07",
+      "-ensure-file",
+      "infra/tools/luci/gerrit/${platform} version:pinned-version",
+      "-max-threads",
+      "0",
+      "-json-output",
+      "/path/to/tmp/json"
+    ],
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.change data.process gitiles commit.ensure infra/tools/luci/gerrit/${platform}.install infra/tools/luci/gerrit.ensure_installed",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@5@@@",
+      "@@@STEP_LOG_LINE@json.output@{@@@",
+      "@@@STEP_LOG_LINE@json.output@  \"result\": {@@@",
+      "@@@STEP_LOG_LINE@json.output@    \"\": [@@@",
+      "@@@STEP_LOG_LINE@json.output@      {@@@",
+      "@@@STEP_LOG_LINE@json.output@        \"instance_id\": \"resolved-instance_id-of-version:pinned-v\",@@@",
+      "@@@STEP_LOG_LINE@json.output@        \"package\": \"infra/tools/luci/gerrit/resolved-platform\"@@@",
+      "@@@STEP_LOG_LINE@json.output@      }@@@",
+      "@@@STEP_LOG_LINE@json.output@    ]@@@",
+      "@@@STEP_LOG_LINE@json.output@  }@@@",
+      "@@@STEP_LOG_LINE@json.output@}@@@",
+      "@@@STEP_LOG_END@json.output@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "[START_DIR]/cipd_tool/infra/tools/luci/gerrit/0e548aa33f8113a45a5b3b62201e114e98e63d00f97296912380138f44597b07/gerrit",
+      "change-query",
+      "-host",
+      "https://pigweed-review.googlesource.com",
+      "-input",
+      "{\"params\": {\"q\": \"commit:2d72510e447ab60a9728aeea2362d8be2cbd7789\"}}",
+      "-output",
+      "/path/to/tmp/json"
+    ],
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.change data.process gitiles commit.number",
+    "timeout": 30,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@3@@@",
+      "@@@STEP_LOG_LINE@json.output@[@@@",
+      "@@@STEP_LOG_LINE@json.output@  {@@@",
+      "@@@STEP_LOG_LINE@json.output@    \"_number\": \"1234\",@@@",
+      "@@@STEP_LOG_LINE@json.output@    \"branch\": \"main\",@@@",
+      "@@@STEP_LOG_LINE@json.output@    \"project\": \"pigweed\"@@@",
+      "@@@STEP_LOG_LINE@json.output@  }@@@",
+      "@@@STEP_LOG_LINE@json.output@]@@@",
+      "@@@STEP_LOG_END@json.output@@@",
+      "@@@STEP_LOG_LINE@json.input@{@@@",
+      "@@@STEP_LOG_LINE@json.input@  \"params\": {@@@",
+      "@@@STEP_LOG_LINE@json.input@    \"q\": \"commit:2d72510e447ab60a9728aeea2362d8be2cbd7789\"@@@",
+      "@@@STEP_LOG_LINE@json.input@  }@@@",
+      "@@@STEP_LOG_LINE@json.input@}@@@",
+      "@@@STEP_LOG_END@json.input@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "checkout pigweed.change data.changes",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "checkout pigweed.change data.changes.pigweed:1234",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@3@@@",
+      "@@@STEP_SUMMARY_TEXT@Change(number=1234, remote='https://pigweed.googlesource.com/pigweed_name', ref='2d72510e447ab60a9728aeea2362d8be2cbd7789', rebase=False, project='pigweed_name', branch='main', gerrit_name='pigweed', submitted=True, patchset=None, path=None, base=None, base_type=None, is_merge=False, commit_message='', topic=None, current_revision='2d72510e447ab60a9728aeea2362d8be2cbd7789', primary=True, submit_requirements={}, uploader=None)@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "ensure-directory",
+      "--mode",
+      "0o777",
+      "[START_DIR]/co"
+    ],
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.mkdir checkout",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "checkout pigweed.no non-standard branch names",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "RECIPE_MODULE[pigweed::repo]/resources/repo",
+      "init",
+      "--manifest-url",
+      "https://pigweed.googlesource.com/pigweed/manifest",
+      "--groups",
+      "all",
+      "--manifest-branch",
+      "main",
+      "--repo-url",
+      "https://pigweed.googlesource.com/third_party/gerrit/git-repo",
+      "--repo-rev",
+      "b750b48f50eb4a11087ca6775161d5bf4d5c47d5",
+      "--no-repo-verify",
+      "--manifest-name",
+      "default.xml",
+      "--verbose"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.repo init",
+    "timeout": 120,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "find",
+      ".repo/",
+      "-type",
+      "f",
+      "-name",
+      "*.lock",
+      "-print",
+      "-delete"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.clear repo locks",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "RECIPE_MODULE[pigweed::repo]/resources/repo",
+      "forall",
+      "--ignore-missing",
+      "-j",
+      "32",
+      "-c",
+      "find",
+      ".git/",
+      "-type",
+      "f",
+      "-name",
+      "*.lock",
+      "-print",
+      "-delete"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.clear git locks",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "checkout pigweed.read manifest",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@",
+      "@@@STEP_LOG_LINE@raw@<?xml version=\"1.0\" encoding=\"UTF-8\"?>@@@",
+      "@@@STEP_LOG_LINE@raw@<manifest>@@@",
+      "@@@STEP_LOG_LINE@raw@  <remote@@@",
+      "@@@STEP_LOG_LINE@raw@    name=\"default_remote\"@@@",
+      "@@@STEP_LOG_LINE@raw@    fetch=\"sso://default\"@@@",
+      "@@@STEP_LOG_LINE@raw@    />@@@",
+      "@@@STEP_LOG_LINE@raw@@@@",
+      "@@@STEP_LOG_LINE@raw@  <remote@@@",
+      "@@@STEP_LOG_LINE@raw@    name=\"pigweed_remote\"@@@",
+      "@@@STEP_LOG_LINE@raw@    revision=\"main\"@@@",
+      "@@@STEP_LOG_LINE@raw@    fetch=\"..\"@@@",
+      "@@@STEP_LOG_LINE@raw@    review=\"https://pigweed.googlesource.com\"@@@",
+      "@@@STEP_LOG_LINE@raw@    />@@@",
+      "@@@STEP_LOG_LINE@raw@@@@",
+      "@@@STEP_LOG_LINE@raw@  <remote@@@",
+      "@@@STEP_LOG_LINE@raw@    name=\"pigweed-internal_remote\"@@@",
+      "@@@STEP_LOG_LINE@raw@    revision=\"main\"@@@",
+      "@@@STEP_LOG_LINE@raw@    fetch=\"https://pigweed-internal.googlesource.com\"@@@",
+      "@@@STEP_LOG_LINE@raw@    review=\"https://pigweed-internal.googlesource.com\"@@@",
+      "@@@STEP_LOG_LINE@raw@    />@@@",
+      "@@@STEP_LOG_LINE@raw@@@@",
+      "@@@STEP_LOG_LINE@raw@  <remote@@@",
+      "@@@STEP_LOG_LINE@raw@    name=\"prefixed\"@@@",
+      "@@@STEP_LOG_LINE@raw@    fetch=\"https://foo.googlesource.com/prefix\"@@@",
+      "@@@STEP_LOG_LINE@raw@    review=\"https://foo.googlesource.com/prefix\"@@@",
+      "@@@STEP_LOG_LINE@raw@    />@@@",
+      "@@@STEP_LOG_LINE@raw@@@@",
+      "@@@STEP_LOG_LINE@raw@  <default@@@",
+      "@@@STEP_LOG_LINE@raw@    remote=\"default_remote\"@@@",
+      "@@@STEP_LOG_LINE@raw@    revision=\"main\"@@@",
+      "@@@STEP_LOG_LINE@raw@    />@@@",
+      "@@@STEP_LOG_LINE@raw@@@@",
+      "@@@STEP_LOG_LINE@raw@  <project@@@",
+      "@@@STEP_LOG_LINE@raw@    name=\"default_name\"@@@",
+      "@@@STEP_LOG_LINE@raw@    path=\"default_path\"@@@",
+      "@@@STEP_LOG_LINE@raw@    />@@@",
+      "@@@STEP_LOG_LINE@raw@@@@",
+      "@@@STEP_LOG_LINE@raw@  <project@@@",
+      "@@@STEP_LOG_LINE@raw@    name=\"pigweed_name\"@@@",
+      "@@@STEP_LOG_LINE@raw@    path=\"pigweed_path\"@@@",
+      "@@@STEP_LOG_LINE@raw@    remote=\"pigweed_remote\"@@@",
+      "@@@STEP_LOG_LINE@raw@    revision=\"main\"@@@",
+      "@@@STEP_LOG_LINE@raw@    />@@@",
+      "@@@STEP_LOG_LINE@raw@@@@",
+      "@@@STEP_LOG_LINE@raw@  <project@@@",
+      "@@@STEP_LOG_LINE@raw@    name=\"pigweed-internal_name\"@@@",
+      "@@@STEP_LOG_LINE@raw@    path=\"pigweed-internal_path\"@@@",
+      "@@@STEP_LOG_LINE@raw@    remote=\"pigweed-internal_remote\"@@@",
+      "@@@STEP_LOG_LINE@raw@    />@@@",
+      "@@@STEP_LOG_LINE@raw@@@@",
+      "@@@STEP_LOG_LINE@raw@  <project@@@",
+      "@@@STEP_LOG_LINE@raw@    name=\"pinned\"@@@",
+      "@@@STEP_LOG_LINE@raw@    path=\"pinned\"@@@",
+      "@@@STEP_LOG_LINE@raw@    remote=\"pigweed_remote\"@@@",
+      "@@@STEP_LOG_LINE@raw@    revision=\"0123456789012345678901234567890123456789\"@@@",
+      "@@@STEP_LOG_LINE@raw@    upstream=\"main\"@@@",
+      "@@@STEP_LOG_LINE@raw@    />@@@",
+      "@@@STEP_LOG_LINE@raw@@@@",
+      "@@@STEP_LOG_LINE@raw@  <project@@@",
+      "@@@STEP_LOG_LINE@raw@    name=\"suffix\"@@@",
+      "@@@STEP_LOG_LINE@raw@    path=\"prefix/suffix\"@@@",
+      "@@@STEP_LOG_LINE@raw@    remote=\"prefixed\"@@@",
+      "@@@STEP_LOG_LINE@raw@    />@@@",
+      "@@@STEP_LOG_LINE@raw@</manifest>@@@",
+      "@@@STEP_LOG_END@raw@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "copy",
+      "[START_DIR]/co/.repo/manifests/default.xml",
+      "/path/to/tmp/"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.read manifest.read file",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@",
+      "@@@STEP_LOG_LINE@default.xml@<?xml version=\"1.0\" encoding=\"UTF-8\"?>@@@",
+      "@@@STEP_LOG_LINE@default.xml@<manifest>@@@",
+      "@@@STEP_LOG_LINE@default.xml@  <remote@@@",
+      "@@@STEP_LOG_LINE@default.xml@    name=\"default_remote\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    fetch=\"sso://default\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    />@@@",
+      "@@@STEP_LOG_LINE@default.xml@@@@",
+      "@@@STEP_LOG_LINE@default.xml@  <remote@@@",
+      "@@@STEP_LOG_LINE@default.xml@    name=\"pigweed_remote\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    revision=\"main\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    fetch=\"..\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    review=\"https://pigweed.googlesource.com\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    />@@@",
+      "@@@STEP_LOG_LINE@default.xml@@@@",
+      "@@@STEP_LOG_LINE@default.xml@  <remote@@@",
+      "@@@STEP_LOG_LINE@default.xml@    name=\"pigweed-internal_remote\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    revision=\"main\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    fetch=\"https://pigweed-internal.googlesource.com\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    review=\"https://pigweed-internal.googlesource.com\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    />@@@",
+      "@@@STEP_LOG_LINE@default.xml@@@@",
+      "@@@STEP_LOG_LINE@default.xml@  <remote@@@",
+      "@@@STEP_LOG_LINE@default.xml@    name=\"prefixed\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    fetch=\"https://foo.googlesource.com/prefix\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    review=\"https://foo.googlesource.com/prefix\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    />@@@",
+      "@@@STEP_LOG_LINE@default.xml@@@@",
+      "@@@STEP_LOG_LINE@default.xml@  <default@@@",
+      "@@@STEP_LOG_LINE@default.xml@    remote=\"default_remote\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    revision=\"main\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    />@@@",
+      "@@@STEP_LOG_LINE@default.xml@@@@",
+      "@@@STEP_LOG_LINE@default.xml@  <project@@@",
+      "@@@STEP_LOG_LINE@default.xml@    name=\"default_name\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    path=\"default_path\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    />@@@",
+      "@@@STEP_LOG_LINE@default.xml@@@@",
+      "@@@STEP_LOG_LINE@default.xml@  <project@@@",
+      "@@@STEP_LOG_LINE@default.xml@    name=\"pigweed_name\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    path=\"pigweed_path\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    remote=\"pigweed_remote\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    revision=\"main\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    />@@@",
+      "@@@STEP_LOG_LINE@default.xml@@@@",
+      "@@@STEP_LOG_LINE@default.xml@  <project@@@",
+      "@@@STEP_LOG_LINE@default.xml@    name=\"pigweed-internal_name\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    path=\"pigweed-internal_path\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    remote=\"pigweed-internal_remote\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    />@@@",
+      "@@@STEP_LOG_LINE@default.xml@@@@",
+      "@@@STEP_LOG_LINE@default.xml@  <project@@@",
+      "@@@STEP_LOG_LINE@default.xml@    name=\"pinned\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    path=\"pinned\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    remote=\"pigweed_remote\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    revision=\"0123456789012345678901234567890123456789\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    upstream=\"main\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    />@@@",
+      "@@@STEP_LOG_LINE@default.xml@@@@",
+      "@@@STEP_LOG_LINE@default.xml@  <project@@@",
+      "@@@STEP_LOG_LINE@default.xml@    name=\"suffix\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    path=\"prefix/suffix\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    remote=\"prefixed\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    />@@@",
+      "@@@STEP_LOG_LINE@default.xml@</manifest>@@@",
+      "@@@STEP_LOG_END@default.xml@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "checkout pigweed.read manifest.log",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@",
+      "@@@STEP_SUMMARY_TEXT@{'name': 'default_remote', 'fetch': 'sso://default'}@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "checkout pigweed.read manifest.log (2)",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@",
+      "@@@STEP_SUMMARY_TEXT@{'name': 'pigweed_remote', 'revision': 'main', 'fetch': '..', 'review': 'https://pigweed.googlesource.com'}@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "checkout pigweed.read manifest.log (3)",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@",
+      "@@@STEP_SUMMARY_TEXT@{'name': 'pigweed-internal_remote', 'revision': 'main', 'fetch': 'https://pigweed-internal.googlesource.com', 'review': 'https://pigweed-internal.googlesource.com'}@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "checkout pigweed.read manifest.log (4)",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@",
+      "@@@STEP_SUMMARY_TEXT@{'name': 'prefixed', 'fetch': 'https://foo.googlesource.com/prefix', 'review': 'https://foo.googlesource.com/prefix'}@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "copy",
+      "{\"projects\": [{\"name\": \"default_name\", \"path\": \"default_path\", \"remote\": \"default_remote\", \"revision\": \"main\", \"upstream\": \"main\", \"url\": \"https://default.googlesource.com/default_name\"}, {\"name\": \"pigweed_name\", \"path\": \"pigweed_path\", \"remote\": \"pigweed_remote\", \"revision\": \"main\", \"upstream\": \"main\", \"url\": \"https://pigweed.googlesource.com/pigweed_name\"}, {\"name\": \"pigweed-internal_name\", \"path\": \"pigweed-internal_path\", \"remote\": \"pigweed-internal_remote\", \"revision\": \"main\", \"upstream\": \"main\", \"url\": \"https://pigweed-internal.googlesource.com/pigweed-internal_name\"}, {\"name\": \"pinned\", \"path\": \"pinned\", \"remote\": \"pigweed_remote\", \"revision\": \"0123456789012345678901234567890123456789\", \"upstream\": \"main\", \"url\": \"https://pigweed.googlesource.com/pinned\"}, {\"name\": \"suffix\", \"path\": \"prefix/suffix\", \"remote\": \"prefixed\", \"revision\": \"main\", \"upstream\": \"main\", \"url\": \"https://foo.googlesource.com/prefix/suffix\"}], \"remotes\": {\"default_remote\": {\"alias\": null, \"fetch\": {\"https\": \"https://default.googlesource.com\", \"url\": \"sso://default\"}, \"name\": \"default_remote\", \"review\": null, \"revision\": null}, \"pigweed-internal_remote\": {\"alias\": null, \"fetch\": {\"https\": \"https://pigweed-internal.googlesource.com\", \"url\": \"https://pigweed-internal.googlesource.com\"}, \"name\": \"pigweed-internal_remote\", \"review\": \"https://pigweed-internal.googlesource.com\", \"revision\": \"main\"}, \"pigweed_remote\": {\"alias\": null, \"fetch\": {\"https\": \"https://pigweed.googlesource.com\", \"url\": \"https://pigweed.googlesource.com\"}, \"name\": \"pigweed_remote\", \"review\": \"https://pigweed.googlesource.com\", \"revision\": \"main\"}, \"prefixed\": {\"alias\": null, \"fetch\": {\"https\": \"https://foo.googlesource.com/prefix\", \"url\": \"https://foo.googlesource.com/prefix\"}, \"name\": \"prefixed\", \"review\": \"https://foo.googlesource.com/prefix\", \"revision\": null}}}",
+      "[START_DIR]/manifest.json"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.read manifest.manifest json",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@",
+      "@@@STEP_LOG_LINE@manifest.json@{\"projects\": [{\"name\": \"default_name\", \"path\": \"default_path\", \"remote\": \"default_remote\", \"revision\": \"main\", \"upstream\": \"main\", \"url\": \"https://default.googlesource.com/default_name\"}, {\"name\": \"pigweed_name\", \"path\": \"pigweed_path\", \"remote\": \"pigweed_remote\", \"revision\": \"main\", \"upstream\": \"main\", \"url\": \"https://pigweed.googlesource.com/pigweed_name\"}, {\"name\": \"pigweed-internal_name\", \"path\": \"pigweed-internal_path\", \"remote\": \"pigweed-internal_remote\", \"revision\": \"main\", \"upstream\": \"main\", \"url\": \"https://pigweed-internal.googlesource.com/pigweed-internal_name\"}, {\"name\": \"pinned\", \"path\": \"pinned\", \"remote\": \"pigweed_remote\", \"revision\": \"0123456789012345678901234567890123456789\", \"upstream\": \"main\", \"url\": \"https://pigweed.googlesource.com/pinned\"}, {\"name\": \"suffix\", \"path\": \"prefix/suffix\", \"remote\": \"prefixed\", \"revision\": \"main\", \"upstream\": \"main\", \"url\": \"https://foo.googlesource.com/prefix/suffix\"}], \"remotes\": {\"default_remote\": {\"alias\": null, \"fetch\": {\"https\": \"https://default.googlesource.com\", \"url\": \"sso://default\"}, \"name\": \"default_remote\", \"review\": null, \"revision\": null}, \"pigweed-internal_remote\": {\"alias\": null, \"fetch\": {\"https\": \"https://pigweed-internal.googlesource.com\", \"url\": \"https://pigweed-internal.googlesource.com\"}, \"name\": \"pigweed-internal_remote\", \"review\": \"https://pigweed-internal.googlesource.com\", \"revision\": \"main\"}, \"pigweed_remote\": {\"alias\": null, \"fetch\": {\"https\": \"https://pigweed.googlesource.com\", \"url\": \"https://pigweed.googlesource.com\"}, \"name\": \"pigweed_remote\", \"review\": \"https://pigweed.googlesource.com\", \"revision\": \"main\"}, \"prefixed\": {\"alias\": null, \"fetch\": {\"https\": \"https://foo.googlesource.com/prefix\", \"url\": \"https://foo.googlesource.com/prefix\"}, \"name\": \"prefixed\", \"review\": \"https://foo.googlesource.com/prefix\", \"revision\": null}}}@@@",
+      "@@@STEP_LOG_END@manifest.json@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "config",
+      "--global",
+      "--add",
+      "url.https://default.googlesource.com/a.insteadof",
+      "sso://default"
+    ],
+    "cwd": "[START_DIR]/co",
+    "env": {
+      "GIT_ADVICE": "0",
+      "GIT_CONFIG_COUNT": "4",
+      "GIT_CONFIG_KEY_0": "fetch.unpackLimit",
+      "GIT_CONFIG_KEY_1": "gc.auto",
+      "GIT_CONFIG_KEY_2": "gc.autoDetach",
+      "GIT_CONFIG_KEY_3": "gc.autoPackLimit",
+      "GIT_CONFIG_VALUE_0": "1",
+      "GIT_CONFIG_VALUE_1": "0",
+      "GIT_CONFIG_VALUE_2": "0",
+      "GIT_CONFIG_VALUE_3": "0"
+    },
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.git insteadof sso://default",
+    "timeout": 1200.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "RECIPE_MODULE[pigweed::repo]/resources/repo",
+      "sync",
+      "--force-sync",
+      "--current-branch",
+      "--jobs",
+      "12",
+      "--verbose"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.repo sync",
+    "timeout": 900,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "RECIPE_MODULE[pigweed::repo]/resources/repo",
+      "start",
+      "base",
+      "--all"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.repo start",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "checkout pigweed.apply pigweed:1234",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@",
+      "@@@STEP_SUMMARY_TEXT@pigweed_path@@@",
+      "@@@STEP_LINK@gerrit@https://pigweed-review.googlesource.com/c/1234@@@",
+      "@@@STEP_LINK@gitiles@https://pigweed.googlesource.com/pigweed_name/+/2d72510e447ab60a9728aeea2362d8be2cbd7789@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "checkout pigweed.apply pigweed:1234.timeout 10s",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "fetch",
+      "--jobs",
+      "4",
+      "https://pigweed.googlesource.com/pigweed_name",
+      "2d72510e447ab60a9728aeea2362d8be2cbd7789",
+      "--no-recurse-submodules"
+    ],
+    "cwd": "[START_DIR]/co/pigweed_path",
+    "env": {
+      "GIT_ADVICE": "0",
+      "GIT_CONFIG_COUNT": "4",
+      "GIT_CONFIG_KEY_0": "fetch.unpackLimit",
+      "GIT_CONFIG_KEY_1": "gc.auto",
+      "GIT_CONFIG_KEY_2": "gc.autoDetach",
+      "GIT_CONFIG_KEY_3": "gc.autoPackLimit",
+      "GIT_CONFIG_VALUE_0": "1",
+      "GIT_CONFIG_VALUE_1": "0",
+      "GIT_CONFIG_VALUE_2": "0",
+      "GIT_CONFIG_VALUE_3": "0"
+    },
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:1234.git fetch patch",
+    "timeout": 1200.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "checkout",
+      "--force",
+      "-b",
+      "working",
+      "FETCH_HEAD"
+    ],
+    "cwd": "[START_DIR]/co/pigweed_path",
+    "env": {
+      "GIT_ADVICE": "0",
+      "GIT_CONFIG_COUNT": "4",
+      "GIT_CONFIG_KEY_0": "fetch.unpackLimit",
+      "GIT_CONFIG_KEY_1": "gc.auto",
+      "GIT_CONFIG_KEY_2": "gc.autoDetach",
+      "GIT_CONFIG_KEY_3": "gc.autoPackLimit",
+      "GIT_CONFIG_VALUE_0": "1",
+      "GIT_CONFIG_VALUE_1": "0",
+      "GIT_CONFIG_VALUE_2": "0",
+      "GIT_CONFIG_VALUE_3": "0"
+    },
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:1234.git checkout patch",
+    "timeout": 1200.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "remote",
+      "add",
+      "https___pigweed_googlesource_com_pigweed_name",
+      "https://pigweed.googlesource.com/pigweed_name"
+    ],
+    "cwd": "[START_DIR]/co/pigweed_path",
+    "env": {
+      "GIT_ADVICE": "0",
+      "GIT_CONFIG_COUNT": "4",
+      "GIT_CONFIG_KEY_0": "fetch.unpackLimit",
+      "GIT_CONFIG_KEY_1": "gc.auto",
+      "GIT_CONFIG_KEY_2": "gc.autoDetach",
+      "GIT_CONFIG_KEY_3": "gc.autoPackLimit",
+      "GIT_CONFIG_VALUE_0": "1",
+      "GIT_CONFIG_VALUE_1": "0",
+      "GIT_CONFIG_VALUE_2": "0",
+      "GIT_CONFIG_VALUE_3": "0"
+    },
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:1234.git remote add",
+    "timeout": 1200.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "checkout pigweed.apply pigweed:1234.timeout 10s (2)",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "fetch",
+      "--jobs",
+      "4",
+      "https___pigweed_googlesource_com_pigweed_name",
+      "refs/heads/main"
+    ],
+    "cwd": "[START_DIR]/co/pigweed_path",
+    "env": {
+      "GIT_ADVICE": "0",
+      "GIT_CONFIG_COUNT": "4",
+      "GIT_CONFIG_KEY_0": "fetch.unpackLimit",
+      "GIT_CONFIG_KEY_1": "gc.auto",
+      "GIT_CONFIG_KEY_2": "gc.autoDetach",
+      "GIT_CONFIG_KEY_3": "gc.autoPackLimit",
+      "GIT_CONFIG_VALUE_0": "1",
+      "GIT_CONFIG_VALUE_1": "0",
+      "GIT_CONFIG_VALUE_2": "0",
+      "GIT_CONFIG_VALUE_3": "0"
+    },
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:1234.fetch main branch",
+    "timeout": 1200.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "branch",
+      "--set-upstream-to=https___pigweed_googlesource_com_pigweed_name/main"
+    ],
+    "cwd": "[START_DIR]/co/pigweed_path",
+    "env": {
+      "GIT_ADVICE": "0",
+      "GIT_CONFIG_COUNT": "4",
+      "GIT_CONFIG_KEY_0": "fetch.unpackLimit",
+      "GIT_CONFIG_KEY_1": "gc.auto",
+      "GIT_CONFIG_KEY_2": "gc.autoDetach",
+      "GIT_CONFIG_KEY_3": "gc.autoPackLimit",
+      "GIT_CONFIG_VALUE_0": "1",
+      "GIT_CONFIG_VALUE_1": "0",
+      "GIT_CONFIG_VALUE_2": "0",
+      "GIT_CONFIG_VALUE_3": "0"
+    },
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:1234.git set upstream",
+    "timeout": 1200.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "rev-parse",
+      "HEAD"
+    ],
+    "cwd": "[START_DIR]/co/pigweed_path",
+    "env": {
+      "GIT_ADVICE": "0",
+      "GIT_CONFIG_COUNT": "4",
+      "GIT_CONFIG_KEY_0": "fetch.unpackLimit",
+      "GIT_CONFIG_KEY_1": "gc.auto",
+      "GIT_CONFIG_KEY_2": "gc.autoDetach",
+      "GIT_CONFIG_KEY_3": "gc.autoPackLimit",
+      "GIT_CONFIG_VALUE_0": "1",
+      "GIT_CONFIG_VALUE_1": "0",
+      "GIT_CONFIG_VALUE_2": "0",
+      "GIT_CONFIG_VALUE_3": "0"
+    },
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:1234.git rev-parse",
+    "timeout": 300.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "log",
+      "--oneline",
+      "-n",
+      "10"
+    ],
+    "cwd": "[START_DIR]/co/pigweed_path",
+    "env": {
+      "GIT_ADVICE": "0",
+      "GIT_CONFIG_COUNT": "4",
+      "GIT_CONFIG_KEY_0": "fetch.unpackLimit",
+      "GIT_CONFIG_KEY_1": "gc.auto",
+      "GIT_CONFIG_KEY_2": "gc.autoDetach",
+      "GIT_CONFIG_KEY_3": "gc.autoPackLimit",
+      "GIT_CONFIG_VALUE_0": "1",
+      "GIT_CONFIG_VALUE_1": "0",
+      "GIT_CONFIG_VALUE_2": "0",
+      "GIT_CONFIG_VALUE_3": "0"
+    },
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:1234.post-rebase log",
+    "timeout": 1200.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "checkout pigweed.apply pigweed:1234.timeout 10s (3)",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "checkout",
+      "--detach"
+    ],
+    "cwd": "[START_DIR]/co/pigweed_path",
+    "env": {
+      "GIT_ADVICE": "0",
+      "GIT_CONFIG_COUNT": "4",
+      "GIT_CONFIG_KEY_0": "fetch.unpackLimit",
+      "GIT_CONFIG_KEY_1": "gc.auto",
+      "GIT_CONFIG_KEY_2": "gc.autoDetach",
+      "GIT_CONFIG_KEY_3": "gc.autoPackLimit",
+      "GIT_CONFIG_VALUE_0": "1",
+      "GIT_CONFIG_VALUE_1": "0",
+      "GIT_CONFIG_VALUE_2": "0",
+      "GIT_CONFIG_VALUE_3": "0"
+    },
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:1234.detach",
+    "timeout": 1200.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "submodule",
+      "sync",
+      "--recursive"
+    ],
+    "cwd": "[START_DIR]/co/pigweed_path",
+    "env": {
+      "GIT_ADVICE": "0",
+      "GIT_CONFIG_COUNT": "4",
+      "GIT_CONFIG_KEY_0": "fetch.unpackLimit",
+      "GIT_CONFIG_KEY_1": "gc.auto",
+      "GIT_CONFIG_KEY_2": "gc.autoDetach",
+      "GIT_CONFIG_KEY_3": "gc.autoPackLimit",
+      "GIT_CONFIG_VALUE_0": "1",
+      "GIT_CONFIG_VALUE_1": "0",
+      "GIT_CONFIG_VALUE_2": "0",
+      "GIT_CONFIG_VALUE_3": "0"
+    },
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:1234.git submodule sync",
+    "timeout": 1200.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "submodule",
+      "update",
+      "--init",
+      "--recursive",
+      "--jobs",
+      "4"
+    ],
+    "cwd": "[START_DIR]/co/pigweed_path",
+    "env": {
+      "GIT_ADVICE": "0",
+      "GIT_CONFIG_COUNT": "4",
+      "GIT_CONFIG_KEY_0": "fetch.unpackLimit",
+      "GIT_CONFIG_KEY_1": "gc.auto",
+      "GIT_CONFIG_KEY_2": "gc.autoDetach",
+      "GIT_CONFIG_KEY_3": "gc.autoPackLimit",
+      "GIT_CONFIG_VALUE_0": "1",
+      "GIT_CONFIG_VALUE_1": "0",
+      "GIT_CONFIG_VALUE_2": "0",
+      "GIT_CONFIG_VALUE_3": "0"
+    },
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:1234.git submodule update",
+    "timeout": 600,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "checkout",
+      "-"
+    ],
+    "cwd": "[START_DIR]/co/pigweed_path",
+    "env": {
+      "GIT_ADVICE": "0",
+      "GIT_CONFIG_COUNT": "4",
+      "GIT_CONFIG_KEY_0": "fetch.unpackLimit",
+      "GIT_CONFIG_KEY_1": "gc.auto",
+      "GIT_CONFIG_KEY_2": "gc.autoDetach",
+      "GIT_CONFIG_KEY_3": "gc.autoPackLimit",
+      "GIT_CONFIG_VALUE_0": "1",
+      "GIT_CONFIG_VALUE_1": "0",
+      "GIT_CONFIG_VALUE_2": "0",
+      "GIT_CONFIG_VALUE_3": "0"
+    },
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:1234.reattach",
+    "timeout": 1200.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "checkout pigweed.apply pigweed:1234.compare branch name",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@",
+      "@@@STEP_SUMMARY_TEXT@CL branch: main\nupstream branch: main@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "checkout pigweed.status",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@",
+      "@@@STEP_SUMMARY_TEXT@applied [Change(number=1234, remote='https://pigweed.googlesource.com/pigweed_name', ref='2d72510e447ab60a9728aeea2362d8be2cbd7789', rebase=False, project='pigweed_name', branch='main', gerrit_name='pigweed', submitted=True, patchset=None, path='pigweed_path', base='HEAD_HEAD_HEAD_HEAD_HEAD_HEAD_HEAD_HEAD_', base_type='submitted_commit_hash', is_merge=False, commit_message='', topic=None, current_revision='2d72510e447ab60a9728aeea2362d8be2cbd7789', primary=True, submit_requirements={}, uploader=None)]\nnot applied []@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "ensure-directory",
+      "--mode",
+      "0o777",
+      "[START_DIR]/snapshot"
+    ],
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.mkdir",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "RECIPE_MODULE[pigweed::repo]/resources/repo",
+      "manifest",
+      "-r"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.repo manifest",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@",
+      "@@@STEP_LOG_LINE@raw_io.output_text@<manifest></manifest>@@@",
+      "@@@STEP_LOG_END@raw_io.output_text@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "copy",
+      "<manifest></manifest>",
+      "[START_DIR]/snapshot/manifest.xml"
+    ],
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.write manifest.xml",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@",
+      "@@@STEP_LOG_LINE@manifest.xml@<manifest></manifest>@@@",
+      "@@@STEP_LOG_END@manifest.xml@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "log",
+      "--oneline",
+      "-n",
+      "10"
+    ],
+    "cwd": "[START_DIR]/co",
+    "env": {
+      "GIT_ADVICE": "0",
+      "GIT_CONFIG_COUNT": "4",
+      "GIT_CONFIG_KEY_0": "fetch.unpackLimit",
+      "GIT_CONFIG_KEY_1": "gc.auto",
+      "GIT_CONFIG_KEY_2": "gc.autoDetach",
+      "GIT_CONFIG_KEY_3": "gc.autoPackLimit",
+      "GIT_CONFIG_VALUE_0": "1",
+      "GIT_CONFIG_VALUE_1": "0",
+      "GIT_CONFIG_VALUE_2": "0",
+      "GIT_CONFIG_VALUE_3": "0"
+    },
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.log",
+    "timeout": 1200.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "copy",
+      "",
+      "[START_DIR]/snapshot/git.log"
+    ],
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.write git log",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@",
+      "@@@STEP_LOG_END@git.log@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "changes"
+  },
+  {
+    "cmd": [],
+    "name": "changes.0",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@",
+      "@@@STEP_SUMMARY_TEXT@Change(number=1234, remote='https://pigweed.googlesource.com/pigweed_name', ref='2d72510e447ab60a9728aeea2362d8be2cbd7789', rebase=False, project='pigweed_name', branch='main', gerrit_name='pigweed', submitted=True, patchset=None, path='pigweed_path', base='HEAD_HEAD_HEAD_HEAD_HEAD_HEAD_HEAD_HEAD_', base_type='submitted_commit_hash', is_merge=False, commit_message='', topic=None, current_revision='2d72510e447ab60a9728aeea2362d8be2cbd7789', primary=True, submit_requirements={}, uploader=None)@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "snapshot_to_dir"
+  },
+  {
+    "cmd": [
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "ensure-directory",
+      "--mode",
+      "0o777",
+      "[START_DIR]/snapshot"
+    ],
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "snapshot_to_dir.mkdir",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "copy",
+      "<manifest></manifest>",
+      "[START_DIR]/snapshot/manifest.xml"
+    ],
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "snapshot_to_dir.write manifest.xml",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@",
+      "@@@STEP_LOG_LINE@manifest.xml@<manifest></manifest>@@@",
+      "@@@STEP_LOG_END@manifest.xml@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "log",
+      "--oneline",
+      "-n",
+      "10"
+    ],
+    "cwd": "[START_DIR]/co",
+    "env": {
+      "GIT_ADVICE": "0",
+      "GIT_CONFIG_COUNT": "4",
+      "GIT_CONFIG_KEY_0": "fetch.unpackLimit",
+      "GIT_CONFIG_KEY_1": "gc.auto",
+      "GIT_CONFIG_KEY_2": "gc.autoDetach",
+      "GIT_CONFIG_KEY_3": "gc.autoPackLimit",
+      "GIT_CONFIG_VALUE_0": "1",
+      "GIT_CONFIG_VALUE_1": "0",
+      "GIT_CONFIG_VALUE_2": "0",
+      "GIT_CONFIG_VALUE_3": "0"
+    },
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "snapshot_to_dir.log",
+    "timeout": 1200.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "copy",
+      "",
+      "[START_DIR]/snapshot/git.log"
+    ],
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "snapshot_to_dir.write git log",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@",
+      "@@@STEP_LOG_END@git.log@@@"
+    ]
+  },
+  {
+    "name": "$result"
+  }
+]
\ No newline at end of file
diff --git a/recipe_modules/checkout/tests/repo.expected/feature_branches_ci.json b/recipe_modules/checkout/tests/repo.expected/feature_branches_ci.json
index 40a522c..48bd0ec 100644
--- a/recipe_modules/checkout/tests/repo.expected/feature_branches_ci.json
+++ b/recipe_modules/checkout/tests/repo.expected/feature_branches_ci.json
@@ -699,12 +699,75 @@
   },
   {
     "cmd": [
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "ensure-directory",
+      "--mode",
+      "0o777",
+      "[CACHE]/repo"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.ensure repo cache dir",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "copy",
+      "",
+      "[CACHE]/repo/.GUARD_FILE"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.write repo cache guard file",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
       "RECIPE_MODULE[pigweed::repo]/resources/repo",
       "sync",
       "--force-sync",
       "--current-branch",
       "--jobs",
       "12",
+      "--cache-dir",
+      "[CACHE]/repo",
       "--verbose"
     ],
     "cwd": "[START_DIR]/co",
@@ -729,6 +792,35 @@
   },
   {
     "cmd": [
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "remove",
+      "[CACHE]/repo/.GUARD_FILE"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.remove repo cache guard file",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
       "RECIPE_MODULE[pigweed::repo]/resources/repo",
       "start",
       "base",
diff --git a/recipe_modules/checkout/tests/repo.expected/feature_branches_try.json b/recipe_modules/checkout/tests/repo.expected/feature_branches_try.json
index ab49c16..973c1dc 100644
--- a/recipe_modules/checkout/tests/repo.expected/feature_branches_try.json
+++ b/recipe_modules/checkout/tests/repo.expected/feature_branches_try.json
@@ -814,12 +814,75 @@
   },
   {
     "cmd": [
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "ensure-directory",
+      "--mode",
+      "0o777",
+      "[CACHE]/repo"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.ensure repo cache dir",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "copy",
+      "",
+      "[CACHE]/repo/.GUARD_FILE"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.write repo cache guard file",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
       "RECIPE_MODULE[pigweed::repo]/resources/repo",
       "sync",
       "--force-sync",
       "--current-branch",
       "--jobs",
       "12",
+      "--cache-dir",
+      "[CACHE]/repo",
       "--verbose"
     ],
     "cwd": "[START_DIR]/co",
@@ -844,6 +907,35 @@
   },
   {
     "cmd": [
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "remove",
+      "[CACHE]/repo/.GUARD_FILE"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.remove repo cache guard file",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
       "RECIPE_MODULE[pigweed::repo]/resources/repo",
       "start",
       "base",
diff --git a/recipe_modules/checkout/tests/repo.expected/feature_branches_try_multiple_features.json b/recipe_modules/checkout/tests/repo.expected/feature_branches_try_multiple_features.json
index b90b4e9..3ed250d 100644
--- a/recipe_modules/checkout/tests/repo.expected/feature_branches_try_multiple_features.json
+++ b/recipe_modules/checkout/tests/repo.expected/feature_branches_try_multiple_features.json
@@ -943,12 +943,75 @@
   },
   {
     "cmd": [
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "ensure-directory",
+      "--mode",
+      "0o777",
+      "[CACHE]/repo"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.ensure repo cache dir",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "copy",
+      "",
+      "[CACHE]/repo/.GUARD_FILE"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.write repo cache guard file",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
       "RECIPE_MODULE[pigweed::repo]/resources/repo",
       "sync",
       "--force-sync",
       "--current-branch",
       "--jobs",
       "12",
+      "--cache-dir",
+      "[CACHE]/repo",
       "--verbose"
     ],
     "cwd": "[START_DIR]/co",
@@ -973,6 +1036,35 @@
   },
   {
     "cmd": [
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "remove",
+      "[CACHE]/repo/.GUARD_FILE"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.remove repo cache guard file",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
       "RECIPE_MODULE[pigweed::repo]/resources/repo",
       "start",
       "base",
diff --git a/recipe_modules/checkout/tests/repo.expected/feature_branches_try_no_matching.json b/recipe_modules/checkout/tests/repo.expected/feature_branches_try_no_matching.json
index 9d6a9a3..b8e50cd 100644
--- a/recipe_modules/checkout/tests/repo.expected/feature_branches_try_no_matching.json
+++ b/recipe_modules/checkout/tests/repo.expected/feature_branches_try_no_matching.json
@@ -828,12 +828,75 @@
   },
   {
     "cmd": [
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "ensure-directory",
+      "--mode",
+      "0o777",
+      "[CACHE]/repo"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.ensure repo cache dir",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "copy",
+      "",
+      "[CACHE]/repo/.GUARD_FILE"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.write repo cache guard file",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
       "RECIPE_MODULE[pigweed::repo]/resources/repo",
       "sync",
       "--force-sync",
       "--current-branch",
       "--jobs",
       "12",
+      "--cache-dir",
+      "[CACHE]/repo",
       "--verbose"
     ],
     "cwd": "[START_DIR]/co",
@@ -858,6 +921,35 @@
   },
   {
     "cmd": [
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "remove",
+      "[CACHE]/repo/.GUARD_FILE"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.remove repo cache guard file",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
       "RECIPE_MODULE[pigweed::repo]/resources/repo",
       "start",
       "base",
diff --git a/recipe_modules/checkout/tests/repo.expected/no_cache.json b/recipe_modules/checkout/tests/repo.expected/no_cache.json
new file mode 100644
index 0000000..ab354b8
--- /dev/null
+++ b/recipe_modules/checkout/tests/repo.expected/no_cache.json
@@ -0,0 +1,1476 @@
+[
+  {
+    "cmd": [],
+    "name": "checkout pigweed",
+    "~followup_annotations": [
+      "@@@STEP_LINK@applied pigweed:1234 (pigweed_path)@https://pigweed-review.googlesource.com/c/1234@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "checkout pigweed.options",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@",
+      "@@@STEP_SUMMARY_TEXT@remote: \"https://pigweed.googlesource.com/pigweed/manifest\"\nbranch: \"main\"\nuse_repo: true\nmanifest_file: \"default.xml\"\ninitialize_submodules: true\nmatch_branch: true\nuse_trigger: true\ndo_not_cache: true\n@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "checkout pigweed.options with defaults",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@",
+      "@@@STEP_SUMMARY_TEXT@remote: \"https://pigweed.googlesource.com/pigweed/manifest\"\nbranch: \"main\"\nuse_repo: true\nmanifest_file: \"default.xml\"\ninitialize_submodules: true\nrepo_init_timeout_sec: 120\nrepo_sync_timeout_sec: 900\nnumber_of_attempts: 3\nmatch_branch: true\nsubmodule_timeout_sec: 600\nuse_trigger: true\ndo_not_cache: true\nmax_attempts: 2\n@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "checkout pigweed.change data",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "checkout pigweed.change data.process gitiles commit",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "checkout pigweed.change data.process gitiles commit.ensure infra/tools/luci/gerrit/${platform}",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@3@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "checkout pigweed.change data.process gitiles commit.ensure infra/tools/luci/gerrit/${platform}.get packages",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@4@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "copy",
+      "RECIPE_MODULE[fuchsia::gerrit]/resources/cipd.ensure",
+      "/path/to/tmp/"
+    ],
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.change data.process gitiles commit.ensure infra/tools/luci/gerrit/${platform}.get packages.read ensure file",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@5@@@",
+      "@@@STEP_LOG_LINE@cipd.ensure@infra/tools/luci/gerrit/${platform} version:pinned-version@@@",
+      "@@@STEP_LOG_END@cipd.ensure@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "checkout pigweed.change data.process gitiles commit.ensure infra/tools/luci/gerrit/${platform}.install infra/tools/luci/gerrit",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@4@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "ensure-directory",
+      "--mode",
+      "0o777",
+      "[START_DIR]/cipd_tool/infra/tools/luci/gerrit/0e548aa33f8113a45a5b3b62201e114e98e63d00f97296912380138f44597b07"
+    ],
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.change data.process gitiles commit.ensure infra/tools/luci/gerrit/${platform}.install infra/tools/luci/gerrit.ensure package directory",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@5@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "cipd",
+      "ensure",
+      "-root",
+      "[START_DIR]/cipd_tool/infra/tools/luci/gerrit/0e548aa33f8113a45a5b3b62201e114e98e63d00f97296912380138f44597b07",
+      "-ensure-file",
+      "infra/tools/luci/gerrit/${platform} version:pinned-version",
+      "-max-threads",
+      "0",
+      "-json-output",
+      "/path/to/tmp/json"
+    ],
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.change data.process gitiles commit.ensure infra/tools/luci/gerrit/${platform}.install infra/tools/luci/gerrit.ensure_installed",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@5@@@",
+      "@@@STEP_LOG_LINE@json.output@{@@@",
+      "@@@STEP_LOG_LINE@json.output@  \"result\": {@@@",
+      "@@@STEP_LOG_LINE@json.output@    \"\": [@@@",
+      "@@@STEP_LOG_LINE@json.output@      {@@@",
+      "@@@STEP_LOG_LINE@json.output@        \"instance_id\": \"resolved-instance_id-of-version:pinned-v\",@@@",
+      "@@@STEP_LOG_LINE@json.output@        \"package\": \"infra/tools/luci/gerrit/resolved-platform\"@@@",
+      "@@@STEP_LOG_LINE@json.output@      }@@@",
+      "@@@STEP_LOG_LINE@json.output@    ]@@@",
+      "@@@STEP_LOG_LINE@json.output@  }@@@",
+      "@@@STEP_LOG_LINE@json.output@}@@@",
+      "@@@STEP_LOG_END@json.output@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "[START_DIR]/cipd_tool/infra/tools/luci/gerrit/0e548aa33f8113a45a5b3b62201e114e98e63d00f97296912380138f44597b07/gerrit",
+      "change-query",
+      "-host",
+      "https://pigweed-review.googlesource.com",
+      "-input",
+      "{\"params\": {\"q\": \"commit:2d72510e447ab60a9728aeea2362d8be2cbd7789\"}}",
+      "-output",
+      "/path/to/tmp/json"
+    ],
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.change data.process gitiles commit.number",
+    "timeout": 30,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@3@@@",
+      "@@@STEP_LOG_LINE@json.output@[@@@",
+      "@@@STEP_LOG_LINE@json.output@  {@@@",
+      "@@@STEP_LOG_LINE@json.output@    \"_number\": \"1234\",@@@",
+      "@@@STEP_LOG_LINE@json.output@    \"branch\": \"main\",@@@",
+      "@@@STEP_LOG_LINE@json.output@    \"project\": \"pigweed\"@@@",
+      "@@@STEP_LOG_LINE@json.output@  }@@@",
+      "@@@STEP_LOG_LINE@json.output@]@@@",
+      "@@@STEP_LOG_END@json.output@@@",
+      "@@@STEP_LOG_LINE@json.input@{@@@",
+      "@@@STEP_LOG_LINE@json.input@  \"params\": {@@@",
+      "@@@STEP_LOG_LINE@json.input@    \"q\": \"commit:2d72510e447ab60a9728aeea2362d8be2cbd7789\"@@@",
+      "@@@STEP_LOG_LINE@json.input@  }@@@",
+      "@@@STEP_LOG_LINE@json.input@}@@@",
+      "@@@STEP_LOG_END@json.input@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "checkout pigweed.change data.changes",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "checkout pigweed.change data.changes.pigweed:1234",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@3@@@",
+      "@@@STEP_SUMMARY_TEXT@Change(number=1234, remote='https://pigweed.googlesource.com/pigweed_name', ref='2d72510e447ab60a9728aeea2362d8be2cbd7789', rebase=False, project='pigweed_name', branch='main', gerrit_name='pigweed', submitted=True, patchset=None, path=None, base=None, base_type=None, is_merge=False, commit_message='', topic=None, current_revision='2d72510e447ab60a9728aeea2362d8be2cbd7789', primary=True, submit_requirements={}, uploader=None)@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "ensure-directory",
+      "--mode",
+      "0o777",
+      "[START_DIR]/co"
+    ],
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.mkdir checkout",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "checkout pigweed.no non-standard branch names",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "RECIPE_MODULE[pigweed::repo]/resources/repo",
+      "init",
+      "--manifest-url",
+      "https://pigweed.googlesource.com/pigweed/manifest",
+      "--groups",
+      "all",
+      "--manifest-branch",
+      "main",
+      "--repo-url",
+      "https://pigweed.googlesource.com/third_party/gerrit/git-repo",
+      "--repo-rev",
+      "b750b48f50eb4a11087ca6775161d5bf4d5c47d5",
+      "--no-repo-verify",
+      "--manifest-name",
+      "default.xml",
+      "--verbose"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.repo init",
+    "timeout": 120,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "find",
+      ".repo/",
+      "-type",
+      "f",
+      "-name",
+      "*.lock",
+      "-print",
+      "-delete"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.clear repo locks",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "RECIPE_MODULE[pigweed::repo]/resources/repo",
+      "forall",
+      "--ignore-missing",
+      "-j",
+      "32",
+      "-c",
+      "find",
+      ".git/",
+      "-type",
+      "f",
+      "-name",
+      "*.lock",
+      "-print",
+      "-delete"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.clear git locks",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "checkout pigweed.read manifest",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@",
+      "@@@STEP_LOG_LINE@raw@<?xml version=\"1.0\" encoding=\"UTF-8\"?>@@@",
+      "@@@STEP_LOG_LINE@raw@<manifest>@@@",
+      "@@@STEP_LOG_LINE@raw@  <remote@@@",
+      "@@@STEP_LOG_LINE@raw@    name=\"default_remote\"@@@",
+      "@@@STEP_LOG_LINE@raw@    fetch=\"sso://default\"@@@",
+      "@@@STEP_LOG_LINE@raw@    />@@@",
+      "@@@STEP_LOG_LINE@raw@@@@",
+      "@@@STEP_LOG_LINE@raw@  <remote@@@",
+      "@@@STEP_LOG_LINE@raw@    name=\"pigweed_remote\"@@@",
+      "@@@STEP_LOG_LINE@raw@    revision=\"main\"@@@",
+      "@@@STEP_LOG_LINE@raw@    fetch=\"..\"@@@",
+      "@@@STEP_LOG_LINE@raw@    review=\"https://pigweed.googlesource.com\"@@@",
+      "@@@STEP_LOG_LINE@raw@    />@@@",
+      "@@@STEP_LOG_LINE@raw@@@@",
+      "@@@STEP_LOG_LINE@raw@  <remote@@@",
+      "@@@STEP_LOG_LINE@raw@    name=\"pigweed-internal_remote\"@@@",
+      "@@@STEP_LOG_LINE@raw@    revision=\"main\"@@@",
+      "@@@STEP_LOG_LINE@raw@    fetch=\"https://pigweed-internal.googlesource.com\"@@@",
+      "@@@STEP_LOG_LINE@raw@    review=\"https://pigweed-internal.googlesource.com\"@@@",
+      "@@@STEP_LOG_LINE@raw@    />@@@",
+      "@@@STEP_LOG_LINE@raw@@@@",
+      "@@@STEP_LOG_LINE@raw@  <remote@@@",
+      "@@@STEP_LOG_LINE@raw@    name=\"prefixed\"@@@",
+      "@@@STEP_LOG_LINE@raw@    fetch=\"https://foo.googlesource.com/prefix\"@@@",
+      "@@@STEP_LOG_LINE@raw@    review=\"https://foo.googlesource.com/prefix\"@@@",
+      "@@@STEP_LOG_LINE@raw@    />@@@",
+      "@@@STEP_LOG_LINE@raw@@@@",
+      "@@@STEP_LOG_LINE@raw@  <default@@@",
+      "@@@STEP_LOG_LINE@raw@    remote=\"default_remote\"@@@",
+      "@@@STEP_LOG_LINE@raw@    revision=\"main\"@@@",
+      "@@@STEP_LOG_LINE@raw@    />@@@",
+      "@@@STEP_LOG_LINE@raw@@@@",
+      "@@@STEP_LOG_LINE@raw@  <project@@@",
+      "@@@STEP_LOG_LINE@raw@    name=\"default_name\"@@@",
+      "@@@STEP_LOG_LINE@raw@    path=\"default_path\"@@@",
+      "@@@STEP_LOG_LINE@raw@    />@@@",
+      "@@@STEP_LOG_LINE@raw@@@@",
+      "@@@STEP_LOG_LINE@raw@  <project@@@",
+      "@@@STEP_LOG_LINE@raw@    name=\"pigweed_name\"@@@",
+      "@@@STEP_LOG_LINE@raw@    path=\"pigweed_path\"@@@",
+      "@@@STEP_LOG_LINE@raw@    remote=\"pigweed_remote\"@@@",
+      "@@@STEP_LOG_LINE@raw@    revision=\"main\"@@@",
+      "@@@STEP_LOG_LINE@raw@    />@@@",
+      "@@@STEP_LOG_LINE@raw@@@@",
+      "@@@STEP_LOG_LINE@raw@  <project@@@",
+      "@@@STEP_LOG_LINE@raw@    name=\"pigweed-internal_name\"@@@",
+      "@@@STEP_LOG_LINE@raw@    path=\"pigweed-internal_path\"@@@",
+      "@@@STEP_LOG_LINE@raw@    remote=\"pigweed-internal_remote\"@@@",
+      "@@@STEP_LOG_LINE@raw@    />@@@",
+      "@@@STEP_LOG_LINE@raw@@@@",
+      "@@@STEP_LOG_LINE@raw@  <project@@@",
+      "@@@STEP_LOG_LINE@raw@    name=\"pinned\"@@@",
+      "@@@STEP_LOG_LINE@raw@    path=\"pinned\"@@@",
+      "@@@STEP_LOG_LINE@raw@    remote=\"pigweed_remote\"@@@",
+      "@@@STEP_LOG_LINE@raw@    revision=\"0123456789012345678901234567890123456789\"@@@",
+      "@@@STEP_LOG_LINE@raw@    upstream=\"main\"@@@",
+      "@@@STEP_LOG_LINE@raw@    />@@@",
+      "@@@STEP_LOG_LINE@raw@@@@",
+      "@@@STEP_LOG_LINE@raw@  <project@@@",
+      "@@@STEP_LOG_LINE@raw@    name=\"suffix\"@@@",
+      "@@@STEP_LOG_LINE@raw@    path=\"prefix/suffix\"@@@",
+      "@@@STEP_LOG_LINE@raw@    remote=\"prefixed\"@@@",
+      "@@@STEP_LOG_LINE@raw@    />@@@",
+      "@@@STEP_LOG_LINE@raw@</manifest>@@@",
+      "@@@STEP_LOG_END@raw@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "copy",
+      "[START_DIR]/co/.repo/manifests/default.xml",
+      "/path/to/tmp/"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.read manifest.read file",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@",
+      "@@@STEP_LOG_LINE@default.xml@<?xml version=\"1.0\" encoding=\"UTF-8\"?>@@@",
+      "@@@STEP_LOG_LINE@default.xml@<manifest>@@@",
+      "@@@STEP_LOG_LINE@default.xml@  <remote@@@",
+      "@@@STEP_LOG_LINE@default.xml@    name=\"default_remote\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    fetch=\"sso://default\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    />@@@",
+      "@@@STEP_LOG_LINE@default.xml@@@@",
+      "@@@STEP_LOG_LINE@default.xml@  <remote@@@",
+      "@@@STEP_LOG_LINE@default.xml@    name=\"pigweed_remote\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    revision=\"main\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    fetch=\"..\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    review=\"https://pigweed.googlesource.com\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    />@@@",
+      "@@@STEP_LOG_LINE@default.xml@@@@",
+      "@@@STEP_LOG_LINE@default.xml@  <remote@@@",
+      "@@@STEP_LOG_LINE@default.xml@    name=\"pigweed-internal_remote\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    revision=\"main\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    fetch=\"https://pigweed-internal.googlesource.com\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    review=\"https://pigweed-internal.googlesource.com\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    />@@@",
+      "@@@STEP_LOG_LINE@default.xml@@@@",
+      "@@@STEP_LOG_LINE@default.xml@  <remote@@@",
+      "@@@STEP_LOG_LINE@default.xml@    name=\"prefixed\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    fetch=\"https://foo.googlesource.com/prefix\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    review=\"https://foo.googlesource.com/prefix\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    />@@@",
+      "@@@STEP_LOG_LINE@default.xml@@@@",
+      "@@@STEP_LOG_LINE@default.xml@  <default@@@",
+      "@@@STEP_LOG_LINE@default.xml@    remote=\"default_remote\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    revision=\"main\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    />@@@",
+      "@@@STEP_LOG_LINE@default.xml@@@@",
+      "@@@STEP_LOG_LINE@default.xml@  <project@@@",
+      "@@@STEP_LOG_LINE@default.xml@    name=\"default_name\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    path=\"default_path\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    />@@@",
+      "@@@STEP_LOG_LINE@default.xml@@@@",
+      "@@@STEP_LOG_LINE@default.xml@  <project@@@",
+      "@@@STEP_LOG_LINE@default.xml@    name=\"pigweed_name\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    path=\"pigweed_path\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    remote=\"pigweed_remote\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    revision=\"main\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    />@@@",
+      "@@@STEP_LOG_LINE@default.xml@@@@",
+      "@@@STEP_LOG_LINE@default.xml@  <project@@@",
+      "@@@STEP_LOG_LINE@default.xml@    name=\"pigweed-internal_name\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    path=\"pigweed-internal_path\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    remote=\"pigweed-internal_remote\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    />@@@",
+      "@@@STEP_LOG_LINE@default.xml@@@@",
+      "@@@STEP_LOG_LINE@default.xml@  <project@@@",
+      "@@@STEP_LOG_LINE@default.xml@    name=\"pinned\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    path=\"pinned\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    remote=\"pigweed_remote\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    revision=\"0123456789012345678901234567890123456789\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    upstream=\"main\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    />@@@",
+      "@@@STEP_LOG_LINE@default.xml@@@@",
+      "@@@STEP_LOG_LINE@default.xml@  <project@@@",
+      "@@@STEP_LOG_LINE@default.xml@    name=\"suffix\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    path=\"prefix/suffix\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    remote=\"prefixed\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    />@@@",
+      "@@@STEP_LOG_LINE@default.xml@</manifest>@@@",
+      "@@@STEP_LOG_END@default.xml@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "checkout pigweed.read manifest.log",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@",
+      "@@@STEP_SUMMARY_TEXT@{'name': 'default_remote', 'fetch': 'sso://default'}@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "checkout pigweed.read manifest.log (2)",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@",
+      "@@@STEP_SUMMARY_TEXT@{'name': 'pigweed_remote', 'revision': 'main', 'fetch': '..', 'review': 'https://pigweed.googlesource.com'}@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "checkout pigweed.read manifest.log (3)",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@",
+      "@@@STEP_SUMMARY_TEXT@{'name': 'pigweed-internal_remote', 'revision': 'main', 'fetch': 'https://pigweed-internal.googlesource.com', 'review': 'https://pigweed-internal.googlesource.com'}@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "checkout pigweed.read manifest.log (4)",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@",
+      "@@@STEP_SUMMARY_TEXT@{'name': 'prefixed', 'fetch': 'https://foo.googlesource.com/prefix', 'review': 'https://foo.googlesource.com/prefix'}@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "copy",
+      "{\"projects\": [{\"name\": \"default_name\", \"path\": \"default_path\", \"remote\": \"default_remote\", \"revision\": \"main\", \"upstream\": \"main\", \"url\": \"https://default.googlesource.com/default_name\"}, {\"name\": \"pigweed_name\", \"path\": \"pigweed_path\", \"remote\": \"pigweed_remote\", \"revision\": \"main\", \"upstream\": \"main\", \"url\": \"https://pigweed.googlesource.com/pigweed_name\"}, {\"name\": \"pigweed-internal_name\", \"path\": \"pigweed-internal_path\", \"remote\": \"pigweed-internal_remote\", \"revision\": \"main\", \"upstream\": \"main\", \"url\": \"https://pigweed-internal.googlesource.com/pigweed-internal_name\"}, {\"name\": \"pinned\", \"path\": \"pinned\", \"remote\": \"pigweed_remote\", \"revision\": \"0123456789012345678901234567890123456789\", \"upstream\": \"main\", \"url\": \"https://pigweed.googlesource.com/pinned\"}, {\"name\": \"suffix\", \"path\": \"prefix/suffix\", \"remote\": \"prefixed\", \"revision\": \"main\", \"upstream\": \"main\", \"url\": \"https://foo.googlesource.com/prefix/suffix\"}], \"remotes\": {\"default_remote\": {\"alias\": null, \"fetch\": {\"https\": \"https://default.googlesource.com\", \"url\": \"sso://default\"}, \"name\": \"default_remote\", \"review\": null, \"revision\": null}, \"pigweed-internal_remote\": {\"alias\": null, \"fetch\": {\"https\": \"https://pigweed-internal.googlesource.com\", \"url\": \"https://pigweed-internal.googlesource.com\"}, \"name\": \"pigweed-internal_remote\", \"review\": \"https://pigweed-internal.googlesource.com\", \"revision\": \"main\"}, \"pigweed_remote\": {\"alias\": null, \"fetch\": {\"https\": \"https://pigweed.googlesource.com\", \"url\": \"https://pigweed.googlesource.com\"}, \"name\": \"pigweed_remote\", \"review\": \"https://pigweed.googlesource.com\", \"revision\": \"main\"}, \"prefixed\": {\"alias\": null, \"fetch\": {\"https\": \"https://foo.googlesource.com/prefix\", \"url\": \"https://foo.googlesource.com/prefix\"}, \"name\": \"prefixed\", \"review\": \"https://foo.googlesource.com/prefix\", \"revision\": null}}}",
+      "[START_DIR]/manifest.json"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.read manifest.manifest json",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@",
+      "@@@STEP_LOG_LINE@manifest.json@{\"projects\": [{\"name\": \"default_name\", \"path\": \"default_path\", \"remote\": \"default_remote\", \"revision\": \"main\", \"upstream\": \"main\", \"url\": \"https://default.googlesource.com/default_name\"}, {\"name\": \"pigweed_name\", \"path\": \"pigweed_path\", \"remote\": \"pigweed_remote\", \"revision\": \"main\", \"upstream\": \"main\", \"url\": \"https://pigweed.googlesource.com/pigweed_name\"}, {\"name\": \"pigweed-internal_name\", \"path\": \"pigweed-internal_path\", \"remote\": \"pigweed-internal_remote\", \"revision\": \"main\", \"upstream\": \"main\", \"url\": \"https://pigweed-internal.googlesource.com/pigweed-internal_name\"}, {\"name\": \"pinned\", \"path\": \"pinned\", \"remote\": \"pigweed_remote\", \"revision\": \"0123456789012345678901234567890123456789\", \"upstream\": \"main\", \"url\": \"https://pigweed.googlesource.com/pinned\"}, {\"name\": \"suffix\", \"path\": \"prefix/suffix\", \"remote\": \"prefixed\", \"revision\": \"main\", \"upstream\": \"main\", \"url\": \"https://foo.googlesource.com/prefix/suffix\"}], \"remotes\": {\"default_remote\": {\"alias\": null, \"fetch\": {\"https\": \"https://default.googlesource.com\", \"url\": \"sso://default\"}, \"name\": \"default_remote\", \"review\": null, \"revision\": null}, \"pigweed-internal_remote\": {\"alias\": null, \"fetch\": {\"https\": \"https://pigweed-internal.googlesource.com\", \"url\": \"https://pigweed-internal.googlesource.com\"}, \"name\": \"pigweed-internal_remote\", \"review\": \"https://pigweed-internal.googlesource.com\", \"revision\": \"main\"}, \"pigweed_remote\": {\"alias\": null, \"fetch\": {\"https\": \"https://pigweed.googlesource.com\", \"url\": \"https://pigweed.googlesource.com\"}, \"name\": \"pigweed_remote\", \"review\": \"https://pigweed.googlesource.com\", \"revision\": \"main\"}, \"prefixed\": {\"alias\": null, \"fetch\": {\"https\": \"https://foo.googlesource.com/prefix\", \"url\": \"https://foo.googlesource.com/prefix\"}, \"name\": \"prefixed\", \"review\": \"https://foo.googlesource.com/prefix\", \"revision\": null}}}@@@",
+      "@@@STEP_LOG_END@manifest.json@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "config",
+      "--global",
+      "--add",
+      "url.https://default.googlesource.com/a.insteadof",
+      "sso://default"
+    ],
+    "cwd": "[START_DIR]/co",
+    "env": {
+      "GIT_ADVICE": "0",
+      "GIT_CONFIG_COUNT": "4",
+      "GIT_CONFIG_KEY_0": "fetch.unpackLimit",
+      "GIT_CONFIG_KEY_1": "gc.auto",
+      "GIT_CONFIG_KEY_2": "gc.autoDetach",
+      "GIT_CONFIG_KEY_3": "gc.autoPackLimit",
+      "GIT_CONFIG_VALUE_0": "1",
+      "GIT_CONFIG_VALUE_1": "0",
+      "GIT_CONFIG_VALUE_2": "0",
+      "GIT_CONFIG_VALUE_3": "0"
+    },
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.git insteadof sso://default",
+    "timeout": 1200.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "RECIPE_MODULE[pigweed::repo]/resources/repo",
+      "sync",
+      "--force-sync",
+      "--current-branch",
+      "--jobs",
+      "12",
+      "--verbose"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.repo sync",
+    "timeout": 900,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "RECIPE_MODULE[pigweed::repo]/resources/repo",
+      "start",
+      "base",
+      "--all"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.repo start",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "checkout pigweed.apply pigweed:1234",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@",
+      "@@@STEP_SUMMARY_TEXT@pigweed_path@@@",
+      "@@@STEP_LINK@gerrit@https://pigweed-review.googlesource.com/c/1234@@@",
+      "@@@STEP_LINK@gitiles@https://pigweed.googlesource.com/pigweed_name/+/2d72510e447ab60a9728aeea2362d8be2cbd7789@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "checkout pigweed.apply pigweed:1234.timeout 10s",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "fetch",
+      "--jobs",
+      "4",
+      "https://pigweed.googlesource.com/pigweed_name",
+      "2d72510e447ab60a9728aeea2362d8be2cbd7789",
+      "--no-recurse-submodules"
+    ],
+    "cwd": "[START_DIR]/co/pigweed_path",
+    "env": {
+      "GIT_ADVICE": "0",
+      "GIT_CONFIG_COUNT": "4",
+      "GIT_CONFIG_KEY_0": "fetch.unpackLimit",
+      "GIT_CONFIG_KEY_1": "gc.auto",
+      "GIT_CONFIG_KEY_2": "gc.autoDetach",
+      "GIT_CONFIG_KEY_3": "gc.autoPackLimit",
+      "GIT_CONFIG_VALUE_0": "1",
+      "GIT_CONFIG_VALUE_1": "0",
+      "GIT_CONFIG_VALUE_2": "0",
+      "GIT_CONFIG_VALUE_3": "0"
+    },
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:1234.git fetch patch",
+    "timeout": 1200.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "checkout",
+      "--force",
+      "-b",
+      "working",
+      "FETCH_HEAD"
+    ],
+    "cwd": "[START_DIR]/co/pigweed_path",
+    "env": {
+      "GIT_ADVICE": "0",
+      "GIT_CONFIG_COUNT": "4",
+      "GIT_CONFIG_KEY_0": "fetch.unpackLimit",
+      "GIT_CONFIG_KEY_1": "gc.auto",
+      "GIT_CONFIG_KEY_2": "gc.autoDetach",
+      "GIT_CONFIG_KEY_3": "gc.autoPackLimit",
+      "GIT_CONFIG_VALUE_0": "1",
+      "GIT_CONFIG_VALUE_1": "0",
+      "GIT_CONFIG_VALUE_2": "0",
+      "GIT_CONFIG_VALUE_3": "0"
+    },
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:1234.git checkout patch",
+    "timeout": 1200.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "remote",
+      "add",
+      "https___pigweed_googlesource_com_pigweed_name",
+      "https://pigweed.googlesource.com/pigweed_name"
+    ],
+    "cwd": "[START_DIR]/co/pigweed_path",
+    "env": {
+      "GIT_ADVICE": "0",
+      "GIT_CONFIG_COUNT": "4",
+      "GIT_CONFIG_KEY_0": "fetch.unpackLimit",
+      "GIT_CONFIG_KEY_1": "gc.auto",
+      "GIT_CONFIG_KEY_2": "gc.autoDetach",
+      "GIT_CONFIG_KEY_3": "gc.autoPackLimit",
+      "GIT_CONFIG_VALUE_0": "1",
+      "GIT_CONFIG_VALUE_1": "0",
+      "GIT_CONFIG_VALUE_2": "0",
+      "GIT_CONFIG_VALUE_3": "0"
+    },
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:1234.git remote add",
+    "timeout": 1200.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "checkout pigweed.apply pigweed:1234.timeout 10s (2)",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "fetch",
+      "--jobs",
+      "4",
+      "https___pigweed_googlesource_com_pigweed_name",
+      "refs/heads/main"
+    ],
+    "cwd": "[START_DIR]/co/pigweed_path",
+    "env": {
+      "GIT_ADVICE": "0",
+      "GIT_CONFIG_COUNT": "4",
+      "GIT_CONFIG_KEY_0": "fetch.unpackLimit",
+      "GIT_CONFIG_KEY_1": "gc.auto",
+      "GIT_CONFIG_KEY_2": "gc.autoDetach",
+      "GIT_CONFIG_KEY_3": "gc.autoPackLimit",
+      "GIT_CONFIG_VALUE_0": "1",
+      "GIT_CONFIG_VALUE_1": "0",
+      "GIT_CONFIG_VALUE_2": "0",
+      "GIT_CONFIG_VALUE_3": "0"
+    },
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:1234.fetch main branch",
+    "timeout": 1200.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "branch",
+      "--set-upstream-to=https___pigweed_googlesource_com_pigweed_name/main"
+    ],
+    "cwd": "[START_DIR]/co/pigweed_path",
+    "env": {
+      "GIT_ADVICE": "0",
+      "GIT_CONFIG_COUNT": "4",
+      "GIT_CONFIG_KEY_0": "fetch.unpackLimit",
+      "GIT_CONFIG_KEY_1": "gc.auto",
+      "GIT_CONFIG_KEY_2": "gc.autoDetach",
+      "GIT_CONFIG_KEY_3": "gc.autoPackLimit",
+      "GIT_CONFIG_VALUE_0": "1",
+      "GIT_CONFIG_VALUE_1": "0",
+      "GIT_CONFIG_VALUE_2": "0",
+      "GIT_CONFIG_VALUE_3": "0"
+    },
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:1234.git set upstream",
+    "timeout": 1200.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "rev-parse",
+      "HEAD"
+    ],
+    "cwd": "[START_DIR]/co/pigweed_path",
+    "env": {
+      "GIT_ADVICE": "0",
+      "GIT_CONFIG_COUNT": "4",
+      "GIT_CONFIG_KEY_0": "fetch.unpackLimit",
+      "GIT_CONFIG_KEY_1": "gc.auto",
+      "GIT_CONFIG_KEY_2": "gc.autoDetach",
+      "GIT_CONFIG_KEY_3": "gc.autoPackLimit",
+      "GIT_CONFIG_VALUE_0": "1",
+      "GIT_CONFIG_VALUE_1": "0",
+      "GIT_CONFIG_VALUE_2": "0",
+      "GIT_CONFIG_VALUE_3": "0"
+    },
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:1234.git rev-parse",
+    "timeout": 300.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "log",
+      "--oneline",
+      "-n",
+      "10"
+    ],
+    "cwd": "[START_DIR]/co/pigweed_path",
+    "env": {
+      "GIT_ADVICE": "0",
+      "GIT_CONFIG_COUNT": "4",
+      "GIT_CONFIG_KEY_0": "fetch.unpackLimit",
+      "GIT_CONFIG_KEY_1": "gc.auto",
+      "GIT_CONFIG_KEY_2": "gc.autoDetach",
+      "GIT_CONFIG_KEY_3": "gc.autoPackLimit",
+      "GIT_CONFIG_VALUE_0": "1",
+      "GIT_CONFIG_VALUE_1": "0",
+      "GIT_CONFIG_VALUE_2": "0",
+      "GIT_CONFIG_VALUE_3": "0"
+    },
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:1234.post-rebase log",
+    "timeout": 1200.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "checkout pigweed.apply pigweed:1234.timeout 10s (3)",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "checkout",
+      "--detach"
+    ],
+    "cwd": "[START_DIR]/co/pigweed_path",
+    "env": {
+      "GIT_ADVICE": "0",
+      "GIT_CONFIG_COUNT": "4",
+      "GIT_CONFIG_KEY_0": "fetch.unpackLimit",
+      "GIT_CONFIG_KEY_1": "gc.auto",
+      "GIT_CONFIG_KEY_2": "gc.autoDetach",
+      "GIT_CONFIG_KEY_3": "gc.autoPackLimit",
+      "GIT_CONFIG_VALUE_0": "1",
+      "GIT_CONFIG_VALUE_1": "0",
+      "GIT_CONFIG_VALUE_2": "0",
+      "GIT_CONFIG_VALUE_3": "0"
+    },
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:1234.detach",
+    "timeout": 1200.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "submodule",
+      "sync",
+      "--recursive"
+    ],
+    "cwd": "[START_DIR]/co/pigweed_path",
+    "env": {
+      "GIT_ADVICE": "0",
+      "GIT_CONFIG_COUNT": "4",
+      "GIT_CONFIG_KEY_0": "fetch.unpackLimit",
+      "GIT_CONFIG_KEY_1": "gc.auto",
+      "GIT_CONFIG_KEY_2": "gc.autoDetach",
+      "GIT_CONFIG_KEY_3": "gc.autoPackLimit",
+      "GIT_CONFIG_VALUE_0": "1",
+      "GIT_CONFIG_VALUE_1": "0",
+      "GIT_CONFIG_VALUE_2": "0",
+      "GIT_CONFIG_VALUE_3": "0"
+    },
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:1234.git submodule sync",
+    "timeout": 1200.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "submodule",
+      "update",
+      "--init",
+      "--recursive",
+      "--jobs",
+      "4"
+    ],
+    "cwd": "[START_DIR]/co/pigweed_path",
+    "env": {
+      "GIT_ADVICE": "0",
+      "GIT_CONFIG_COUNT": "4",
+      "GIT_CONFIG_KEY_0": "fetch.unpackLimit",
+      "GIT_CONFIG_KEY_1": "gc.auto",
+      "GIT_CONFIG_KEY_2": "gc.autoDetach",
+      "GIT_CONFIG_KEY_3": "gc.autoPackLimit",
+      "GIT_CONFIG_VALUE_0": "1",
+      "GIT_CONFIG_VALUE_1": "0",
+      "GIT_CONFIG_VALUE_2": "0",
+      "GIT_CONFIG_VALUE_3": "0"
+    },
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:1234.git submodule update",
+    "timeout": 600,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "checkout",
+      "-"
+    ],
+    "cwd": "[START_DIR]/co/pigweed_path",
+    "env": {
+      "GIT_ADVICE": "0",
+      "GIT_CONFIG_COUNT": "4",
+      "GIT_CONFIG_KEY_0": "fetch.unpackLimit",
+      "GIT_CONFIG_KEY_1": "gc.auto",
+      "GIT_CONFIG_KEY_2": "gc.autoDetach",
+      "GIT_CONFIG_KEY_3": "gc.autoPackLimit",
+      "GIT_CONFIG_VALUE_0": "1",
+      "GIT_CONFIG_VALUE_1": "0",
+      "GIT_CONFIG_VALUE_2": "0",
+      "GIT_CONFIG_VALUE_3": "0"
+    },
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:1234.reattach",
+    "timeout": 1200.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "checkout pigweed.apply pigweed:1234.compare branch name",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@",
+      "@@@STEP_SUMMARY_TEXT@CL branch: main\nupstream branch: main@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "checkout pigweed.status",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@",
+      "@@@STEP_SUMMARY_TEXT@applied [Change(number=1234, remote='https://pigweed.googlesource.com/pigweed_name', ref='2d72510e447ab60a9728aeea2362d8be2cbd7789', rebase=False, project='pigweed_name', branch='main', gerrit_name='pigweed', submitted=True, patchset=None, path='pigweed_path', base='HEAD_HEAD_HEAD_HEAD_HEAD_HEAD_HEAD_HEAD_', base_type='submitted_commit_hash', is_merge=False, commit_message='', topic=None, current_revision='2d72510e447ab60a9728aeea2362d8be2cbd7789', primary=True, submit_requirements={}, uploader=None)]\nnot applied []@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "ensure-directory",
+      "--mode",
+      "0o777",
+      "[START_DIR]/snapshot"
+    ],
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.mkdir",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "RECIPE_MODULE[pigweed::repo]/resources/repo",
+      "manifest",
+      "-r"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.repo manifest",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@",
+      "@@@STEP_LOG_LINE@raw_io.output_text@<manifest></manifest>@@@",
+      "@@@STEP_LOG_END@raw_io.output_text@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "copy",
+      "<manifest></manifest>",
+      "[START_DIR]/snapshot/manifest.xml"
+    ],
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.write manifest.xml",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@",
+      "@@@STEP_LOG_LINE@manifest.xml@<manifest></manifest>@@@",
+      "@@@STEP_LOG_END@manifest.xml@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "log",
+      "--oneline",
+      "-n",
+      "10"
+    ],
+    "cwd": "[START_DIR]/co",
+    "env": {
+      "GIT_ADVICE": "0",
+      "GIT_CONFIG_COUNT": "4",
+      "GIT_CONFIG_KEY_0": "fetch.unpackLimit",
+      "GIT_CONFIG_KEY_1": "gc.auto",
+      "GIT_CONFIG_KEY_2": "gc.autoDetach",
+      "GIT_CONFIG_KEY_3": "gc.autoPackLimit",
+      "GIT_CONFIG_VALUE_0": "1",
+      "GIT_CONFIG_VALUE_1": "0",
+      "GIT_CONFIG_VALUE_2": "0",
+      "GIT_CONFIG_VALUE_3": "0"
+    },
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.log",
+    "timeout": 1200.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "copy",
+      "",
+      "[START_DIR]/snapshot/git.log"
+    ],
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.write git log",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@",
+      "@@@STEP_LOG_END@git.log@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "changes"
+  },
+  {
+    "cmd": [],
+    "name": "changes.0",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@",
+      "@@@STEP_SUMMARY_TEXT@Change(number=1234, remote='https://pigweed.googlesource.com/pigweed_name', ref='2d72510e447ab60a9728aeea2362d8be2cbd7789', rebase=False, project='pigweed_name', branch='main', gerrit_name='pigweed', submitted=True, patchset=None, path='pigweed_path', base='HEAD_HEAD_HEAD_HEAD_HEAD_HEAD_HEAD_HEAD_', base_type='submitted_commit_hash', is_merge=False, commit_message='', topic=None, current_revision='2d72510e447ab60a9728aeea2362d8be2cbd7789', primary=True, submit_requirements={}, uploader=None)@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "snapshot_to_dir"
+  },
+  {
+    "cmd": [
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "ensure-directory",
+      "--mode",
+      "0o777",
+      "[START_DIR]/snapshot"
+    ],
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "snapshot_to_dir.mkdir",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "copy",
+      "<manifest></manifest>",
+      "[START_DIR]/snapshot/manifest.xml"
+    ],
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "snapshot_to_dir.write manifest.xml",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@",
+      "@@@STEP_LOG_LINE@manifest.xml@<manifest></manifest>@@@",
+      "@@@STEP_LOG_END@manifest.xml@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "log",
+      "--oneline",
+      "-n",
+      "10"
+    ],
+    "cwd": "[START_DIR]/co",
+    "env": {
+      "GIT_ADVICE": "0",
+      "GIT_CONFIG_COUNT": "4",
+      "GIT_CONFIG_KEY_0": "fetch.unpackLimit",
+      "GIT_CONFIG_KEY_1": "gc.auto",
+      "GIT_CONFIG_KEY_2": "gc.autoDetach",
+      "GIT_CONFIG_KEY_3": "gc.autoPackLimit",
+      "GIT_CONFIG_VALUE_0": "1",
+      "GIT_CONFIG_VALUE_1": "0",
+      "GIT_CONFIG_VALUE_2": "0",
+      "GIT_CONFIG_VALUE_3": "0"
+    },
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "snapshot_to_dir.log",
+    "timeout": 1200.0,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "copy",
+      "",
+      "[START_DIR]/snapshot/git.log"
+    ],
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "snapshot_to_dir.write git log",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@",
+      "@@@STEP_LOG_END@git.log@@@"
+    ]
+  },
+  {
+    "name": "$result"
+  }
+]
\ No newline at end of file
diff --git a/recipe_modules/checkout/tests/repo.expected/no_trigger.json b/recipe_modules/checkout/tests/repo.expected/no_trigger.json
index 07e21b2..8a4dd45 100644
--- a/recipe_modules/checkout/tests/repo.expected/no_trigger.json
+++ b/recipe_modules/checkout/tests/repo.expected/no_trigger.json
@@ -879,12 +879,51 @@
   },
   {
     "cmd": [
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "ensure-directory",
+      "--mode",
+      "0o777",
+      "[CACHE]/repo"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "name": "checkout pigweed.ensure repo cache dir",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "copy",
+      "",
+      "[CACHE]/repo/.GUARD_FILE"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "name": "checkout pigweed.write repo cache guard file",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
       "RECIPE_MODULE[pigweed::repo]/resources/repo",
       "sync",
       "--force-sync",
       "--current-branch",
       "--jobs",
       "12",
+      "--cache-dir",
+      "[CACHE]/repo",
       "--verbose"
     ],
     "cwd": "[START_DIR]/co",
@@ -897,6 +936,23 @@
   },
   {
     "cmd": [
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "remove",
+      "[CACHE]/repo/.GUARD_FILE"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "name": "checkout pigweed.remove repo cache guard file",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
       "RECIPE_MODULE[pigweed::repo]/resources/repo",
       "start",
       "base",
diff --git a/recipe_modules/checkout/tests/repo.expected/prefix.json b/recipe_modules/checkout/tests/repo.expected/prefix.json
index e3cc199..cfc88e1 100644
--- a/recipe_modules/checkout/tests/repo.expected/prefix.json
+++ b/recipe_modules/checkout/tests/repo.expected/prefix.json
@@ -754,12 +754,75 @@
   },
   {
     "cmd": [
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "ensure-directory",
+      "--mode",
+      "0o777",
+      "[CACHE]/repo"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.ensure repo cache dir",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "copy",
+      "",
+      "[CACHE]/repo/.GUARD_FILE"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.write repo cache guard file",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
       "RECIPE_MODULE[pigweed::repo]/resources/repo",
       "sync",
       "--force-sync",
       "--current-branch",
       "--jobs",
       "12",
+      "--cache-dir",
+      "[CACHE]/repo",
       "--verbose"
     ],
     "cwd": "[START_DIR]/co",
@@ -784,6 +847,35 @@
   },
   {
     "cmd": [
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "remove",
+      "[CACHE]/repo/.GUARD_FILE"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.remove repo cache guard file",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
       "RECIPE_MODULE[pigweed::repo]/resources/repo",
       "start",
       "base",
diff --git a/recipe_modules/checkout/tests/repo.expected/try-multiple-cqdeps.json b/recipe_modules/checkout/tests/repo.expected/try-multiple-cqdeps.json
index ed01080..b30e58c 100644
--- a/recipe_modules/checkout/tests/repo.expected/try-multiple-cqdeps.json
+++ b/recipe_modules/checkout/tests/repo.expected/try-multiple-cqdeps.json
@@ -1067,12 +1067,75 @@
   },
   {
     "cmd": [
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "ensure-directory",
+      "--mode",
+      "0o777",
+      "[CACHE]/repo"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.ensure repo cache dir",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "copy",
+      "",
+      "[CACHE]/repo/.GUARD_FILE"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.write repo cache guard file",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
       "RECIPE_MODULE[pigweed::repo]/resources/repo",
       "sync",
       "--force-sync",
       "--current-branch",
       "--jobs",
       "12",
+      "--cache-dir",
+      "[CACHE]/repo",
       "--verbose"
     ],
     "cwd": "[START_DIR]/co",
@@ -1097,6 +1160,35 @@
   },
   {
     "cmd": [
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "remove",
+      "[CACHE]/repo/.GUARD_FILE"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.remove repo cache guard file",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
       "RECIPE_MODULE[pigweed::repo]/resources/repo",
       "start",
       "base",
diff --git a/recipe_modules/checkout/tests/repo.expected/try-multiple-onenotapplied.json b/recipe_modules/checkout/tests/repo.expected/try-multiple-onenotapplied.json
index 8bb5abb..e22ea5b 100644
--- a/recipe_modules/checkout/tests/repo.expected/try-multiple-onenotapplied.json
+++ b/recipe_modules/checkout/tests/repo.expected/try-multiple-onenotapplied.json
@@ -923,12 +923,75 @@
   },
   {
     "cmd": [
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "ensure-directory",
+      "--mode",
+      "0o777",
+      "[CACHE]/repo"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.ensure repo cache dir",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "copy",
+      "",
+      "[CACHE]/repo/.GUARD_FILE"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.write repo cache guard file",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
       "RECIPE_MODULE[pigweed::repo]/resources/repo",
       "sync",
       "--force-sync",
       "--current-branch",
       "--jobs",
       "12",
+      "--cache-dir",
+      "[CACHE]/repo",
       "--verbose"
     ],
     "cwd": "[START_DIR]/co",
@@ -953,6 +1016,35 @@
   },
   {
     "cmd": [
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "remove",
+      "[CACHE]/repo/.GUARD_FILE"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.remove repo cache guard file",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
       "RECIPE_MODULE[pigweed::repo]/resources/repo",
       "start",
       "base",
diff --git a/recipe_modules/checkout/tests/repo.expected/try-multiple.json b/recipe_modules/checkout/tests/repo.expected/try-multiple.json
index ffbf57d..5809c5a 100644
--- a/recipe_modules/checkout/tests/repo.expected/try-multiple.json
+++ b/recipe_modules/checkout/tests/repo.expected/try-multiple.json
@@ -840,12 +840,75 @@
   },
   {
     "cmd": [
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "ensure-directory",
+      "--mode",
+      "0o777",
+      "[CACHE]/repo"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.ensure repo cache dir",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "copy",
+      "",
+      "[CACHE]/repo/.GUARD_FILE"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.write repo cache guard file",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
       "RECIPE_MODULE[pigweed::repo]/resources/repo",
       "sync",
       "--force-sync",
       "--current-branch",
       "--jobs",
       "12",
+      "--cache-dir",
+      "[CACHE]/repo",
       "--verbose"
     ],
     "cwd": "[START_DIR]/co",
@@ -870,6 +933,35 @@
   },
   {
     "cmd": [
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "remove",
+      "[CACHE]/repo/.GUARD_FILE"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.remove repo cache guard file",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
       "RECIPE_MODULE[pigweed::repo]/resources/repo",
       "start",
       "base",
diff --git a/recipe_modules/checkout/tests/repo.expected/try.json b/recipe_modules/checkout/tests/repo.expected/try.json
index cb4c61a..632c97b 100644
--- a/recipe_modules/checkout/tests/repo.expected/try.json
+++ b/recipe_modules/checkout/tests/repo.expected/try.json
@@ -756,12 +756,75 @@
   },
   {
     "cmd": [
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "ensure-directory",
+      "--mode",
+      "0o777",
+      "[CACHE]/repo"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.ensure repo cache dir",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "copy",
+      "",
+      "[CACHE]/repo/.GUARD_FILE"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.write repo cache guard file",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
       "RECIPE_MODULE[pigweed::repo]/resources/repo",
       "sync",
       "--force-sync",
       "--current-branch",
       "--jobs",
       "12",
+      "--cache-dir",
+      "[CACHE]/repo",
       "--verbose"
     ],
     "cwd": "[START_DIR]/co",
@@ -786,6 +849,35 @@
   },
   {
     "cmd": [
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "remove",
+      "[CACHE]/repo/.GUARD_FILE"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.remove repo cache guard file",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
       "RECIPE_MODULE[pigweed::repo]/resources/repo",
       "start",
       "base",
diff --git a/recipe_modules/checkout/tests/repo.expected/try_manifest.json b/recipe_modules/checkout/tests/repo.expected/try_manifest.json
index e3c44bf..3553021 100644
--- a/recipe_modules/checkout/tests/repo.expected/try_manifest.json
+++ b/recipe_modules/checkout/tests/repo.expected/try_manifest.json
@@ -1391,12 +1391,75 @@
   },
   {
     "cmd": [
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "ensure-directory",
+      "--mode",
+      "0o777",
+      "[CACHE]/repo"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.ensure repo cache dir",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "copy",
+      "",
+      "[CACHE]/repo/.GUARD_FILE"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.write repo cache guard file",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
       "RECIPE_MODULE[pigweed::repo]/resources/repo",
       "sync",
       "--force-sync",
       "--current-branch",
       "--jobs",
       "12",
+      "--cache-dir",
+      "[CACHE]/repo",
       "--verbose"
     ],
     "cwd": "[START_DIR]/co",
@@ -1421,6 +1484,35 @@
   },
   {
     "cmd": [
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "remove",
+      "[CACHE]/repo/.GUARD_FILE"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.remove repo cache guard file",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
       "RECIPE_MODULE[pigweed::repo]/resources/repo",
       "start",
       "base",
diff --git a/recipe_modules/checkout/tests/repo.expected/try_repo_not_in_manifest.json b/recipe_modules/checkout/tests/repo.expected/try_repo_not_in_manifest.json
index 7e58b67..0261eb3 100644
--- a/recipe_modules/checkout/tests/repo.expected/try_repo_not_in_manifest.json
+++ b/recipe_modules/checkout/tests/repo.expected/try_repo_not_in_manifest.json
@@ -754,12 +754,75 @@
   },
   {
     "cmd": [
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "ensure-directory",
+      "--mode",
+      "0o777",
+      "[CACHE]/repo"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.ensure repo cache dir",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "copy",
+      "",
+      "[CACHE]/repo/.GUARD_FILE"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.write repo cache guard file",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
       "RECIPE_MODULE[pigweed::repo]/resources/repo",
       "sync",
       "--force-sync",
       "--current-branch",
       "--jobs",
       "12",
+      "--cache-dir",
+      "[CACHE]/repo",
       "--verbose"
     ],
     "cwd": "[START_DIR]/co",
@@ -784,6 +847,35 @@
   },
   {
     "cmd": [
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "remove",
+      "[CACHE]/repo/.GUARD_FILE"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.remove repo cache guard file",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
       "RECIPE_MODULE[pigweed::repo]/resources/repo",
       "start",
       "base",
diff --git a/recipe_modules/checkout/tests/repo.py b/recipe_modules/checkout/tests/repo.py
index 821ca1a..89ece73 100644
--- a/recipe_modules/checkout/tests/repo.py
+++ b/recipe_modules/checkout/tests/repo.py
@@ -288,3 +288,38 @@
         api.checkout.manifest_test_data(),
         api.checkout.all_changes_applied(),
     )
+
+    yield api.test(
+        'no_cache',
+        properties(do_not_cache=True),
+        api.checkout.ci_test_data(git_repo=PIGWEED_REPO),
+        api.checkout.manifest_test_data(),
+        api.checkout.all_changes_applied(),
+        api.post_check(
+            post_process.MustRun,
+            'checkout pigweed.repo sync',
+        ),
+        api.post_check(
+            post_process.DoesNotRunRE,
+            '.*cache.*',
+        ),
+    )
+
+    yield api.test(
+        'disable_repo_cache_experiment',
+        properties(),
+        api.checkout.ci_test_data(
+            git_repo=PIGWEED_REPO,
+            experiments=['pigweed.disable_repo_cache'],
+        ),
+        api.checkout.manifest_test_data(),
+        api.checkout.all_changes_applied(),
+        api.post_check(
+            post_process.MustRun,
+            'checkout pigweed.repo sync',
+        ),
+        api.post_check(
+            post_process.DoesNotRunRE,
+            '.*cache.*',
+        ),
+    )
diff --git a/recipes/target_to_cipd.expected/success.json b/recipes/target_to_cipd.expected/success.json
index de4bea5..c1d6991 100644
--- a/recipes/target_to_cipd.expected/success.json
+++ b/recipes/target_to_cipd.expected/success.json
@@ -1134,12 +1134,75 @@
   },
   {
     "cmd": [
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "ensure-directory",
+      "--mode",
+      "0o777",
+      "[CACHE]/repo"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.ensure repo cache dir",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "copy",
+      "",
+      "[CACHE]/repo/.GUARD_FILE"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.write repo cache guard file",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
       "RECIPE_MODULE[pigweed::repo]/resources/repo",
       "sync",
       "--force-sync",
       "--current-branch",
       "--jobs",
       "12",
+      "--cache-dir",
+      "[CACHE]/repo",
       "--verbose"
     ],
     "cwd": "[START_DIR]/co",
@@ -1164,6 +1227,35 @@
   },
   {
     "cmd": [
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "remove",
+      "[CACHE]/repo/.GUARD_FILE"
+    ],
+    "cwd": "[START_DIR]/co",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.remove repo cache guard file",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
       "RECIPE_MODULE[pigweed::repo]/resources/repo",
       "start",
       "base",