diff options
author | Joanna Wang <jojwang@google.com> | 2022-11-03 16:51:19 -0400 |
---|---|---|
committer | Joanna Wang <jojwang@google.com> | 2022-11-03 21:07:07 +0000 |
commit | a6c52f566acfbff5b0f37158c0d33adf05d250e5 (patch) | |
tree | d79d55b872c3be39c54dcb6ef41749c40d39ccf2 /git_command.py | |
parent | 0d130d2da0754c546f654ede99a79aac2b8e6c5f (diff) | |
download | git-repo-a6c52f566acfbff5b0f37158c0d33adf05d250e5.tar.gz |
Set tracing to always on and save to .repo/TRACE_FILE.
- add `--trace_to_stderr` option so stderr will include trace outputs and any other errors that get sent to stderr
- while TRACE_FILE will only include trace outputs
piggy-backing on: https://gerrit-review.googlesource.com/c/git-repo/+/349154
Change-Id: I3895a84de4b2784f17fac4325521cd5e72e645e2
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/350114
Reviewed-by: LaMont Jones <lamontjones@google.com>
Tested-by: Joanna Wang <jojwang@google.com>
Diffstat (limited to 'git_command.py')
-rw-r--r-- | git_command.py | 47 |
1 files changed, 23 insertions, 24 deletions
diff --git a/git_command.py b/git_command.py index 19100fa9..56e18e02 100644 --- a/git_command.py +++ b/git_command.py | |||
@@ -230,12 +230,11 @@ class GitCommand(object): | |||
230 | stderr = (subprocess.STDOUT if merge_output else | 230 | stderr = (subprocess.STDOUT if merge_output else |
231 | (subprocess.PIPE if capture_stderr else None)) | 231 | (subprocess.PIPE if capture_stderr else None)) |
232 | 232 | ||
233 | dbg = '' | ||
233 | if IsTrace(): | 234 | if IsTrace(): |
234 | global LAST_CWD | 235 | global LAST_CWD |
235 | global LAST_GITDIR | 236 | global LAST_GITDIR |
236 | 237 | ||
237 | dbg = '' | ||
238 | |||
239 | if cwd and LAST_CWD != cwd: | 238 | if cwd and LAST_CWD != cwd: |
240 | if LAST_GITDIR or LAST_CWD: | 239 | if LAST_GITDIR or LAST_CWD: |
241 | dbg += '\n' | 240 | dbg += '\n' |
@@ -263,31 +262,31 @@ class GitCommand(object): | |||
263 | dbg += ' 2>|' | 262 | dbg += ' 2>|' |
264 | elif stderr == subprocess.STDOUT: | 263 | elif stderr == subprocess.STDOUT: |
265 | dbg += ' 2>&1' | 264 | dbg += ' 2>&1' |
266 | Trace('%s', dbg) | ||
267 | |||
268 | try: | ||
269 | p = subprocess.Popen(command, | ||
270 | cwd=cwd, | ||
271 | env=env, | ||
272 | encoding='utf-8', | ||
273 | errors='backslashreplace', | ||
274 | stdin=stdin, | ||
275 | stdout=stdout, | ||
276 | stderr=stderr) | ||
277 | except Exception as e: | ||
278 | raise GitError('%s: %s' % (command[1], e)) | ||
279 | |||
280 | if ssh_proxy: | ||
281 | ssh_proxy.add_client(p) | ||
282 | 265 | ||
283 | self.process = p | 266 | with Trace('git command %s %s with debug: %s', LAST_GITDIR, command, dbg): |
267 | try: | ||
268 | p = subprocess.Popen(command, | ||
269 | cwd=cwd, | ||
270 | env=env, | ||
271 | encoding='utf-8', | ||
272 | errors='backslashreplace', | ||
273 | stdin=stdin, | ||
274 | stdout=stdout, | ||
275 | stderr=stderr) | ||
276 | except Exception as e: | ||
277 | raise GitError('%s: %s' % (command[1], e)) | ||
284 | 278 | ||
285 | try: | ||
286 | self.stdout, self.stderr = p.communicate(input=input) | ||
287 | finally: | ||
288 | if ssh_proxy: | 279 | if ssh_proxy: |
289 | ssh_proxy.remove_client(p) | 280 | ssh_proxy.add_client(p) |
290 | self.rc = p.wait() | 281 | |
282 | self.process = p | ||
283 | |||
284 | try: | ||
285 | self.stdout, self.stderr = p.communicate(input=input) | ||
286 | finally: | ||
287 | if ssh_proxy: | ||
288 | ssh_proxy.remove_client(p) | ||
289 | self.rc = p.wait() | ||
291 | 290 | ||
292 | @staticmethod | 291 | @staticmethod |
293 | def _GetBasicEnv(): | 292 | def _GetBasicEnv(): |