summaryrefslogtreecommitdiffstats
path: root/git_command.py
diff options
context:
space:
mode:
Diffstat (limited to 'git_command.py')
-rw-r--r--git_command.py42
1 files changed, 21 insertions, 21 deletions
diff --git a/git_command.py b/git_command.py
index 3a3bb34d..d4d4bed4 100644
--- a/git_command.py
+++ b/git_command.py
@@ -159,12 +159,12 @@ def git_require(min_version, fail=False, msg=''):
159 159
160 160
161def _build_env( 161def _build_env(
162 _kwargs_only=(), 162 _kwargs_only=(),
163 bare: Optional[bool] = False, 163 bare: Optional[bool] = False,
164 disable_editor: Optional[bool] = False, 164 disable_editor: Optional[bool] = False,
165 ssh_proxy: Optional[Any] = None, 165 ssh_proxy: Optional[Any] = None,
166 gitdir: Optional[str] = None, 166 gitdir: Optional[str] = None,
167 objdir: Optional[str] = None 167 objdir: Optional[str] = None
168): 168):
169 """Constucts an env dict for command execution.""" 169 """Constucts an env dict for command execution."""
170 170
@@ -194,8 +194,7 @@ def _build_env(
194 env['GIT_OBJECT_DIRECTORY'] = objdir 194 env['GIT_OBJECT_DIRECTORY'] = objdir
195 195
196 alt_objects = os.path.join(gitdir, 'objects') if gitdir else None 196 alt_objects = os.path.join(gitdir, 'objects') if gitdir else None
197 if (alt_objects and 197 if alt_objects and os.path.realpath(alt_objects) != os.path.realpath(objdir):
198 os.path.realpath(alt_objects) != os.path.realpath(objdir)):
199 # Allow git to search the original place in case of local or unique refs 198 # Allow git to search the original place in case of local or unique refs
200 # that git will attempt to resolve even if we aren't fetching them. 199 # that git will attempt to resolve even if we aren't fetching them.
201 env['GIT_ALTERNATE_OBJECT_DIRECTORIES'] = alt_objects 200 env['GIT_ALTERNATE_OBJECT_DIRECTORIES'] = alt_objects
@@ -236,11 +235,11 @@ class GitCommand(object):
236 gitdir = gitdir.replace('\\', '/') 235 gitdir = gitdir.replace('\\', '/')
237 236
238 env = _build_env( 237 env = _build_env(
239 disable_editor=disable_editor, 238 disable_editor=disable_editor,
240 ssh_proxy=ssh_proxy, 239 ssh_proxy=ssh_proxy,
241 objdir=objdir, 240 objdir=objdir,
242 gitdir=gitdir, 241 gitdir=gitdir,
243 bare=bare, 242 bare=bare,
244 ) 243 )
245 244
246 command = [GIT] 245 command = [GIT]
@@ -279,7 +278,8 @@ class GitCommand(object):
279 if 'GIT_OBJECT_DIRECTORY' in env: 278 if 'GIT_OBJECT_DIRECTORY' in env:
280 dbg += ': export GIT_OBJECT_DIRECTORY=%s\n' % env['GIT_OBJECT_DIRECTORY'] 279 dbg += ': export GIT_OBJECT_DIRECTORY=%s\n' % env['GIT_OBJECT_DIRECTORY']
281 if 'GIT_ALTERNATE_OBJECT_DIRECTORIES' in env: 280 if 'GIT_ALTERNATE_OBJECT_DIRECTORIES' in env:
282 dbg += ': export GIT_ALTERNATE_OBJECT_DIRECTORIES=%s\n' % env['GIT_ALTERNATE_OBJECT_DIRECTORIES'] 281 dbg += ': export GIT_ALTERNATE_OBJECT_DIRECTORIES=%s\n' % (
282 env['GIT_ALTERNATE_OBJECT_DIRECTORIES'])
283 283
284 dbg += ': ' 284 dbg += ': '
285 dbg += ' '.join(command) 285 dbg += ' '.join(command)
@@ -295,13 +295,13 @@ class GitCommand(object):
295 with Trace('git command %s %s with debug: %s', LAST_GITDIR, command, dbg): 295 with Trace('git command %s %s with debug: %s', LAST_GITDIR, command, dbg):
296 try: 296 try:
297 p = subprocess.Popen(command, 297 p = subprocess.Popen(command,
298 cwd=cwd, 298 cwd=cwd,
299 env=env, 299 env=env,
300 encoding='utf-8', 300 encoding='utf-8',
301 errors='backslashreplace', 301 errors='backslashreplace',
302 stdin=stdin, 302 stdin=stdin,
303 stdout=stdout, 303 stdout=stdout,
304 stderr=stderr) 304 stderr=stderr)
305 except Exception as e: 305 except Exception as e:
306 raise GitError('%s: %s' % (command[1], e)) 306 raise GitError('%s: %s' % (command[1], e))
307 307