From fc901b92bbcde2c16cd557322041abf958297665 Mon Sep 17 00:00:00 2001 From: Josip Sokcevic Date: Wed, 12 Mar 2025 20:40:49 +0000 Subject: [PATCH] sync: Refresh index before updating repo If the repo index is stale, reset --keep will refuse to reset workspace. An index can be stale if there are any modifications to file node, including mtime, atime, ownership changes, etc. Bug: b/375423099 Change-Id: Ibef03d9d8d2babbb107041707281687342ab7a77 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/460022 Commit-Queue: Josip Sokcevic Tested-by: Josip Sokcevic Reviewed-by: Scott Lee --- subcmds/sync.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/subcmds/sync.py b/subcmds/sync.py index 978b3beb..49874c44 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py @@ -1999,6 +1999,8 @@ def _PostRepoFetch(rp, repo_verify=True, verbose=False): # We also have to make sure this will switch to an older commit if # that's the latest tag in order to support release rollback. try: + # Refresh index since reset --keep won't do it. + rp.work_git.update_index("-q", "--refresh") rp.work_git.reset("--keep", new_rev) except GitError as e: raise RepoUnhandledExceptionError(e)