diff options
author | Kostis Anagnostopoulos <ankostis@gmail.com> | 2016-09-26 20:41:41 +0200 |
---|---|---|
committer | Kostis Anagnostopoulos <ankostis@gmail.com> | 2016-09-27 12:37:16 +0200 |
commit | f495e94028bfddc264727ffc464cd694ddd05ab8 (patch) | |
tree | 8c0bf309b08576f96c9344d9937344e1447d2237 /git/index | |
parent | 29eb301700c41f0af7d57d923ad069cbdf636381 (diff) | |
download | gitpython-f495e94028bfddc264727ffc464cd694ddd05ab8.tar.gz |
src, #519: collect all is_<platform>() calls
Diffstat (limited to 'git/index')
-rw-r--r-- | git/index/base.py | 7 | ||||
-rw-r--r-- | git/index/fun.py | 5 | ||||
-rw-r--r-- | git/index/util.py | 3 |
3 files changed, 9 insertions, 6 deletions
diff --git a/git/index/base.py b/git/index/base.py index 86eda41e..82df361f 100644 --- a/git/index/base.py +++ b/git/index/base.py @@ -46,7 +46,8 @@ from git.compat import ( string_types, force_bytes, defenc, - mviter + mviter, + is_win ) from git.util import ( @@ -136,7 +137,7 @@ class IndexFile(LazyMixin, diff.Diffable, Serializable): # which happens during read-tree. # In this case, we will just read the memory in directly. # Its insanely bad ... I am disappointed ! - allow_mmap = (os.name != 'nt' or sys.version_info[1] > 5) + allow_mmap = (is_win() or sys.version_info[1] > 5) stream = file_contents_ro(fd, stream=True, allow_mmap=allow_mmap) try: @@ -1059,7 +1060,7 @@ class IndexFile(LazyMixin, diff.Diffable, Serializable): # END for each possible ending # END for each line if unknown_lines: - raise GitCommandError(("git-checkout-index", ), 128, stderr) + raise GitCommandError(("git-checkout-index",), 128, stderr) if failed_files: valid_files = list(set(iter_checked_out_files) - set(failed_files)) raise CheckoutError( diff --git a/git/index/fun.py b/git/index/fun.py index 818847a2..98e2d3a0 100644 --- a/git/index/fun.py +++ b/git/index/fun.py @@ -43,7 +43,8 @@ from gitdb.typ import str_tree_type from git.compat import ( defenc, force_text, - force_bytes + force_bytes, + is_posix, ) S_IFGITLINK = S_IFLNK | S_IFDIR # a submodule @@ -75,7 +76,7 @@ def run_commit_hook(name, index): stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=index.repo.working_dir, - close_fds=(os.name == 'posix'), + close_fds=(is_posix()), universal_newlines=True, creationflags=PROC_CREATIONFLAGS,) stdout, stderr = cmd.communicate() diff --git a/git/index/util.py b/git/index/util.py index 171bd8fc..0340500c 100644 --- a/git/index/util.py +++ b/git/index/util.py @@ -2,6 +2,7 @@ import struct import tempfile import os +from git.compat import is_win __all__ = ('TemporaryFileSwap', 'post_clear_cache', 'default_index', 'git_working_dir') @@ -29,7 +30,7 @@ class TemporaryFileSwap(object): def __del__(self): if os.path.isfile(self.tmp_file_path): - if os.name == 'nt' and os.path.exists(self.file_path): + if is_win and os.path.exists(self.file_path): os.remove(self.file_path) os.rename(self.tmp_file_path, self.file_path) # END temp file exists |