summaryrefslogtreecommitdiffstats
path: root/subcmds/sync.py
diff options
context:
space:
mode:
authorJosip Sokcevic <sokcevic@chromium.org>2025-03-12 20:40:49 +0000
committerLUCI <gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com>2025-03-13 08:24:35 -0700
commitfc901b92bbcde2c16cd557322041abf958297665 (patch)
tree758275e935e2752bdfa9014676b764fab3f2ee5b /subcmds/sync.py
parent8d5f03261164f3cd65af0576dfa7d4edded96c67 (diff)
downloadgit-repo-fc901b92bbcde2c16cd557322041abf958297665.tar.gz
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 <sokcevic@chromium.org> Tested-by: Josip Sokcevic <sokcevic@chromium.org> Reviewed-by: Scott Lee <ddoman@google.com>
Diffstat (limited to 'subcmds/sync.py')
-rw-r--r--subcmds/sync.py2
1 files changed, 2 insertions, 0 deletions
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):
1999 # We also have to make sure this will switch to an older commit if 1999 # We also have to make sure this will switch to an older commit if
2000 # that's the latest tag in order to support release rollback. 2000 # that's the latest tag in order to support release rollback.
2001 try: 2001 try:
2002 # Refresh index since reset --keep won't do it.
2003 rp.work_git.update_index("-q", "--refresh")
2002 rp.work_git.reset("--keep", new_rev) 2004 rp.work_git.reset("--keep", new_rev)
2003 except GitError as e: 2005 except GitError as e:
2004 raise RepoUnhandledExceptionError(e) 2006 raise RepoUnhandledExceptionError(e)