[gclient] Fix gitmodule for Windows machine

Use universal newlines when writing to gitmodules. Also, split
update-index command so we don't hit Windows limit for process lenght.

R=jojwang

Bug: 1475328
Change-Id: Ia9bba4620a276c31081a9773bac8f6bd309bb86e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4808507
Auto-Submit: Josip Sokcevic <sokcevic@chromium.org>
Reviewed-by: Aravind Vasudevan <aravindvasudev@google.com>
Commit-Queue: Aravind Vasudevan <aravindvasudev@google.com>
changes/07/4808507/2
Josip Sokcevic 2 years ago committed by LUCI CQ
parent 3dce403ca3
commit 293aa65afa

@ -2708,7 +2708,7 @@ def CMDgitmodules(parser, args):
prefix_length = len(delta_path.replace(os.path.sep, '/')) + 1
cache_info = []
with open(options.output_gitmodules, 'w') as f:
with open(options.output_gitmodules, 'w', newline='') as f:
for path, dep in ls.get('deps').items():
if path in options.skip_dep:
continue
@ -2726,6 +2726,10 @@ def CMDgitmodules(parser, args):
f.write(f'[submodule "{path}"]\n\tpath = {path}\n\turl = {url}\n')
if 'condition' in dep:
f.write(f'\tgclient-condition = {dep["condition"]}\n')
# Windows has limit how long, so let's chunk those calls.
if len(cache_info) >= 100:
subprocess2.call(['git', 'update-index', '--add'] + cache_info)
cache_info = []
if cache_info:
subprocess2.call(['git', 'update-index', '--add'] + cache_info)

Loading…
Cancel
Save