Merge branch 'stable'

* stable:
  Encode the environment variables passed to git
  Exit with statuscode 0 for repo help init
This commit is contained in:
Shawn O. Pearce 2011-01-09 17:29:50 -08:00
commit 71cab95b4c
4 changed files with 18 additions and 14 deletions

View File

@ -112,6 +112,9 @@ def git_require(min_version, fail=False):
sys.exit(1) sys.exit(1)
return False return False
def _setenv(env, name, value):
env[name] = value.encode()
class GitCommand(object): class GitCommand(object):
def __init__(self, def __init__(self,
project, project,
@ -137,10 +140,10 @@ class GitCommand(object):
del env[e] del env[e]
if disable_editor: if disable_editor:
env['GIT_EDITOR'] = ':' _setenv(env, 'GIT_EDITOR', ':')
if ssh_proxy: if ssh_proxy:
env['REPO_SSH_SOCK'] = ssh_sock() _setenv(env, 'REPO_SSH_SOCK', ssh_sock())
env['GIT_SSH'] = _ssh_proxy() _setenv(env, 'GIT_SSH', _ssh_proxy())
if project: if project:
if not cwd: if not cwd:
@ -151,7 +154,7 @@ class GitCommand(object):
command = [GIT] command = [GIT]
if bare: if bare:
if gitdir: if gitdir:
env[GIT_DIR] = gitdir _setenv(env, GIT_DIR, gitdir)
cwd = None cwd = None
command.extend(cmdv) command.extend(cmdv)

9
repo
View File

@ -264,8 +264,8 @@ def _SetupGnuPG(quiet):
gpg_dir, e.strerror) gpg_dir, e.strerror)
sys.exit(1) sys.exit(1)
env = dict(os.environ) env = os.environ.copy()
env['GNUPGHOME'] = gpg_dir env['GNUPGHOME'] = gpg_dir.encode()
cmd = ['gpg', '--import'] cmd = ['gpg', '--import']
try: try:
@ -383,8 +383,8 @@ def _Verify(cwd, branch, quiet):
% (branch, cur) % (branch, cur)
print >>sys.stderr print >>sys.stderr
env = dict(os.environ) env = os.environ.copy()
env['GNUPGHOME'] = gpg_dir env['GNUPGHOME'] = gpg_dir.encode()
cmd = [GIT, 'tag', '-v', cur] cmd = [GIT, 'tag', '-v', cur]
proc = subprocess.Popen(cmd, proc = subprocess.Popen(cmd,
@ -488,6 +488,7 @@ def _Help(args):
if args: if args:
if args[0] == 'init': if args[0] == 'init':
init_optparse.print_help() init_optparse.print_help()
sys.exit(0)
else: else:
print >>sys.stderr,\ print >>sys.stderr,\
"error: '%s' is not a bootstrap command.\n"\ "error: '%s' is not a bootstrap command.\n"\

View File

@ -151,11 +151,11 @@ terminal and are not redirected.
first = True first = True
for project in self.GetProjects(args): for project in self.GetProjects(args):
env = dict(os.environ.iteritems()) env = os.environ.copy()
def setenv(name, val): def setenv(name, val):
if val is None: if val is None:
val = '' val = ''
env[name] = val env[name] = val.encode()
setenv('REPO_PROJECT', project.name) setenv('REPO_PROJECT', project.name)
setenv('REPO_PATH', project.relpath) setenv('REPO_PATH', project.relpath)

View File

@ -271,7 +271,7 @@ uncommitted changes are present' % project.relpath
if branch.startswith(R_HEADS): if branch.startswith(R_HEADS):
branch = branch[len(R_HEADS):] branch = branch[len(R_HEADS):]
env = dict(os.environ) env = os.environ.copy()
if (env.has_key('TARGET_PRODUCT') and if (env.has_key('TARGET_PRODUCT') and
env.has_key('TARGET_BUILD_VARIANT')): env.has_key('TARGET_BUILD_VARIANT')):
target = '%s-%s' % (env['TARGET_PRODUCT'], target = '%s-%s' % (env['TARGET_PRODUCT'],
@ -428,9 +428,9 @@ warning: Cannot automatically authenticate repo."""
% (project.name, rev) % (project.name, rev)
return False return False
env = dict(os.environ) env = os.environ.copy()
env['GIT_DIR'] = project.gitdir env['GIT_DIR'] = project.gitdir.encode()
env['GNUPGHOME'] = gpg_dir env['GNUPGHOME'] = gpg_dir.encode()
cmd = [GIT, 'tag', '-v', cur] cmd = [GIT, 'tag', '-v', cur]
proc = subprocess.Popen(cmd, proc = subprocess.Popen(cmd,