diff options
| -rw-r--r-- | AUTHORS | 1 | ||||
| -rw-r--r-- | git/refs/symbolic.py | 10 | ||||
| -rw-r--r-- | git/repo/base.py | 20 | ||||
| -rw-r--r-- | git/test/test_repo.py | 14 |
4 files changed, 40 insertions, 5 deletions
@@ -23,5 +23,6 @@ Contributors are: -Ken Odegard <ken.odegard _at_ gmail.com> -Alexis Horgix Chotard -Piotr Babij <piotr.babij _at_ gmail.com> +-Mikuláš Poul <mikulaspoul _at_ gmail.com> Portions derived from other open source works and are clearly marked. diff --git a/git/refs/symbolic.py b/git/refs/symbolic.py index bef6ba3c..8efeafc5 100644 --- a/git/refs/symbolic.py +++ b/git/refs/symbolic.py @@ -96,7 +96,15 @@ class SymbolicReference(object): if not line: continue if line.startswith('#'): - if line.startswith('# pack-refs with:') and not line.endswith('peeled'): + # "# pack-refs with: peeled fully-peeled sorted" + # the git source code shows "peeled", + # "fully-peeled" and "sorted" as the keywords + # that can go on this line, as per comments in git file + # refs/packed-backend.c + # I looked at master on 2017-10-11, + # commit 111ef79afe, after tag v2.15.0-rc1 + # from repo https://github.com/git/git.git + if line.startswith('# pack-refs with:') and 'peeled' not in line: raise TypeError("PackingType of packed-Refs not understood: %r" % line) # END abort if we do not understand the packing scheme continue diff --git a/git/repo/base.py b/git/repo/base.py index 9ed3f714..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) diff --git a/git/test/test_repo.py b/git/test/test_repo.py index 86fb2f51..2c3ad957 100644 --- a/git/test/test_repo.py +++ b/git/test/test_repo.py @@ -16,6 +16,11 @@ try: except ImportError: from unittest2 import skipIf, SkipTest +try: + import pathlib +except ImportError: + pathlib = None + from git import ( InvalidGitRepositoryError, Repo, @@ -210,6 +215,15 @@ class TestRepo(TestBase): assert_equal(environment, cloned.git.environment()) + @with_rw_directory + def test_clone_from_pathlib(self, rw_dir): + if pathlib is None: # pythons bellow 3.4 don't have pathlib + raise SkipTest("pathlib was introduced in 3.4") + + original_repo = Repo.init(osp.join(rw_dir, "repo")) + + Repo.clone_from(original_repo.git_dir, pathlib.Path(rw_dir) / "clone_pathlib") + def test_init(self): prev_cwd = os.getcwd() os.chdir(tempfile.gettempdir()) |
