|
@@ -10,6 +10,7 @@ copy of repo in the checkout.
|
|
|
|
|
|
|
|
from __future__ import print_function
|
|
from __future__ import print_function
|
|
|
|
|
|
|
|
|
|
+import datetime
|
|
|
import os
|
|
import os
|
|
|
import platform
|
|
import platform
|
|
|
import subprocess
|
|
import subprocess
|
|
@@ -478,6 +479,39 @@ def _CheckGitVersion():
|
|
|
raise CloneFailure()
|
|
raise CloneFailure()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+def SetGitTrace2ParentSid(env=None):
|
|
|
|
|
+ """Set up GIT_TRACE2_PARENT_SID for git tracing."""
|
|
|
|
|
+ # We roughly follow the format git itself uses in trace2/tr2_sid.c.
|
|
|
|
|
+ # (1) Be unique (2) be valid filename (3) be fixed length.
|
|
|
|
|
+ #
|
|
|
|
|
+ # Since we always export this variable, we try to avoid more expensive calls.
|
|
|
|
|
+ # e.g. We don't attempt hostname lookups or hashing the results.
|
|
|
|
|
+ if env is None:
|
|
|
|
|
+ env = os.environ
|
|
|
|
|
+
|
|
|
|
|
+ KEY = 'GIT_TRACE2_PARENT_SID'
|
|
|
|
|
+
|
|
|
|
|
+ now = datetime.datetime.utcnow()
|
|
|
|
|
+ value = 'repo-%s-P%08x' % (now.strftime('%Y%m%dT%H%M%SZ'), os.getpid())
|
|
|
|
|
+
|
|
|
|
|
+ # If it's already set, then append ourselves.
|
|
|
|
|
+ if KEY in env:
|
|
|
|
|
+ value = env[KEY] + '/' + value
|
|
|
|
|
+
|
|
|
|
|
+ _setenv(KEY, value, env=env)
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+def _setenv(key, value, env=None):
|
|
|
|
|
+ """Set |key| in the OS environment |env| to |value|."""
|
|
|
|
|
+ if env is None:
|
|
|
|
|
+ env = os.environ
|
|
|
|
|
+ # Environment handling across systems is messy.
|
|
|
|
|
+ try:
|
|
|
|
|
+ env[key] = value
|
|
|
|
|
+ except UnicodeEncodeError:
|
|
|
|
|
+ env[key] = value.encode()
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
def NeedSetupGnuPG():
|
|
def NeedSetupGnuPG():
|
|
|
if not os.path.isdir(home_dot_repo):
|
|
if not os.path.isdir(home_dot_repo):
|
|
|
return True
|
|
return True
|
|
@@ -514,10 +548,7 @@ def SetupGnuPG(quiet):
|
|
|
sys.exit(1)
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
env = os.environ.copy()
|
|
env = os.environ.copy()
|
|
|
- try:
|
|
|
|
|
- env['GNUPGHOME'] = gpg_dir
|
|
|
|
|
- except UnicodeEncodeError:
|
|
|
|
|
- env['GNUPGHOME'] = gpg_dir.encode()
|
|
|
|
|
|
|
+ _setenv('GNUPGHOME', gpg_dir, env)
|
|
|
|
|
|
|
|
cmd = ['gpg', '--import']
|
|
cmd = ['gpg', '--import']
|
|
|
try:
|
|
try:
|
|
@@ -723,10 +754,7 @@ def _Verify(cwd, branch, quiet):
|
|
|
print(file=sys.stderr)
|
|
print(file=sys.stderr)
|
|
|
|
|
|
|
|
env = os.environ.copy()
|
|
env = os.environ.copy()
|
|
|
- try:
|
|
|
|
|
- env['GNUPGHOME'] = gpg_dir
|
|
|
|
|
- except UnicodeEncodeError:
|
|
|
|
|
- env['GNUPGHOME'] = gpg_dir.encode()
|
|
|
|
|
|
|
+ _setenv('GNUPGHOME', gpg_dir, env)
|
|
|
|
|
|
|
|
cmd = [GIT, 'tag', '-v', cur]
|
|
cmd = [GIT, 'tag', '-v', cur]
|
|
|
proc = subprocess.Popen(cmd,
|
|
proc = subprocess.Popen(cmd,
|
|
@@ -901,6 +929,9 @@ def _SetDefaultsTo(gitdir):
|
|
|
def main(orig_args):
|
|
def main(orig_args):
|
|
|
cmd, opt, args = _ParseArguments(orig_args)
|
|
cmd, opt, args = _ParseArguments(orig_args)
|
|
|
|
|
|
|
|
|
|
+ # We run this early as we run some git commands ourselves.
|
|
|
|
|
+ SetGitTrace2ParentSid()
|
|
|
|
|
+
|
|
|
repo_main, rel_repo_dir = None, None
|
|
repo_main, rel_repo_dir = None, None
|
|
|
# Don't use the local repo copy, make sure to switch to the gitc client first.
|
|
# Don't use the local repo copy, make sure to switch to the gitc client first.
|
|
|
if cmd != 'gitc-init':
|
|
if cmd != 'gitc-init':
|