From 3d7cbce9e6c067cc4eea528f83327cc4a8b0e4a7 Mon Sep 17 00:00:00 2001 From: Josip Sokcevic Date: Tue, 5 Oct 2021 20:48:04 +0000 Subject: [PATCH] Fetch remote when applying patches in gclient Remote references may not be up-to-date, resulting in cherry-picking way more changes than needed. In such scenario, it is possible that some cherry-picking results in conflict and therefore fails gclient sync. R=gavinmak@google.com Bug: 1255178 Change-Id: Ibc67ae06c5798286b7510e4119d882053dc9b73f Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3206616 Reviewed-by: Gavin Mak Commit-Queue: Josip Sokcevic --- gclient_scm.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gclient_scm.py b/gclient_scm.py index 151503b754..80519d9bbd 100644 --- a/gclient_scm.py +++ b/gclient_scm.py @@ -396,6 +396,9 @@ class GitWrapper(SCMWrapper): self.Print('Trying the corresponding remote ref for %r: %r\n' % ( target_rev, remote_ref)) 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. + self._Capture(['fetch', '--no-tags', self.remote, target_rev]) target_rev = remote_ref elif not scm.GIT.IsValidRevision(self.checkout_path, target_rev): # Fetch |target_rev| if it's not already available.