33#
44# This module is part of GitPython and is released under
55# the BSD License: http://www.opensource.org/licenses/bsd-license.php
6- import tempfile
7- import os
8- import sys
9- import subprocess
106import glob
117from io import BytesIO
12-
8+ import os
139from stat import S_ISLNK
10+ import subprocess
11+ import sys
12+ import tempfile
1413
15- from .typ import (
16- BaseIndexEntry ,
17- IndexEntry ,
18- )
19-
20- from .util import (
21- TemporaryFileSwap ,
22- post_clear_cache ,
23- default_index ,
24- git_working_dir
14+ from git .compat import (
15+ izip ,
16+ xrange ,
17+ string_types ,
18+ force_bytes ,
19+ defenc ,
20+ mviter ,
21+ is_win
2522)
26-
27- import git .diff as diff
2823from git .exc import (
2924 GitCommandError ,
3025 CheckoutError ,
3126 InvalidGitRepositoryError
3227)
33-
3428from git .objects import (
3529 Blob ,
3630 Submodule ,
3731 Tree ,
3832 Object ,
3933 Commit ,
4034)
41-
4235from git .objects .util import Serializable
43- from git .compat import (
44- izip ,
45- xrange ,
46- string_types ,
47- force_bytes ,
48- defenc ,
49- mviter ,
50- is_win
51- )
52-
5336from git .util import (
5437 LazyMixin ,
5538 LockedFD ,
5841 to_native_path_linux ,
5942 unbare_repo
6043)
44+ from gitdb .base import IStream
45+ from gitdb .db import MemoryDB
46+ from gitdb .util import to_bin_sha
47+
48+ import git .diff as diff
49+ import os .path as osp
6150
6251from .fun import (
6352 entry_key ,
6958 S_IFGITLINK ,
7059 run_commit_hook
7160)
61+ from .typ import (
62+ BaseIndexEntry ,
63+ IndexEntry ,
64+ )
65+ from .util import (
66+ TemporaryFileSwap ,
67+ post_clear_cache ,
68+ default_index ,
69+ git_working_dir
70+ )
7271
73- from gitdb .base import IStream
74- from gitdb .db import MemoryDB
75- from gitdb .util import to_bin_sha
7672
7773__all__ = ('IndexFile' , 'CheckoutError' )
7874
@@ -354,7 +350,7 @@ def from_tree(cls, repo, *treeish, **kwargs):
354350 index .entries # force it to read the file as we will delete the temp-file
355351 del (index_handler ) # release as soon as possible
356352 finally :
357- if os . path .exists (tmp_index ):
353+ if osp .exists (tmp_index ):
358354 os .remove (tmp_index )
359355 # END index merge handling
360356
@@ -374,8 +370,8 @@ def raise_exc(e):
374370 rs = r + os .sep
375371 for path in paths :
376372 abs_path = path
377- if not os . path .isabs (abs_path ):
378- abs_path = os . path .join (r , path )
373+ if not osp .isabs (abs_path ):
374+ abs_path = osp .join (r , path )
379375 # END make absolute path
380376
381377 try :
@@ -407,7 +403,7 @@ def raise_exc(e):
407403 for root , dirs , files in os .walk (abs_path , onerror = raise_exc ): # @UnusedVariable
408404 for rela_file in files :
409405 # add relative paths only
410- yield os . path .join (root .replace (rs , '' ), rela_file )
406+ yield osp .join (root .replace (rs , '' ), rela_file )
411407 # END for each file in subdir
412408 # END for each subdirectory
413409 except OSError :
@@ -569,7 +565,7 @@ def _process_diff_args(self, args):
569565 def _to_relative_path (self , path ):
570566 """:return: Version of path relative to our git directory or raise ValueError
571567 if it is not within our git direcotory"""
572- if not os . path .isabs (path ):
568+ if not osp .isabs (path ):
573569 return path
574570 if self .repo .bare :
575571 raise InvalidGitRepositoryError ("require non-bare repository" )
@@ -617,12 +613,12 @@ def _entries_for_paths(self, paths, path_rewriter, fprogress, entries):
617613 entries_added = list ()
618614 if path_rewriter :
619615 for path in paths :
620- if os . path .isabs (path ):
616+ if osp .isabs (path ):
621617 abspath = path
622618 gitrelative_path = path [len (self .repo .working_tree_dir ) + 1 :]
623619 else :
624620 gitrelative_path = path
625- abspath = os . path .join (self .repo .working_tree_dir , gitrelative_path )
621+ abspath = osp .join (self .repo .working_tree_dir , gitrelative_path )
626622 # end obtain relative and absolute paths
627623
628624 blob = Blob (self .repo , Blob .NULL_BIN_SHA ,
0 commit comments