diff options
author | Shawn O. Pearce <sop@google.com> | 2010-12-07 11:41:05 -0800 |
---|---|---|
committer | Shawn O. Pearce <sop@google.com> | 2011-01-09 16:13:56 -0800 |
commit | f18cb761731a791bf1b9ee8c6308bfce5c9d3e62 (patch) | |
tree | 5b1440e04b3945177eb7033f40cf496e7e28ba34 /git_command.py | |
parent | d3fd537ea59272e2141ccee839400a93c0196e36 (diff) | |
download | git-repo-f18cb761731a791bf1b9ee8c6308bfce5c9d3e62.tar.gz |
Encode the environment variables passed to git
Windows allows the environment to have unicode values.
This will cause Python to fail to execute the command.
Change-Id: I37d922c3d7ced0d5b4883f0220346ac42defc5e9
Signed-off-by: Shawn O. Pearce <sop@google.com>
Diffstat (limited to 'git_command.py')
-rw-r--r-- | git_command.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/git_command.py b/git_command.py index 4ad908f6..4aeacd57 100644 --- a/git_command.py +++ b/git_command.py | |||
@@ -112,6 +112,9 @@ def git_require(min_version, fail=False): | |||
112 | sys.exit(1) | 112 | sys.exit(1) |
113 | return False | 113 | return False |
114 | 114 | ||
115 | def _setenv(env, name, value): | ||
116 | env[name] = value.encode() | ||
117 | |||
115 | class GitCommand(object): | 118 | class GitCommand(object): |
116 | def __init__(self, | 119 | def __init__(self, |
117 | project, | 120 | project, |
@@ -137,10 +140,10 @@ class GitCommand(object): | |||
137 | del env[e] | 140 | del env[e] |
138 | 141 | ||
139 | if disable_editor: | 142 | if disable_editor: |
140 | env['GIT_EDITOR'] = ':' | 143 | _setenv(env, 'GIT_EDITOR', ':') |
141 | if ssh_proxy: | 144 | if ssh_proxy: |
142 | env['REPO_SSH_SOCK'] = ssh_sock() | 145 | _setenv(env, 'REPO_SSH_SOCK', ssh_sock()) |
143 | env['GIT_SSH'] = _ssh_proxy() | 146 | _setenv(env, 'GIT_SSH', _ssh_proxy()) |
144 | 147 | ||
145 | if project: | 148 | if project: |
146 | if not cwd: | 149 | if not cwd: |
@@ -151,7 +154,7 @@ class GitCommand(object): | |||
151 | command = [GIT] | 154 | command = [GIT] |
152 | if bare: | 155 | if bare: |
153 | if gitdir: | 156 | if gitdir: |
154 | env[GIT_DIR] = gitdir | 157 | _setenv(env, GIT_DIR, gitdir) |
155 | cwd = None | 158 | cwd = None |
156 | command.extend(cmdv) | 159 | command.extend(cmdv) |
157 | 160 | ||