repo: Upgrade and pin

Change-Id: I72abefdff6a92b71a5b74162577c6608c40ca0fc
Bug: b/255646095
Reviewed-on: https://pigweed-review.googlesource.com/c/infra/recipes/+/117791
Pigweed-Auto-Submit: Rob Mohr <mohrr@google.com>
Reviewed-by: Ted Pudlik <tpudlik@google.com>
Commit-Queue: Rob Mohr <mohrr@google.com>
diff --git a/recipe_modules/checkout/tests/repo.expected/ci.json b/recipe_modules/checkout/tests/repo.expected/ci.json
index 0dbb090..441b162 100644
--- a/recipe_modules/checkout/tests/repo.expected/ci.json
+++ b/recipe_modules/checkout/tests/repo.expected/ci.json
@@ -194,6 +194,11 @@
       "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"
     ],
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 6f7b138..1172be0 100644
--- a/recipe_modules/checkout/tests/repo.expected/feature_branches_ci.json
+++ b/recipe_modules/checkout/tests/repo.expected/feature_branches_ci.json
@@ -298,6 +298,11 @@
       "all",
       "--manifest-branch",
       "feature1",
+      "--repo-url",
+      "https://pigweed.googlesource.com/third_party/gerrit/git-repo",
+      "--repo-rev",
+      "b750b48f50eb4a11087ca6775161d5bf4d5c47d5",
+      "--no-repo-verify",
       "--manifest-name",
       "default.xml"
     ],
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 576f6fb..71f9242 100644
--- a/recipe_modules/checkout/tests/repo.expected/feature_branches_try.json
+++ b/recipe_modules/checkout/tests/repo.expected/feature_branches_try.json
@@ -510,6 +510,11 @@
       "all",
       "--manifest-branch",
       "feature1",
+      "--repo-url",
+      "https://pigweed.googlesource.com/third_party/gerrit/git-repo",
+      "--repo-rev",
+      "b750b48f50eb4a11087ca6775161d5bf4d5c47d5",
+      "--no-repo-verify",
       "--manifest-name",
       "default.xml"
     ],
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 57ce8cd..8e5a6b7 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
@@ -620,6 +620,11 @@
       "all",
       "--manifest-branch",
       "feature1",
+      "--repo-url",
+      "https://pigweed.googlesource.com/third_party/gerrit/git-repo",
+      "--repo-rev",
+      "b750b48f50eb4a11087ca6775161d5bf4d5c47d5",
+      "--no-repo-verify",
       "--manifest-name",
       "default.xml"
     ],
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 6b79cd3..f5785b0 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
@@ -529,6 +529,11 @@
       "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"
     ],
diff --git a/recipe_modules/checkout/tests/repo.expected/no_trigger.json b/recipe_modules/checkout/tests/repo.expected/no_trigger.json
index 6dae5ad..c753ded 100644
--- a/recipe_modules/checkout/tests/repo.expected/no_trigger.json
+++ b/recipe_modules/checkout/tests/repo.expected/no_trigger.json
@@ -194,6 +194,11 @@
       "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"
     ],
diff --git a/recipe_modules/checkout/tests/repo.expected/prefix.json b/recipe_modules/checkout/tests/repo.expected/prefix.json
index 589d105..43a414f 100644
--- a/recipe_modules/checkout/tests/repo.expected/prefix.json
+++ b/recipe_modules/checkout/tests/repo.expected/prefix.json
@@ -457,6 +457,11 @@
       "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"
     ],
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 71763ff..ce65bd5 100644
--- a/recipe_modules/checkout/tests/repo.expected/try-multiple-cqdeps.json
+++ b/recipe_modules/checkout/tests/repo.expected/try-multiple-cqdeps.json
@@ -702,6 +702,11 @@
       "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"
     ],
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 9851f07..6b03e51 100644
--- a/recipe_modules/checkout/tests/repo.expected/try-multiple-onenotapplied.json
+++ b/recipe_modules/checkout/tests/repo.expected/try-multiple-onenotapplied.json
@@ -602,6 +602,11 @@
       "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"
     ],
