summaryrefslogtreecommitdiff
path: root/git/repo/base.py
diff options
context:
space:
mode:
Diffstat (limited to 'git/repo/base.py')
-rw-r--r--git/repo/base.py26
1 files changed, 21 insertions, 5 deletions
diff --git a/git/repo/base.py b/git/repo/base.py
index d3bdc983..990def64 100644
--- a/git/repo/base.py
+++ b/git/repo/base.py
@@ -209,9 +209,17 @@ class Repo(object):
def close(self):
if self.git:
self.git.clear_cache()
- gc.collect()
+ # Tempfiles objects on Windows are holding references to
+ # open files until they are collected by the garbage
+ # collector, thus preventing deletion.
+ # TODO: Find these references and ensure they are closed
+ # and deleted synchronously rather than forcing a gc
+ # collection.
+ if is_win:
+ gc.collect()
gitdb.util.mman.collect()
- gc.collect()
+ if is_win:
+ gc.collect()
def __eq__(self, rhs):
if isinstance(rhs, Repo):
@@ -905,6 +913,10 @@ class Repo(object):
odbt = kwargs.pop('odbt', odb_default_type)
+ # when pathlib.Path or other classbased path is passed
+ if not isinstance(path, str):
+ path = str(path)
+
## A bug win cygwin's Git, when `--bare` or `--separate-git-dir`
# it prepends the cwd or(?) the `url` into the `path, so::
# git clone --bare /cygwin/d/foo.git C:\\Work
@@ -918,9 +930,9 @@ class Repo(object):
if sep_dir:
kwargs['separate_git_dir'] = Git.polish_url(sep_dir)
proc = git.clone(Git.polish_url(url), clone_path, with_extended_output=True, as_process=True,
- v=True, **add_progress(kwargs, git, progress))
+ v=True, universal_newlines=True, **add_progress(kwargs, git, progress))
if progress:
- handle_process_output(proc, None, progress.new_message_handler(), finalize_process)
+ handle_process_output(proc, None, progress.new_message_handler(), finalize_process, decode_streams=False)
else:
(stdout, stderr) = proc.communicate()
log.debug("Cmd(%s)'s unused stdout: %s", getattr(proc, 'args', ''), stdout)
@@ -931,12 +943,16 @@ class Repo(object):
if not osp.isabs(path) and git.working_dir:
path = osp.join(git._working_dir, path)
+ repo = cls(path, odbt=odbt)
+
+ # retain env values that were passed to _clone()
+ repo.git.update_environment(**git.environment())
+
# adjust remotes - there may be operating systems which use backslashes,
# These might be given as initial paths, but when handling the config file
# that contains the remote from which we were clones, git stops liking it
# as it will escape the backslashes. Hence we undo the escaping just to be
# sure
- repo = cls(path, odbt=odbt)
if repo.remotes:
with repo.remotes[0].config_writer as writer:
writer.set_value('url', Git.polish_url(repo.remotes[0].url))