Fix gclient crash with unicode strings in .gclient files.

Older .gclient files might have explicit u'' strings in their
specs; as part of upgrading code to Python3 compatibility,
we apparently recently introduced a bug in the handling of this
that might cause them to fail on Windows.

This CL fixes that issue by ensuring that the GIT_DIR env var
is always set to a regular string, regardless of whether
the solution name was specified to be a regular string
or a unicode string.

Bug: 1016599
Change-Id: I295d220559eac20a2ced876672d5ccdb787a5338
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1874704
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Dirk Pranke <dpranke@chromium.org>
changes/04/1874704/4
Dirk Pranke 6 years ago committed by Commit Bot
parent a834f39e21
commit db1e79c1c5

@ -1269,8 +1269,14 @@ class GitWrapper(SCMWrapper):
# we don't accidentally go corrupting parent git checks too. See
# https://crbug.com/1000825 for an example.
if set_git_dir:
env.setdefault('GIT_DIR', os.path.abspath(os.path.join(
self.checkout_path, '.git')))
git_dir = os.path.abspath(os.path.join(self.checkout_path, '.git'))
# Depending on how the .gclient file was defined, self.checkout_path
# might be set to a unicode string, not a regular string; on Windows
# Python2, we can't set env vars to be unicode strings, so we
# forcibly cast the value to a string before setting it.
env.setdefault('GIT_DIR', str(git_dir))
ret = subprocess2.check_output(
['git'] + args, env=env, **kwargs).decode('utf-8')
if strip:

Loading…
Cancel
Save