From a111c9189d117f995645e4b95a73dafb26d75889 Mon Sep 17 00:00:00 2001 From: Aravind Vasudevan Date: Wed, 18 Jan 2023 23:44:40 +0000 Subject: [PATCH] Fix roll dep to use update-index This change updates roll-dep to update submodule revision using `git update-index` instead of `git add` to stay consistent with our design. Fix: 1406766 Change-Id: Ic23b9758a5893ac211d459a3c451bb102d4501a8 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4177144 Reviewed-by: Josip Sokcevic Auto-Submit: Aravind Vasudevan Commit-Queue: Josip Sokcevic --- roll_dep.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/roll_dep.py b/roll_dep.py index 00fac4ab13..266bca4856 100755 --- a/roll_dep.py +++ b/roll_dep.py @@ -210,12 +210,16 @@ def finalize(commit_msg, current_dir, rolls): # Pull the dependency to the right revision. This is surprising to users # otherwise. The revision update is done before commiting to update # submodule revision if present. - for _head, roll_to, full_dir in sorted(rolls.values()): + for dependency, (_head, roll_to, full_dir) in sorted(rolls.items()): check_call(['git', 'checkout', '--quiet', roll_to], cwd=full_dir) # This adds the submodule revision update to the commit. if is_submoduled(): - check_call(['git', 'add', full_dir]) + check_call([ + 'git', 'update-index', '--add', '--cacheinfo', '160000,{},{}'.format( + roll_to, dependency) + ], + cwd=current_dir) check_call(['git', 'add', 'DEPS'], cwd=current_dir) # We have to set delete=False and then let the object go out of scope so