diff --git a/git_command.py b/git_command.py index 26668a39..a2782151 100644 --- a/git_command.py +++ b/git_command.py @@ -214,10 +214,6 @@ def git_require(min_version, fail=False, msg=''): return False -def _setenv(env, name, value): - env[name] = value.encode() - - class GitCommand(object): def __init__(self, project, @@ -237,21 +233,21 @@ class GitCommand(object): self.tee = {'stdout': not capture_stdout, 'stderr': not capture_stderr} if disable_editor: - _setenv(env, 'GIT_EDITOR', ':') + env['GIT_EDITOR'] = ':' if ssh_proxy: - _setenv(env, 'REPO_SSH_SOCK', ssh_sock()) - _setenv(env, 'GIT_SSH', _ssh_proxy()) - _setenv(env, 'GIT_SSH_VARIANT', 'ssh') + env['REPO_SSH_SOCK'] = ssh_sock() + env['GIT_SSH'] = _ssh_proxy() + env['GIT_SSH_VARIANT'] = 'ssh' if 'http_proxy' in env and 'darwin' == sys.platform: s = "'http.proxy=%s'" % (env['http_proxy'],) p = env.get('GIT_CONFIG_PARAMETERS') if p is not None: s = p + ' ' + s - _setenv(env, 'GIT_CONFIG_PARAMETERS', s) + env['GIT_CONFIG_PARAMETERS'] = s if 'GIT_ALLOW_PROTOCOL' not in env: - _setenv(env, 'GIT_ALLOW_PROTOCOL', - 'file:git:http:https:ssh:persistent-http:persistent-https:sso:rpc') - _setenv(env, 'GIT_HTTP_USER_AGENT', user_agent.git) + env['GIT_ALLOW_PROTOCOL'] = ( + 'file:git:http:https:ssh:persistent-http:persistent-https:sso:rpc') + env['GIT_HTTP_USER_AGENT'] = user_agent.git if project: if not cwd: @@ -262,7 +258,7 @@ class GitCommand(object): command = [GIT] if bare: if gitdir: - _setenv(env, GIT_DIR, gitdir) + env[GIT_DIR] = gitdir cwd = None command.append(cmdv[0]) # Need to use the --progress flag for fetch/clone so output will be diff --git a/subcmds/forall.py b/subcmds/forall.py index d0e51920..74d1ede7 100644 --- a/subcmds/forall.py +++ b/subcmds/forall.py @@ -310,8 +310,6 @@ def DoWork(project, mirror, opt, cmd, shell, cnt, config): def setenv(name, val): if val is None: val = '' - if hasattr(val, 'encode'): - val = val.encode() env[name] = val setenv('REPO_PROJECT', project['name']) diff --git a/subcmds/sync.py b/subcmds/sync.py index 1988cc72..0ac308e6 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py @@ -794,13 +794,13 @@ later is required to fix a server side protocol bug. if branch.startswith(R_HEADS): branch = branch[len(R_HEADS):] - env = os.environ.copy() - if 'SYNC_TARGET' in env: - target = env['SYNC_TARGET'] + if 'SYNC_TARGET' in os.environ: + target = os.environ('SYNC_TARGET') [success, manifest_str] = server.GetApprovedManifest(branch, target) - elif 'TARGET_PRODUCT' in env and 'TARGET_BUILD_VARIANT' in env: - target = '%s-%s' % (env['TARGET_PRODUCT'], - env['TARGET_BUILD_VARIANT']) + elif ('TARGET_PRODUCT' in os.environ and + 'TARGET_BUILD_VARIANT' in os.environ): + target = '%s-%s' % (os.environ('TARGET_PRODUCT'), + os.environ('TARGET_BUILD_VARIANT')) [success, manifest_str] = server.GetApprovedManifest(branch, target) else: [success, manifest_str] = server.GetApprovedManifest(branch) @@ -1111,8 +1111,8 @@ def _VerifyTag(project): return False env = os.environ.copy() - env['GIT_DIR'] = project.gitdir.encode() - env['GNUPGHOME'] = gpg_dir.encode() + env['GIT_DIR'] = project.gitdir + env['GNUPGHOME'] = gpg_dir cmd = [GIT, 'tag', '-v', cur] proc = subprocess.Popen(cmd,