summaryrefslogtreecommitdiff
path: root/git/index/base.py
diff options
context:
space:
mode:
authorKostis Anagnostopoulos <ankostis@gmail.com>2016-10-01 16:02:20 +0200
committerKostis Anagnostopoulos <ankostis@gmail.com>2016-10-01 16:33:20 +0200
commitb8b025f719b2c3203e194580bbd0785a26c08ebd (patch)
tree8cec9ba13035f9489fdaa56e550e93bc976372fc /git/index/base.py
parenta79cf677744e2c1721fa55f934fa07034bc54b0a (diff)
downloadgitpython-b8b025f719b2c3203e194580bbd0785a26c08ebd.tar.gz
Win, #519: FIX repo TCs.
+ FIX TestRepo.test_submodule_update(): + submod: del `.git` file prior overwrite; Windows denied otherwise! + FIX TestRepo.test_untracked_files(): + In the `git add <file>` case, it failed with unicode args on PY2. Had to encode them with `locale.getpreferredencoding()` AND use SHELL. + cmd: add `shell` into `execute()` kwds, for overriding USE_SHELL per command. + repo: replace blocky `communicate()` in `_clone()` with thread-pumps. + test_repo.py: unittestize (almost all) assertions. + Replace open --> with open for index (base and TC). + test_index.py: Enabled a dormant assertion.
Diffstat (limited to 'git/index/base.py')
-rw-r--r--git/index/base.py15
1 files changed, 7 insertions, 8 deletions
diff --git a/git/index/base.py b/git/index/base.py
index d7d9fc3a..9b6d28ab 100644
--- a/git/index/base.py
+++ b/git/index/base.py
@@ -214,8 +214,8 @@ class IndexFile(LazyMixin, diff.Diffable, Serializable):
self.entries
lfd = LockedFD(file_path or self._file_path)
stream = lfd.open(write=True, stream=True)
- ok = False
+ ok = False
try:
self._serialize(stream, ignore_extension_data)
ok = True
@@ -602,14 +602,13 @@ class IndexFile(LazyMixin, diff.Diffable, Serializable):
stream = None
if S_ISLNK(st.st_mode):
# in PY3, readlink is string, but we need bytes. In PY2, it's just OS encoded bytes, we assume UTF-8
- stream = BytesIO(force_bytes(os.readlink(filepath), encoding=defenc))
+ open_stream = lambda: BytesIO(force_bytes(os.readlink(filepath), encoding=defenc))
else:
- stream = open(filepath, 'rb')
- # END handle stream
- fprogress(filepath, False, filepath)
- istream = self.repo.odb.store(IStream(Blob.type, st.st_size, stream))
- fprogress(filepath, True, filepath)
- stream.close()
+ open_stream = lambda: open(filepath, 'rb')
+ with open_stream() as stream:
+ fprogress(filepath, False, filepath)
+ istream = self.repo.odb.store(IStream(Blob.type, st.st_size, stream))
+ fprogress(filepath, True, filepath)
return BaseIndexEntry((stat_mode_to_index_mode(st.st_mode),
istream.binsha, 0, to_native_path_linux(filepath)))