From 997ea34df16986d1d1ac35d7a1f4b0f1ae8c604d Mon Sep 17 00:00:00 2001 From: Kostis Anagnostopoulos Date: Sun, 16 Oct 2016 02:44:37 +0200 Subject: [PATCH] cygwin, #533: FIX submodules detection (~10TCs fixed) + Decygpath sm's `.git` file contents. - Cygwin TCs failing: - PY2: err: 2, fail: 2 - PY3: err: 2, fail: 2 --- git/repo/base.py | 2 +- git/repo/fun.py | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/git/repo/base.py b/git/repo/base.py index 20b3fa276..21d129e98 100644 --- a/git/repo/base.py +++ b/git/repo/base.py @@ -109,7 +109,7 @@ def __init__(self, path=None, odbt=DefaultDBType, search_parent_directories=Fals :raise InvalidGitRepositoryError: :raise NoSuchPathError: :return: git.Repo """ - if path and Git.is_cygwin(): + if Git.is_cygwin(): path = decygpath(path) epath = _expand_path(path or os.getcwd()) diff --git a/git/repo/fun.py b/git/repo/fun.py index 5fe8682d4..7ea45e6b7 100644 --- a/git/repo/fun.py +++ b/git/repo/fun.py @@ -6,13 +6,14 @@ from git.exc import WorkTreeRepositoryUnsupported from git.objects import Object from git.refs import SymbolicReference -from git.util import hex_to_bin, bin_to_hex +from git.util import hex_to_bin, bin_to_hex, decygpath from gitdb.exc import ( BadObject, BadName, ) import os.path as osp +from git.cmd import Git __all__ = ('rev_parse', 'is_git_dir', 'touch', 'find_git_dir', 'name_to_object', 'short_to_long', 'deref_tag', @@ -59,6 +60,9 @@ def find_git_dir(d): else: if content.startswith('gitdir: '): path = content[8:] + if Git.is_cygwin(): + ## Cygwin creates submodules prefixed with `/cygdrive/...` suffixes. + path = decygpath(path) if not osp.isabs(path): path = osp.join(osp.dirname(d), path) return find_git_dir(path)