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 <sokcevic@chromium.org>
Commit-Queue: Scott Lee <ddoman@chromium.org>
changes/01/6442501/4
Scott Lee 7 months ago committed by LUCI CQ
parent f5b53c0e98
commit b0de8a9432

@ -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):

Loading…
Cancel
Save