From 0210e394e0776d0b7097bf666bebd690ed0c0e4f Mon Sep 17 00:00:00 2001 From: Kostis Anagnostopoulos Date: Sat, 15 Oct 2016 13:11:16 +0200 Subject: src: import os.path as osp --- git/repo/fun.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'git/repo/fun.py') diff --git a/git/repo/fun.py b/git/repo/fun.py index 320eb1c8..c770fd43 100644 --- a/git/repo/fun.py +++ b/git/repo/fun.py @@ -2,12 +2,14 @@ import os from string import digits +from git.compat import xrange +from git.exc import WorkTreeRepositoryUnsupported +from git.objects import Object +from git.refs import SymbolicReference from gitdb.exc import ( BadObject, BadName, ) -from git.refs import SymbolicReference -from git.objects import Object from gitdb.util import ( join, isdir, @@ -16,8 +18,8 @@ from gitdb.util import ( hex_to_bin, bin_to_hex ) -from git.exc import WorkTreeRepositoryUnsupported -from git.compat import xrange + +import os.path as osp __all__ = ('rev_parse', 'is_git_dir', 'touch', 'find_git_dir', 'name_to_object', 'short_to_long', 'deref_tag', @@ -42,7 +44,7 @@ def is_git_dir(d): if isdir(join(d, 'objects')) and isdir(join(d, 'refs')): headref = join(d, 'HEAD') return isfile(headref) or \ - (os.path.islink(headref) and + (osp.islink(headref) and os.readlink(headref).startswith('refs')) elif isfile(join(d, 'gitdir')) and isfile(join(d, 'commondir')) and isfile(join(d, 'gitfile')): raise WorkTreeRepositoryUnsupported(d) @@ -62,7 +64,7 @@ def find_git_dir(d): else: if content.startswith('gitdir: '): path = content[8:] - if not os.path.isabs(path): + if not osp.isabs(path): path = join(dirname(d), path) return find_git_dir(path) # end handle exception -- cgit v1.2.3 From b02662d4e870a34d2c6d97d4f702fcc1311e5177 Mon Sep 17 00:00:00 2001 From: Kostis Anagnostopoulos Date: Sat, 15 Oct 2016 13:42:33 +0200 Subject: src: reduce needless deps to `gitdb.util` --- git/repo/fun.py | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) (limited to 'git/repo/fun.py') diff --git a/git/repo/fun.py b/git/repo/fun.py index c770fd43..5fe8682d 100644 --- a/git/repo/fun.py +++ b/git/repo/fun.py @@ -6,18 +6,11 @@ from git.compat import xrange 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 gitdb.exc import ( BadObject, BadName, ) -from gitdb.util import ( - join, - isdir, - isfile, - dirname, - hex_to_bin, - bin_to_hex -) import os.path as osp @@ -40,13 +33,15 @@ def is_git_dir(d): but at least clearly indicates that we don't support it. There is the unlikely danger to throw if we see directories which just look like a worktree dir, but are none.""" - if isdir(d): - if isdir(join(d, 'objects')) and isdir(join(d, 'refs')): - headref = join(d, 'HEAD') - return isfile(headref) or \ + if osp.isdir(d): + if osp.isdir(osp.join(d, 'objects')) and osp.isdir(osp.join(d, 'refs')): + headref = osp.join(d, 'HEAD') + return osp.isfile(headref) or \ (osp.islink(headref) and os.readlink(headref).startswith('refs')) - elif isfile(join(d, 'gitdir')) and isfile(join(d, 'commondir')) and isfile(join(d, 'gitfile')): + elif (osp.isfile(osp.join(d, 'gitdir')) and + osp.isfile(osp.join(d, 'commondir')) and + osp.isfile(osp.join(d, 'gitfile'))): raise WorkTreeRepositoryUnsupported(d) return False @@ -65,7 +60,7 @@ def find_git_dir(d): if content.startswith('gitdir: '): path = content[8:] if not osp.isabs(path): - path = join(dirname(d), path) + path = osp.join(osp.dirname(d), path) return find_git_dir(path) # end handle exception return None -- cgit v1.2.3 From b2efa1b19061ad6ed9d683ba98a88b18bff3bfd9 Mon Sep 17 00:00:00 2001 From: Kostis Anagnostopoulos Date: Sun, 16 Oct 2016 02:44:37 +0200 Subject: cygwin, #533: FIX submodules detection (~10TCs fixed) + Decygpath sm's `.git` file contents. + Polish another path in `git add`; actually no main-code changes, just a replace \-->/ on a relative(!) path to make cygwin-git to work. - REGRESSION `test_git_submodules_and_add_sm_with_new_commit` asks for user/email settings. - Cygwin TCs failing: - PY2: err: 2, fail: 1 - PY3: err: 2, fail: 1 --- git/repo/fun.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'git/repo/fun.py') diff --git a/git/repo/fun.py b/git/repo/fun.py index 5fe8682d..7ea45e6b 100644 --- a/git/repo/fun.py +++ b/git/repo/fun.py @@ -6,13 +6,14 @@ from git.compat import xrange 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) -- cgit v1.2.3