Merge branch 'cygwin' of https://github.com/ankostis/GitPython into a… · gitpython-developers/GitPython@caa0ea7 · GitHub
Skip to content

Commit caa0ea7

Browse files
committed
Merge branch 'cygwin' of https://github.com/ankostis/GitPython into ankostis-cygwin
2 parents afcd64e + cc77e6b commit caa0ea7

44 files changed

Lines changed: 961 additions & 686 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.appveyor.yml

Lines changed: 24 additions & 19 deletions

.travis.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
language: python
22
python:
3-
- "2.6"
43
- "2.7"
54
- "3.3"
65
- "3.4"
76
- "3.5"
87
# - "pypy" - won't work as smmap doesn't work (see gitdb/.travis.yml for details)
9-
matrix:
10-
allow_failures:
11-
- python: "2.6"
128
git:
139
# a higher depth is needed for most of the tests - must be high enough to not actually be shallow
1410
# as we clone our own repository in the process
@@ -17,7 +13,8 @@ install:
1713
- python --version; git --version
1814
- git submodule update --init --recursive
1915
- git fetch --tags
20-
- pip install codecov flake8 ddt sphinx
16+
- pip install -r test-requirements.txt
17+
- pip install codecov sphinx
2118

2219
# generate some reflog as git-python tests need it (in master)
2320
- ./init-tests-after-clone.sh

git/__init__.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@
55
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
66
# flake8: noqa
77
#@PydevCodeAnalysisIgnore
8+
import inspect
89
import os
910
import sys
10-
import inspect
11+
12+
import os.path as osp
13+
1114

1215
__version__ = 'git'
1316

@@ -16,7 +19,7 @@
1619
def _init_externals():
1720
"""Initialize external projects by putting them into the path"""
1821
if __version__ == 'git':
19-
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'ext', 'gitdb'))
22+
sys.path.insert(0, osp.join(osp.dirname(__file__), 'ext', 'gitdb'))
2023

2124
try:
2225
import gitdb

git/cmd.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
)
3232
from git.exc import CommandError
3333
from git.odict import OrderedDict
34+
from git.util import is_cygwin_git, cygpath
3435

3536
from .exc import (
3637
GitCommandError,
@@ -191,8 +192,26 @@ def __setstate__(self, d):
191192
USE_SHELL = False
192193

193194
@classmethod
194-
def polish_url(cls, url):
195-
return url.replace("\\\\", "\\").replace("\\", "/")
195+
def is_cygwin(cls):
196+
return is_cygwin_git(cls.GIT_PYTHON_GIT_EXECUTABLE)
197+
198+
@classmethod
199+
def polish_url(cls, url, is_cygwin=None):
200+
if is_cygwin is None:
201+
is_cygwin = cls.is_cygwin()
202+
203+
if is_cygwin:
204+
url = cygpath(url)
205+
else:
206+
"""Remove any backslahes from urls to be written in config files.
207+
208+
Windows might create config-files containing paths with backslashed,
209+
but git stops liking them as it will escape the backslashes.
210+
Hence we undo the escaping just to be sure.
211+
"""
212+
url = url.replace("\\\\", "\\").replace("\\", "/")
213+
214+
return url
196215

197216
class AutoInterrupt(object):
198217
"""Kill/Interrupt the stored process instance once this instance goes out of scope. It is

git/config.py

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,13 @@
66
"""Module containing module parser implementation able to properly read and write
77
configuration files"""
88

9-
import re
10-
try:
11-
import ConfigParser as cp
12-
except ImportError:
13-
# PY3
14-
import configparser as cp
9+
import abc
10+
from functools import wraps
1511
import inspect
1612
import logging
17-
import abc
1813
import os
14+
import re
1915

20-
from functools import wraps
21-
22-
from git.odict import OrderedDict
23-
from git.util import LockFile
2416
from git.compat import (
2517
string_types,
2618
FileType,
@@ -29,6 +21,18 @@
2921
with_metaclass,
3022
PY3
3123
)
24+
from git.odict import OrderedDict
25+
from git.util import LockFile
26+
27+
import os.path as osp
28+
29+
30+
try:
31+
import ConfigParser as cp
32+
except ImportError:
33+
# PY3
34+
import configparser as cp
35+
3236

3337
__all__ = ('GitConfigParser', 'SectionConstraint')
3438

@@ -408,15 +412,15 @@ def read(self):
408412
if self._has_includes():
409413
for _, include_path in self.items('include'):
410414
if include_path.startswith('~'):
411-
include_path = os.path.expanduser(include_path)
412-
if not os.path.isabs(include_path):
415+
include_path = osp.expanduser(include_path)
416+
if not osp.isabs(include_path):
413417
if not file_ok:
414418
continue
415419
# end ignore relative paths if we don't know the configuration file path
416-
assert os.path.isabs(file_path), "Need absolute paths to be sure our cycle checks will work"
417-
include_path = os.path.join(os.path.dirname(file_path), include_path)
420+
assert osp.isabs(file_path), "Need absolute paths to be sure our cycle checks will work"
421+
include_path = osp.join(osp.dirname(file_path), include_path)
418422
# end make include path absolute
419-
include_path = os.path.normpath(include_path)
423+
include_path = osp.normpath(include_path)
420424
if include_path in seen or not os.access(include_path, os.R_OK):
421425
continue
422426
seen.add(include_path)

git/db.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
"""Module with our own gitdb implementation - it uses the git command"""
2+
from git.util import bin_to_hex, hex_to_bin
23
from gitdb.base import (
34
OInfo,
45
OStream
56
)
6-
from gitdb.util import (
7-
bin_to_hex,
8-
hex_to_bin
9-
)
107
from gitdb.db import GitDB # @UnusedImport
118
from gitdb.db import LooseObjectDB
129

git/diff.py

Lines changed: 6 additions & 7 deletions

0 commit comments

Comments
 (0)