3
3
#
4
4
# This module is part of GitPython and is released under
5
5
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
6
- import tempfile
7
- import os
8
- import sys
9
- import subprocess
10
6
import glob
11
7
from io import BytesIO
12
-
8
+ import os
13
9
from stat import S_ISLNK
10
+ import subprocess
11
+ import sys
12
+ import tempfile
14
13
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
25
22
)
26
-
27
- import git .diff as diff
28
23
from git .exc import (
29
24
GitCommandError ,
30
25
CheckoutError ,
31
26
InvalidGitRepositoryError
32
27
)
33
-
34
28
from git .objects import (
35
29
Blob ,
36
30
Submodule ,
37
31
Tree ,
38
32
Object ,
39
33
Commit ,
40
34
)
41
-
42
35
from 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
-
53
36
from git .util import (
54
37
LazyMixin ,
55
38
LockedFD ,
58
41
to_native_path_linux ,
59
42
unbare_repo
60
43
)
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
61
50
62
51
from .fun import (
63
52
entry_key ,
69
58
S_IFGITLINK ,
70
59
run_commit_hook
71
60
)
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
+ )
72
71
73
- from gitdb .base import IStream
74
- from gitdb .db import MemoryDB
75
- from gitdb .util import to_bin_sha
76
72
77
73
__all__ = ('IndexFile' , 'CheckoutError' )
78
74
@@ -354,7 +350,7 @@ def from_tree(cls, repo, *treeish, **kwargs):
354
350
index .entries # force it to read the file as we will delete the temp-file
355
351
del (index_handler ) # release as soon as possible
356
352
finally :
357
- if os . path .exists (tmp_index ):
353
+ if osp .exists (tmp_index ):
358
354
os .remove (tmp_index )
359
355
# END index merge handling
360
356
@@ -374,8 +370,8 @@ def raise_exc(e):
374
370
rs = r + os .sep
375
371
for path in paths :
376
372
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 )
379
375
# END make absolute path
380
376
381
377
try :
@@ -407,7 +403,7 @@ def raise_exc(e):
407
403
for root , dirs , files in os .walk (abs_path , onerror = raise_exc ): # @UnusedVariable
408
404
for rela_file in files :
409
405
# add relative paths only
410
- yield os . path .join (root .replace (rs , '' ), rela_file )
406
+ yield osp .join (root .replace (rs , '' ), rela_file )
411
407
# END for each file in subdir
412
408
# END for each subdirectory
413
409
except OSError :
@@ -569,7 +565,7 @@ def _process_diff_args(self, args):
569
565
def _to_relative_path (self , path ):
570
566
""":return: Version of path relative to our git directory or raise ValueError
571
567
if it is not within our git direcotory"""
572
- if not os . path .isabs (path ):
568
+ if not osp .isabs (path ):
573
569
return path
574
570
if self .repo .bare :
575
571
raise InvalidGitRepositoryError ("require non-bare repository" )
@@ -617,12 +613,12 @@ def _entries_for_paths(self, paths, path_rewriter, fprogress, entries):
617
613
entries_added = list ()
618
614
if path_rewriter :
619
615
for path in paths :
620
- if os . path .isabs (path ):
616
+ if osp .isabs (path ):
621
617
abspath = path
622
618
gitrelative_path = path [len (self .repo .working_tree_dir ) + 1 :]
623
619
else :
624
620
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 )
626
622
# end obtain relative and absolute paths
627
623
628
624
blob = Blob (self .repo , Blob .NULL_BIN_SHA ,
0 commit comments