Chromium Code Reviews| Index: git_cl.py |
| diff --git a/git_cl.py b/git_cl.py |
| index 4dfb609eb42ad9adda546b18fb2c00a6262af0f2..2fa434c4b25c034e72c79fe050aa3a18a657ba5d 100755 |
| --- a/git_cl.py |
| +++ b/git_cl.py |
| @@ -69,13 +69,16 @@ def RunCommand(args, error_ok=False, error_message=None, **kwargs): |
| def RunGit(args, **kwargs): |
| """Returns stdout.""" |
| - return RunCommand(['git', '--no-pager'] + args, **kwargs) |
| + return RunCommand(['git'] + args, **kwargs) |
| def RunGitWithCode(args): |
| """Returns return code and stdout.""" |
| try: |
| - out, code = subprocess2.communicate(['git', '--no-pager'] + args, |
| + env = os.environ |
| + env['GIT_PAGER'] = 'cat' # Magic string that prevents a pager. |
|
M-A Ruel
2013/07/08 19:10:50
Move the comment on its own line.
Does this work
iannucci
2013/07/08 20:21:56
(Drive-by: Yeah, GIT_PAGER=cat is a magic value)
Daniel Bratell
2013/07/08 22:08:06
It seems to work when I test manually and accordin
|
| + out, code = subprocess2.communicate(['git'] + args, |
| + env=env, |
| stdout=subprocess2.PIPE) |
| return code, out[0] |
| except ValueError: |
| @@ -225,6 +228,7 @@ def print_stats(similarity, find_copies, args): |
| env = os.environ.copy() |
| if 'GIT_EXTERNAL_DIFF' in env: |
| del env['GIT_EXTERNAL_DIFF'] |
| + env['GIT_PAGER'] = 'cat' # Magical string that disables pagers. |
|
M-A Ruel
2013/07/08 19:10:50
Comment on its own line
|
| if find_copies: |
| similarity_options = ['--find-copies-harder', '-l100000', |
| @@ -233,7 +237,7 @@ def print_stats(similarity, find_copies, args): |
| similarity_options = ['-M%s' % similarity] |
| return subprocess2.call( |
| - ['git', '--no-pager', |
| + ['git', |
| 'diff', '--no-ext-diff', '--stat'] + similarity_options + args, |
| env=env) |
| @@ -301,11 +305,14 @@ class Settings(object): |
| # regexp matching the git-svn line that contains the URL. |
| git_svn_re = re.compile(r'^\s*git-svn-id: (\S+)@', re.MULTILINE) |
| + env = os.environ |
|
M-A Ruel
2013/07/08 19:10:50
env = os.environ.copy()
Daniel Bratell
2013/07/08 22:08:06
I considered it but it's not really necessary sinc
M-A Ruel
2013/07/08 22:15:13
First rule of maintainability is to not mutate glo
|
| + env['GIT_PAGER'] = 'cat' # Magical string that disables pagers. |
|
M-A Ruel
2013/07/08 19:10:50
Comment on its own line.
|
| + |
| # We don't want to go through all of history, so read a line from the |
| # pipe at a time. |
| # The -100 is an arbitrary limit so we don't search forever. |
| - cmd = ['git', '--no-pager', 'log', '-100', '--pretty=medium'] |
| - proc = subprocess2.Popen(cmd, stdout=subprocess2.PIPE) |
| + cmd = ['git', 'log', '-100', '--pretty=medium'] |
| + proc = subprocess2.Popen(cmd, stdout=subprocess2.PIPE, env=env) |
| url = None |
| for line in proc.stdout: |
| match = git_svn_re.match(line) |
| @@ -684,13 +691,16 @@ or verify this branch is set up to track another (via the --track argument to |
| if not self.GitSanityChecks(upstream_branch): |
| DieWithError('\nGit sanity check failure') |
| - root = RunCommand(['git', '--no-pager', 'rev-parse', '--show-cdup']).strip() |
| + env = os.environ |
|
M-A Ruel
2013/07/08 19:10:50
same
|
| + env['GIT_PAGER'] = 'cat' # Magical string that disables pagers. |
| + |
| + root = RunCommand(['git', 'rev-parse', '--show-cdup'], env=env).strip() |
| if not root: |
| root = '.' |
| absroot = os.path.abspath(root) |
| # We use the sha1 of HEAD as a name of this change. |
| - name = RunCommand(['git', '--no-pager', 'rev-parse', 'HEAD']).strip() |
| + name = RunCommand(['git', 'rev-parse', 'HEAD'], env=env).strip() |
| # Need to pass a relative path for msysgit. |
| try: |
| files = scm.GIT.CaptureStatus([root], '.', upstream_branch) |
| @@ -711,9 +721,10 @@ or verify this branch is set up to track another (via the --track argument to |
| # If the change was never uploaded, use the log messages of all commits |
| # up to the branch point, as git cl upload will prefill the description |
| # with these log messages. |
| - description = RunCommand(['git', '--no-pager', |
| + description = RunCommand(['git', |
| 'log', '--pretty=format:%s%n%n%b', |
| - '%s...' % (upstream_branch)]).strip() |
| + '%s...' % (upstream_branch)], |
| + env=env).strip() |
| if not author: |
| author = RunGit(['config', 'user.email']).strip() or None |
| @@ -1751,14 +1762,18 @@ def CMDpatch(parser, args): |
| except subprocess2.CalledProcessError: |
| DieWithError('Git patch mungling failed.') |
| logging.info(patch_data) |
| + env = os.environ |
|
M-A Ruel
2013/07/08 19:10:50
same
|
| + env['GIT_PAGER'] = 'cat' # Magical string that disables pagers. |
| + |
| # We use "git apply" to apply the patch instead of "patch" so that we can |
| # pick up file adds. |
| # The --index flag means: also insert into the index (so we catch adds). |
| - cmd = ['git', '--no-pager', 'apply', '--index', '-p0'] |
| + cmd = ['git', 'apply', '--index', '-p0'] |
| if options.reject: |
| cmd.append('--reject') |
| try: |
| - subprocess2.check_call(cmd, stdin=patch_data, stdout=subprocess2.VOID) |
| + subprocess2.check_call(cmd, env=env, |
| + stdin=patch_data, stdout=subprocess2.VOID) |
| except subprocess2.CalledProcessError: |
| DieWithError('Failed to apply the patch') |
| @@ -1780,7 +1795,10 @@ def CMDrebase(parser, args): |
| # git svn dcommit. |
| # It's the only command that doesn't use parser at all since we just defer |
| # execution to git-svn. |
| - return subprocess2.call(['git', '--no-pager', 'svn', 'rebase'] + args) |
| + env = os.environ |
|
M-A Ruel
2013/07/08 19:10:50
same
|
| + env['GIT_PAGER'] = 'cat' # Magical string that disables pagers. |
| + |
| + return subprocess2.call(['git', 'svn', 'rebase'] + args, env=env) |
| def GetTreeStatus(): |