Skip to content

Support Cygwin's Git on Windows #533

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Oct 22, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 24 additions & 19 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,17 @@ environment:
IS_CONDA: "yes"
GIT_PATH: "%GIT_DAEMON_PATH%"

# ## Cygwin
# #
# - PYTHON: "C:\\Miniconda-x64"
# PYTHON_VERSION: "2.7"
# IS_CONDA: "yes"
# GIT_PATH: "%CYGWIN_GIT_PATH%"
# - PYTHON: "C:\\Python34-x64"
# PYTHON_VERSION: "3.4"
# GIT_PATH: "%CYGWIN_GIT_PATH%"
# - PYTHON: "C:\\Python35-x64"
# PYTHON_VERSION: "3.5"
# GIT_PATH: "%CYGWIN64_GIT_PATH%"
## Cygwin
#
- PYTHON: "C:\\Miniconda-x64"
PYTHON_VERSION: "2.7"
IS_CONDA: "yes"
IS_CYGWIN: "yes"
GIT_PATH: "%CYGWIN_GIT_PATH%"
- PYTHON: "C:\\Python35-x64"
PYTHON_VERSION: "3.5"
GIT_PATH: "%CYGWIN64_GIT_PATH%"
IS_CYGWIN: "yes"


install:
Expand All @@ -48,14 +47,12 @@ install:
python --version
python -c "import struct; print(struct.calcsize('P') * 8)"

- IF "%IS_CONDA%"=="yes" (
- IF "%IS_CONDA%" == "yes" (
conda info -a &
conda install --yes --quiet pip
)
- pip install nose ddt wheel codecov
- IF "%PYTHON_VERSION%"=="2.7" (
pip install mock
)
- pip install -r test-requirements.txt
- pip install codecov

## Copied from `init-tests-after-clone.sh`.
#
Expand All @@ -79,7 +76,15 @@ install:
build: false

test_script:
- IF "%PYTHON_VERSION%"=="3.5" (nosetests -v --with-coverage) ELSE (nosetests -v)
- IF "%IS_CYGWIN%" == "yes" (
nosetests -v
) ELSE (
IF "%PYTHON_VERSION%" == "3.5" (
nosetests -v --with-coverage
) ELSE (
nosetests -v
)
)

on_success:
- IF "%PYTHON_VERSION%"=="3.5" (codecov)
- IF "%PYTHON_VERSION%" == "3.5" IF NOT "%IS_CYGWIN%" == "yes" (codecov)
7 changes: 2 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
language: python
python:
- "2.6"
- "2.7"
- "3.3"
- "3.4"
- "3.5"
# - "pypy" - won't work as smmap doesn't work (see gitdb/.travis.yml for details)
matrix:
allow_failures:
- python: "2.6"
git:
# a higher depth is needed for most of the tests - must be high enough to not actually be shallow
# as we clone our own repository in the process
Expand All @@ -17,7 +13,8 @@ install:
- python --version; git --version
- git submodule update --init --recursive
- git fetch --tags
- pip install codecov flake8 ddt sphinx
- pip install -r test-requirements.txt
- pip install codecov sphinx

# generate some reflog as git-python tests need it (in master)
- ./init-tests-after-clone.sh
Expand Down
7 changes: 5 additions & 2 deletions git/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
# flake8: noqa
#@PydevCodeAnalysisIgnore
import inspect
import os
import sys
import inspect

import os.path as osp


__version__ = 'git'

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

try:
import gitdb
Expand Down
23 changes: 21 additions & 2 deletions git/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
)
from git.exc import CommandError
from git.odict import OrderedDict
from git.util import is_cygwin_git, cygpath

from .exc import (
GitCommandError,
Expand Down Expand Up @@ -191,8 +192,26 @@ def __setstate__(self, d):
USE_SHELL = False

@classmethod
def polish_url(cls, url):
return url.replace("\\\\", "\\").replace("\\", "/")
def is_cygwin(cls):
return is_cygwin_git(cls.GIT_PYTHON_GIT_EXECUTABLE)

@classmethod
def polish_url(cls, url, is_cygwin=None):
if is_cygwin is None:
is_cygwin = cls.is_cygwin()

if is_cygwin:
url = cygpath(url)
else:
"""Remove any backslahes from urls to be written in config files.

Windows might create config-files containing paths with backslashed,
but git stops liking them as it will escape the backslashes.
Hence we undo the escaping just to be sure.
"""
url = url.replace("\\\\", "\\").replace("\\", "/")

return url

class AutoInterrupt(object):
"""Kill/Interrupt the stored process instance once this instance goes out of scope. It is
Expand Down
36 changes: 20 additions & 16 deletions git/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,13 @@
"""Module containing module parser implementation able to properly read and write
configuration files"""

import re
try:
import ConfigParser as cp
except ImportError:
# PY3
import configparser as cp
import abc
from functools import wraps
import inspect
import logging
import abc
import os
import re

from functools import wraps

from git.odict import OrderedDict
from git.util import LockFile
from git.compat import (
string_types,
FileType,
Expand All @@ -29,6 +21,18 @@
with_metaclass,
PY3
)
from git.odict import OrderedDict
from git.util import LockFile

import os.path as osp


try:
import ConfigParser as cp
except ImportError:
# PY3
import configparser as cp


__all__ = ('GitConfigParser', 'SectionConstraint')

Expand Down Expand Up @@ -408,15 +412,15 @@ def read(self):
if self._has_includes():
for _, include_path in self.items('include'):
if include_path.startswith('~'):
include_path = os.path.expanduser(include_path)
if not os.path.isabs(include_path):
include_path = osp.expanduser(include_path)
if not osp.isabs(include_path):
if not file_ok:
continue
# end ignore relative paths if we don't know the configuration file path
assert os.path.isabs(file_path), "Need absolute paths to be sure our cycle checks will work"
include_path = os.path.join(os.path.dirname(file_path), include_path)
assert osp.isabs(file_path), "Need absolute paths to be sure our cycle checks will work"
include_path = osp.join(osp.dirname(file_path), include_path)
# end make include path absolute
include_path = os.path.normpath(include_path)
include_path = osp.normpath(include_path)
if include_path in seen or not os.access(include_path, os.R_OK):
continue
seen.add(include_path)
Expand Down
5 changes: 1 addition & 4 deletions git/db.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
"""Module with our own gitdb implementation - it uses the git command"""
from git.util import bin_to_hex, hex_to_bin
from gitdb.base import (
OInfo,
OStream
)
from gitdb.util import (
bin_to_hex,
hex_to_bin
)
from gitdb.db import GitDB # @UnusedImport
from gitdb.db import LooseObjectDB

Expand Down
13 changes: 6 additions & 7 deletions git/diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,17 @@
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
import re

from gitdb.util import hex_to_bin
from git.cmd import handle_process_output
from git.compat import (
defenc,
PY3
)
from git.util import finalize_process, hex_to_bin

from .compat import binary_type
from .objects.blob import Blob
from .objects.util import mode_str_to_int

from git.compat import (
defenc,
PY3
)
from git.cmd import handle_process_output
from git.util import finalize_process

__all__ = ('Diffable', 'DiffIndex', 'Diff', 'NULL_TREE')

Expand Down
2 changes: 1 addition & 1 deletion git/ext/gitdb
Loading