diff --git a/lib/bup/git.py b/lib/bup/git.py index 02a9597013ec..998e875cf8fd 100644 --- a/lib/bup/git.py +++ b/lib/bup/git.py @@ -32,7 +32,7 @@ from bup.helpers import (Sha1, add_error, chunkyreader, debug1, progress, qprogress, stat_if_exists, unlink, utc_offset_str, - ExistsResult, ObjectExists) + ExistsResult, ObjectExists, bupenv) verbose = 0 @@ -50,7 +50,7 @@ class GitError(Exception): def _gitenv(repo_dir): - return merge_dict(environ, {b'GIT_DIR': os.path.abspath(repo_dir)}) + return merge_dict(bupenv(), {b'GIT_DIR': os.path.abspath(repo_dir)}) def _git_wait(cmd, p): rv = p.wait() @@ -261,7 +261,7 @@ def repo_rel(path): def auto_midx(objdir): args = [path.exe(), b'midx', b'--auto', b'--dir', objdir] try: - rv = subprocess.call(args, stdout=open(os.devnull, 'w')) + rv = subprocess.call(args, stdout=open(os.devnull, 'w'), env=bupenv()) except OSError as e: # make sure 'args' gets printed to help with debugging add_error('%r: exception: %s' % (args, e)) @@ -271,7 +271,7 @@ def auto_midx(objdir): args = [path.exe(), b'bloom', b'--dir', objdir] try: - rv = subprocess.call(args, stdout=open(os.devnull, 'w')) + rv = subprocess.call(args, stdout=open(os.devnull, 'w'), env=bupenv()) except OSError as e: # make sure 'args' gets printed to help with debugging add_error('%r: exception: %s' % (args, e)) diff --git a/lib/bup/helpers.py b/lib/bup/helpers.py index af7b372b9712..355231488e94 100644 --- a/lib/bup/helpers.py +++ b/lib/bup/helpers.py @@ -5,7 +5,6 @@ from collections import namedtuple from contextlib import contextmanager from ctypes import sizeof, c_void_p from math import floor -from os import environ from subprocess import PIPE, Popen import sys, os, subprocess, errno, select, mmap, stat, re, struct import hashlib, heapq, math, operator, time, tempfile @@ -188,6 +187,11 @@ def progress(s): _last_progress = s +def bupenv(): + ttymask = (1 if istty1 else 0) | (2 if istty2 else 0) + return merge_dict(compat.environ, {b'BUP_FORCE_TTY': str(ttymask)}) + + TIME_ESTIMATE_CUTOFF = 5 # seconds @@ -460,7 +464,7 @@ def _argmax_base(command): base_size = 2048 for c in command: base_size += len(command) + 1 - for k, v in compat.items(environ): + for k, v in compat.items(os.environ): base_size += len(k) + len(v) + 2 + sizeof(c_void_p) return base_size