diff --git a/recipe_modules/checkout/tests/repo.expected/try-multiple.json b/recipe_modules/checkout/tests/repo.expected/try-multiple.json
index 4ad53d7..e584c26 100644
--- a/recipe_modules/checkout/tests/repo.expected/try-multiple.json
+++ b/recipe_modules/checkout/tests/repo.expected/try-multiple.json
@@ -529,6 +529,11 @@
       "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"
     ],
diff --git a/recipe_modules/checkout/tests/repo.expected/try.json b/recipe_modules/checkout/tests/repo.expected/try.json
index d59535b..0391375 100644
--- a/recipe_modules/checkout/tests/repo.expected/try.json
+++ b/recipe_modules/checkout/tests/repo.expected/try.json
@@ -459,6 +459,11 @@
       "main",
       "--groups",
       "group1",
+      "--repo-url",
+      "https://pigweed.googlesource.com/third_party/gerrit/git-repo",
+      "--repo-rev",
+      "b750b48f50eb4a11087ca6775161d5bf4d5c47d5",
+      "--no-repo-verify",
       "--manifest-name",
       "default.xml"
     ],
diff --git a/recipe_modules/checkout/tests/repo.expected/try_manifest.json b/recipe_modules/checkout/tests/repo.expected/try_manifest.json
index 8d6e367..92631bd 100644
--- a/recipe_modules/checkout/tests/repo.expected/try_manifest.json
+++ b/recipe_modules/checkout/tests/repo.expected/try_manifest.json
@@ -510,6 +510,11 @@
       "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"
     ],
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 995cd65..a6527d0 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
@@ -457,6 +457,11 @@
       "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"
     ],
diff --git a/recipe_modules/repo/api.py b/recipe_modules/repo/api.py
index aa6763d..33fa707 100644
--- a/recipe_modules/repo/api.py
+++ b/recipe_modules/repo/api.py
@@ -31,7 +31,8 @@
     'ProjectInfo', ['name', 'path', 'remote', 'branch']
 )
 
-REPO_URL = 'https://storage.googleapis.com/git-repo-downloads/repo'
+_REPO_URL = 'https://pigweed.googlesource.com/third_party/gerrit/git-repo'
+_REPO_REV = 'b750b48f50eb4a11087ca6775161d5bf4d5c47d5'
 
 
 class RepoApi(recipe_api.RecipeApi):
@@ -144,8 +145,8 @@
         reference=None,
         groups=None,
         depth=None,
-        repo_url=None,
-        repo_branch=None,
+        repo_url=_REPO_URL,
+        repo_rev=_REPO_REV,
         timeout=15 * 60,
         **kwargs,
     ):
@@ -160,7 +161,7 @@
             groups (list): Groups to checkout (see `repo init --groups`).
             depth (int): Create a shallow clone of the given depth.
             repo_url (str): URL of the repo repository.
