From b0de8a94323d3eb654556ab9455a2c53b5a15f43 Mon Sep 17 00:00:00 2001 From: Scott Lee Date: Tue, 8 Apr 2025 16:05:16 -0700 Subject: [PATCH] Refresh the git cache when applying patches in gclient https://crrev.com/c/3206616 was landed to refresh remote/origin/main. However, it only updated the workspace so that the stale info in the mirror can possibly cause unrelated commits to be picked in the cherry-pick command in [0] This patch is to update the git cache in Mirror, so that the cherry pick will work with the up-to-date commit history. [0]: https://source.chromium.org/chromium/chromium/tools/depot_tools/+/main:gclient_scm.py;l=616;drc=8b60ab5798150d5ea53a89a968edaa62e60d2b36 Bug: 40199928, 407795715 Change-Id: Icf691bf0f50ce2080e8163c91576f00afa60b154 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6442501 Reviewed-by: Josip Sokcevic Commit-Queue: Scott Lee --- gclient_scm.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gclient_scm.py b/gclient_scm.py index 6fb5eb9cd8..70b4f39202 100644 --- a/gclient_scm.py +++ b/gclient_scm.py @@ -547,6 +547,11 @@ class GitWrapper(SCMWrapper): if scm.GIT.IsValidRevision(self.checkout_path, remote_ref): # refs/remotes may need to be updated to cleanly cherry-pick # changes. See https://crbug.com/1255178. + url, _ = gclient_utils.SplitUrlRevision(self.url) + mirror = self._GetMirror(url, options, target_rev, remote_ref) + if mirror: + self._UpdateMirrorIfNotContains(mirror, options, 'branch', + target_rev) self._Capture(['fetch', '--no-tags', self.remote, target_rev]) target_rev = remote_ref elif not scm.GIT.IsValidRevision(self.checkout_path, target_rev):