diff options
author | Shawn O. Pearce <sop@google.com> | 2010-12-07 10:31:19 -0800 |
---|---|---|
committer | Shawn O. Pearce <sop@google.com> | 2010-12-07 11:13:29 -0800 |
commit | 13f3da50d40b89ee5b05f5f3de9542c20edac6d1 (patch) | |
tree | d085b6f6b498bde85a1969fce884dd24e88d03d5 /git_command.py | |
parent | 3218c13205694434edb2375ab8a8515554eed366 (diff) | |
parent | 2b8db3ce3e7344b9f3b5216637c5af0d54be5656 (diff) | |
download | git-repo-13f3da50d40b89ee5b05f5f3de9542c20edac6d1.tar.gz |
Merge branch 'stable'
* stable: (33 commits)
Added feature to print a <notice> from manifest at the end of a sync.
sync: Use --force-broken to continue other projects
upload: Remove --replace option
sync --quiet: be more quiet
sync: Enable use of git clone --reference
Only delete corrupt pickle config files if they exist
Don't allow git fetch to start ControlMaster
Check for existing SSH ControlMaster
Fix for handling values of EDITOR which contain a space.
upload: Fix --replace flag
rebase: Pass through more options
upload: Allow review.HOST.username to override email
upload -t: Automatically include local branch name
Warn users before uploading if there are local changes
sync: Try fetching a tag as a last resort before giving up
rebase: Automatically rebase branch on upstrea
upload: Automatically --cc folks in review.URL.autocopy
Fix format string bugs in grep
Do not invoke ssh with -p argument when no port has been specified.
Allow files to be copied into new folders
...
Conflicts:
git_config.py
manifest_xml.py
subcmds/init.py
subcmds/sync.py
subcmds/upload.py
Change-Id: I4756a6908277e91505c35287a122a775b68f4df5
Diffstat (limited to 'git_command.py')
-rw-r--r-- | git_command.py | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/git_command.py b/git_command.py index 414c84a2..181e3724 100644 --- a/git_command.py +++ b/git_command.py | |||
@@ -17,6 +17,7 @@ import os | |||
17 | import sys | 17 | import sys |
18 | import subprocess | 18 | import subprocess |
19 | import tempfile | 19 | import tempfile |
20 | from signal import SIGTERM | ||
20 | from error import GitError | 21 | from error import GitError |
21 | from trace import REPO_TRACE, IsTrace, Trace | 22 | from trace import REPO_TRACE, IsTrace, Trace |
22 | 23 | ||
@@ -29,8 +30,9 @@ LAST_CWD = None | |||
29 | 30 | ||
30 | _ssh_proxy_path = None | 31 | _ssh_proxy_path = None |
31 | _ssh_sock_path = None | 32 | _ssh_sock_path = None |
33 | _ssh_clients = [] | ||
32 | 34 | ||
33 | def _ssh_sock(create=True): | 35 | def ssh_sock(create=True): |
34 | global _ssh_sock_path | 36 | global _ssh_sock_path |
35 | if _ssh_sock_path is None: | 37 | if _ssh_sock_path is None: |
36 | if not create: | 38 | if not create: |
@@ -51,6 +53,24 @@ def _ssh_proxy(): | |||
51 | 'git_ssh') | 53 | 'git_ssh') |
52 | return _ssh_proxy_path | 54 | return _ssh_proxy_path |
53 | 55 | ||
56 | def _add_ssh_client(p): | ||
57 | _ssh_clients.append(p) | ||
58 | |||
59 | def _remove_ssh_client(p): | ||
60 | try: | ||
61 | _ssh_clients.remove(p) | ||
62 | except ValueError: | ||
63 | pass | ||
64 | |||
65 | def terminate_ssh_clients(): | ||
66 | global _ssh_clients | ||
67 | for p in _ssh_clients: | ||
68 | try: | ||
69 | os.kill(p.pid, SIGTERM) | ||
70 | p.wait() | ||
71 | except OSError: | ||
72 | pass | ||
73 | _ssh_clients = [] | ||
54 | 74 | ||
55 | class _GitCall(object): | 75 | class _GitCall(object): |
56 | def version(self): | 76 | def version(self): |
@@ -119,7 +139,7 @@ class GitCommand(object): | |||
119 | if disable_editor: | 139 | if disable_editor: |
120 | env['GIT_EDITOR'] = ':' | 140 | env['GIT_EDITOR'] = ':' |
121 | if ssh_proxy: | 141 | if ssh_proxy: |
122 | env['REPO_SSH_SOCK'] = _ssh_sock() | 142 | env['REPO_SSH_SOCK'] = ssh_sock() |
123 | env['GIT_SSH'] = _ssh_proxy() | 143 | env['GIT_SSH'] = _ssh_proxy() |
124 | 144 | ||
125 | if project: | 145 | if project: |
@@ -188,6 +208,9 @@ class GitCommand(object): | |||
188 | except Exception, e: | 208 | except Exception, e: |
189 | raise GitError('%s: %s' % (command[1], e)) | 209 | raise GitError('%s: %s' % (command[1], e)) |
190 | 210 | ||
211 | if ssh_proxy: | ||
212 | _add_ssh_client(p) | ||
213 | |||
191 | self.process = p | 214 | self.process = p |
192 | self.stdin = p.stdin | 215 | self.stdin = p.stdin |
193 | 216 | ||
@@ -210,4 +233,8 @@ class GitCommand(object): | |||
210 | else: | 233 | else: |
211 | p.stderr = None | 234 | p.stderr = None |
212 | 235 | ||
213 | return self.process.wait() | 236 | try: |
237 | rc = p.wait() | ||
238 | finally: | ||
239 | _remove_ssh_client(p) | ||
240 | return rc | ||