-            repo_branch (str): Repo binary branch to use.
+            repo_rev (str): Repo binary revision to use.
             timeout (int): Timeout in seconds.
             **kwargs: Passed through to self.m.step().
         """
@@ -181,8 +182,8 @@
             cmd += ['--depth', '%d' % depth]
         if repo_url is not None:
             cmd += ['--repo-url', repo_url]
-        if repo_branch is not None:
-            cmd += ['--repo-branch', repo_branch, '--no-repo-verify']
+        if repo_rev is not None:
+            cmd += ['--repo-rev', repo_rev, '--no-repo-verify']
         if manifest_name:
             cmd += ['--manifest-name', manifest_name]
         self._step(cmd, timeout=timeout, **kwargs)
diff --git a/recipe_modules/repo/examples/full.expected/setup_repo.json b/recipe_modules/repo/examples/full.expected/setup_repo.json
index a742844..b280dfa 100644
--- a/recipe_modules/repo/examples/full.expected/setup_repo.json
+++ b/recipe_modules/repo/examples/full.expected/setup_repo.json
@@ -6,7 +6,12 @@
       "--manifest-url",
       "http://manifest_url",
       "--groups",
-      "all"
+      "all",
+      "--repo-url",
+      "https://pigweed.googlesource.com/third_party/gerrit/git-repo",
+      "--repo-rev",
+      "b750b48f50eb4a11087ca6775161d5bf4d5c47d5",
+      "--no-repo-verify"
     ],
     "cwd": "[START_DIR]/checkout",
     "infra_step": true,
@@ -67,7 +72,7 @@
       "10",
       "--repo-url",
       "http://repo_url",
-      "--repo-branch",
+      "--repo-rev",
       "next",
       "--no-repo-verify",
       "--manifest-name",
@@ -309,7 +314,12 @@
       "--manifest-url",
       "http://manifest_url",
       "--groups",
-      "all"
+      "all",
+      "--repo-url",
+      "https://pigweed.googlesource.com/third_party/gerrit/git-repo",
+      "--repo-rev",
+      "b750b48f50eb4a11087ca6775161d5bf4d5c47d5",
+      "--no-repo-verify"
     ],
     "cwd": "[CLEANUP]/ensure",
     "infra_step": true,
diff --git a/recipe_modules/repo/examples/full.py b/recipe_modules/repo/examples/full.py
index 7bf36c9..f28ff5e 100644
--- a/recipe_modules/repo/examples/full.py
+++ b/recipe_modules/repo/examples/full.py
@@ -34,7 +34,7 @@
             groups=['group1', 'group2'],
             depth=10,
             repo_url='http://repo_url',
-            repo_branch='next',
+            repo_rev='next',
         )
         api.repo.sync()
         api.repo.sync(
diff --git a/recipe_modules/repo/examples/init_sync_retry.expected/fail-fail.json b/recipe_modules/repo/examples/init_sync_retry.expected/fail-fail.json
index 462b103..d5d2ac6 100644
--- a/recipe_modules/repo/examples/init_sync_retry.expected/fail-fail.json
+++ b/recipe_modules/repo/examples/init_sync_retry.expected/fail-fail.json
@@ -6,7 +6,12 @@
       "--manifest-url",
       "https://manifest/url",
       "--groups",
-      "all"
+      "all",
+      "--repo-url",
+      "https://pigweed.googlesource.com/third_party/gerrit/git-repo",
+      "--repo-rev",
+      "b750b48f50eb4a11087ca6775161d5bf4d5c47d5",
+      "--no-repo-verify"
     ],
     "infra_step": true,
     "name": "repo init",
diff --git a/recipe_modules/repo/examples/init_sync_retry.expected/fail-pass.json b/recipe_modules/repo/examples/init_sync_retry.expected/fail-pass.json
index 5dbe51c..a8f26fb 100644
--- a/recipe_modules/repo/examples/init_sync_retry.expected/fail-pass.json
+++ b/recipe_modules/repo/examples/init_sync_retry.expected/fail-pass.json
@@ -6,7 +6,12 @@
       "--manifest-url",
       "https://manifest/url",
       "--groups",
-      "all"
+      "all",
+      "--repo-url",
+      "https://pigweed.googlesource.com/third_party/gerrit/git-repo",
+      "--repo-rev",
+      "b750b48f50eb4a11087ca6775161d5bf4d5c47d5",
+      "--no-repo-verify"
     ],
     "infra_step": true,
     "name": "repo init",
diff --git a/recipe_modules/repo/examples/repo_retry_failure.expected/repo_retry_failure.json b/recipe_modules/repo/examples/repo_retry_failure.expected/repo_retry_failure.json
index bbededb..10cf4b4 100644
--- a/recipe_modules/repo/examples/repo_retry_failure.expected/repo_retry_failure.json
+++ b/recipe_modules/repo/examples/repo_retry_failure.expected/repo_retry_failure.json
@@ -65,7 +65,12 @@
       "--manifest-url",
       "http://manifest_url",
       "--groups",
-      "all"
+      "all",
+      "--repo-url",
+      "https://pigweed.googlesource.com/third_party/gerrit/git-repo",
+      "--repo-rev",
+      "b750b48f50eb4a11087ca6775161d5bf4d5c47d5",
+      "--no-repo-verify"
     ],
     "cwd": "[CLEANUP]/ensure",
     "infra_step": true,
@@ -134,7 +139,12 @@
       "--manifest-url",
       "http://manifest_url",
       "--groups",
-      "all"
+      "all",
+      "--repo-url",
+      "https://pigweed.googlesource.com/third_party/gerrit/git-repo",
+      "--repo-rev",
+      "b750b48f50eb4a11087ca6775161d5bf4d5c47d5",
+      "--no-repo-verify"
     ],
     "cwd": "[CLEANUP]/ensure",
     "infra_step": true,
diff --git a/recipe_modules/repo/examples/repo_retry_success.expected/repo_retry_success.json b/recipe_modules/repo/examples/repo_retry_success.expected/repo_retry_success.json
index 5914a98..b82f954 100644
--- a/recipe_modules/repo/examples/repo_retry_success.expected/repo_retry_success.json
+++ b/recipe_modules/repo/examples/repo_retry_success.expected/repo_retry_success.json
@@ -65,7 +65,12 @@
       "--manifest-url",
       "http://manifest_url",
       "--groups",
-      "all"
+      "all",
+      "--repo-url",
+      "https://pigweed.googlesource.com/third_party/gerrit/git-repo",
+      "--repo-rev",
+      "b750b48f50eb4a11087ca6775161d5bf4d5c47d5",
+      "--no-repo-verify"
     ],
     "cwd": "[CLEANUP]/ensure",
     "infra_step": true,
@@ -134,7 +139,12 @@
       "--manifest-url",
       "http://manifest_url",
       "--groups",
-      "all"
+      "all",
+      "--repo-url",
+      "https://pigweed.googlesource.com/third_party/gerrit/git-repo",
+      "--repo-rev",
+      "b750b48f50eb4a11087ca6775161d5bf4d5c47d5",
+      "--no-repo-verify"
     ],
     "cwd": "[CLEANUP]/ensure",
     "infra_step": true,
diff --git a/recipe_modules/repo/examples/timeout.expected/timeout_persistent.json b/recipe_modules/repo/examples/timeout.expected/timeout_persistent.json
index 25c96f9..ab9511b 100644
--- a/recipe_modules/repo/examples/timeout.expected/timeout_persistent.json
+++ b/recipe_modules/repo/examples/timeout.expected/timeout_persistent.json
@@ -8,7 +8,12 @@
       "--groups",
       "all",
       "--manifest-branch",
-      "main"
+      "main",
+      "--repo-url",
+      "https://pigweed.googlesource.com/third_party/gerrit/git-repo",
+      "--repo-rev",
+      "b750b48f50eb4a11087ca6775161d5bf4d5c47d5",
+      "--no-repo-verify"
     ],
     "infra_step": true,
     "name": "repo init",
@@ -26,7 +31,12 @@
       "--groups",
       "all",
       "--manifest-branch",
-      "main"
+      "main",
+      "--repo-url",
+      "https://pigweed.googlesource.com/third_party/gerrit/git-repo",
+      "--repo-rev",
+      "b750b48f50eb4a11087ca6775161d5bf4d5c47d5",
+      "--no-repo-verify"
     ],
     "infra_step": true,
     "name": "repo init (2)",
@@ -44,7 +54,12 @@
       "--groups",
       "all",
       "--manifest-branch",
-      "main"
+      "main",
+      "--repo-url",
+      "https://pigweed.googlesource.com/third_party/gerrit/git-repo",
+      "--repo-rev",
+      "b750b48f50eb4a11087ca6775161d5bf4d5c47d5",
+      "--no-repo-verify"
     ],
     "infra_step": true,
     "name": "repo init (3)",
diff --git a/recipe_modules/repo/examples/timeout.expected/timeout_recover.json b/recipe_modules/repo/examples/timeout.expected/timeout_recover.json
index 7168a20..c260e76 100644
--- a/recipe_modules/repo/examples/timeout.expected/timeout_recover.json
+++ b/recipe_modules/repo/examples/timeout.expected/timeout_recover.json
@@ -8,7 +8,12 @@
       "--groups",
       "all",
       "--manifest-branch",
-      "main"
+      "main",
+      "--repo-url",
+      "https://pigweed.googlesource.com/third_party/gerrit/git-repo",
+      "--repo-rev",
+      "b750b48f50eb4a11087ca6775161d5bf4d5c47d5",
+      "--no-repo-verify"
     ],
     "infra_step": true,
     "name": "repo init",
@@ -26,7 +31,12 @@
       "--groups",
       "all",
       "--manifest-branch",
-      "main"
+      "main",
+      "--repo-url",
+      "https://pigweed.googlesource.com/third_party/gerrit/git-repo",
+      "--repo-rev",
+      "b750b48f50eb4a11087ca6775161d5bf4d5c47d5",
+      "--no-repo-verify"
     ],
     "infra_step": true,
     "name": "repo init (2)",
@@ -44,7 +54,12 @@
       "--groups",
       "all",
       "--manifest-branch",
-      "main"
+      "main",
+      "--repo-url",
+      "https://pigweed.googlesource.com/third_party/gerrit/git-repo",
+      "--repo-rev",
+      "b750b48f50eb4a11087ca6775161d5bf4d5c47d5",
+      "--no-repo-verify"
     ],
     "infra_step": true,
     "name": "repo init (3)",
diff --git a/recipe_modules/repo/resources/repo b/recipe_modules/repo/resources/repo
index 4cddbf1..c084b65 100755
--- a/recipe_modules/repo/resources/repo
+++ b/recipe_modules/repo/resources/repo
@@ -149,7 +149,7 @@
 BUG_URL = 'https://bugs.chromium.org/p/gerrit/issues/entry?template=Repo+tool+issue'
 
 # increment this whenever we make important changes to this script
-VERSION = (2, 17)
+VERSION = (2, 21)
 
 # increment this if the MAINTAINER_KEYS block is modified
 KEYRING_VERSION = (2, 3)
@@ -372,7 +372,7 @@
                    help='filter for use with --partial-clone '
                         '[default: %default]')
   group.add_option('--use-superproject', action='store_true', default=None,
-                   help='use the manifest superproject to sync projects')
+                   help='use the manifest superproject to sync projects; implies -c')
   group.add_option('--no-use-superproject', action='store_false',
                    dest='use_superproject',
                    help='disable use of manifest superprojects')
@@ -382,6 +382,11 @@
   group.add_option('--no-clone-bundle',
                    dest='clone_bundle', action='store_false',
                    help='disable use of /clone.bundle on HTTP/HTTPS (default if --partial-clone)')
+  group.add_option('--git-lfs', action='store_true',
+                   help='enable Git LFS support')
+  group.add_option('--no-git-lfs',
+                   dest='git_lfs', action='store_false',
+                   help='disable Git LFS support')
 
   # Tool.
   group = parser.add_option_group('repo Version options')
@@ -618,6 +623,7 @@
             "REPO_URL set correctly?" % url, file=sys.stderr)
 
   except CloneFailure:
+    print('fatal: double check your --repo-rev setting.', file=sys.stderr)
     if opt.quiet:
       print('fatal: repo init failed; run without --quiet to see why',
             file=sys.stderr)
diff --git a/recipes/target_to_cipd.expected/success.json b/recipes/target_to_cipd.expected/success.json
index a06c050..c845031 100644
--- a/recipes/target_to_cipd.expected/success.json
+++ b/recipes/target_to_cipd.expected/success.json
@@ -245,6 +245,11 @@
       "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"
     ],