cygwin, #533: Try to make it work with Cygwin's Git. · gitpython-developers/GitPython@e6e23ed

@@ -4,51 +4,21 @@

44

# This module is part of GitPython and is released under

55

# the BSD License: http://www.opensource.org/licenses/bsd-license.php

667-

from git.exc import (

8-

InvalidGitRepositoryError,

9-

NoSuchPathError,

10-

GitCommandError

11-

)

12-

from git.cmd import (

13-

Git,

14-

handle_process_output

15-

)

16-

from git.refs import (

17-

HEAD,

18-

Head,

19-

Reference,

20-

TagReference,

21-

)

22-

from git.objects import (

23-

Submodule,

24-

RootModule,

25-

Commit

26-

)

27-

from git.util import (

28-

Actor,

29-

finalize_process

30-

)

31-

from git.index import IndexFile

32-

from git.config import GitConfigParser

33-

from git.remote import (

34-

Remote,

35-

add_progress,

36-

to_progress_instance

37-

)

38-39-

from git.db import GitCmdObjectDB

7+

from collections import namedtuple

8+

import logging

9+

import os

10+

import re

11+

import sys

40124113

from gitdb.util import (

4214

join,

4315

isfile,

4416

hex_to_bin

4517

)

461847-

from .fun import (

48-

rev_parse,

49-

is_git_dir,

50-

find_git_dir,

51-

touch,

19+

from git.cmd import (

20+

Git,

21+

handle_process_output

5222

)

5323

from git.compat import (

5424

text_type,

@@ -58,12 +28,17 @@

5828

range,

5929

is_win,

6030

)

31+

from git.config import GitConfigParser

32+

from git.db import GitCmdObjectDB

33+

from git.exc import InvalidGitRepositoryError, NoSuchPathError, GitCommandError

34+

from git.index import IndexFile

35+

from git.objects import Submodule, RootModule, Commit

36+

from git.refs import HEAD, Head, Reference, TagReference

37+

from git.remote import Remote, add_progress, to_progress_instance

38+

from git.util import Actor, finalize_process

39+40+

from .fun import rev_parse, is_git_dir, find_git_dir, touch

614162-

import os

63-

import sys

64-

import re

65-

import logging

66-

from collections import namedtuple

67426843

log = logging.getLogger(__name__)

6944

@@ -875,12 +850,22 @@ def _clone(cls, git, url, path, odb_default_type, progress, **kwargs):

875850

progress = to_progress_instance(progress)

876851877852

odbt = kwargs.pop('odbt', odb_default_type)

878-

proc = git.clone(url, path, with_extended_output=True, as_process=True,

853+854+

## A bug win cygwin's Git, when `--bare`

855+

# it prepends the basename of the `url` into the `path::

856+

# git clone --bare /cygwin/a/foo.git C:\\Work

857+

# becomes::

858+

# git clone --bare /cygwin/a/foo.git /cygwin/a/C:\\Work

859+

#

860+

clone_path = (Git.polish_url(path)

861+

if Git.is_cygwin() and 'bare' in kwargs

862+

else path)

863+

proc = git.clone(Git.polish_url(url), clone_path, with_extended_output=True, as_process=True,

879864

v=True, **add_progress(kwargs, git, progress))

880865

if progress:

881866

handle_process_output(proc, None, progress.new_message_handler(), finalize_process)

882867

else:

883-

(stdout, stderr) = proc.communicate() # FIXME: Will block of outputs are big!

868+

(stdout, stderr) = proc.communicate() # FIXME: Will block if outputs are big!

884869

log.debug("Cmd(%s)'s unused stdout: %s", getattr(proc, 'args', ''), stdout)

885870

finalize_process(proc, stderr=stderr)

886871