summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2015-01-12 12:25:53 +0100
committerSebastian Thiel <byronimo@gmail.com>2015-01-12 12:25:53 +0100
commite7671110bc865786ffe61cf9b92bf43c03759229 (patch)
tree3318b3b49d2a6c5f58a31ce189c27d1cf4d56927
parentede325d15ba9cba0e7fe9ee693085fd5db966629 (diff)
downloadgitpython-e7671110bc865786ffe61cf9b92bf43c03759229.tar.gz
Removed os.path.realpath invocations as they are not necessary if paths are used consistently.
This will save IOPs, and make the code easier to understand (I suppose). Related to #224
-rw-r--r--git/index/base.py10
-rw-r--r--git/test/lib/helper.py4
-rw-r--r--git/test/test_index.py2
3 files changed, 11 insertions, 5 deletions
diff --git a/git/index/base.py b/git/index/base.py
index 66fd5b1f..db0c3cda 100644
--- a/git/index/base.py
+++ b/git/index/base.py
@@ -579,8 +579,14 @@ class IndexFile(LazyMixin, diff.Diffable, Serializable):
entries_added = list()
if path_rewriter:
for path in paths:
- abspath = os.path.abspath(path)
- gitrelative_path = abspath[len(self.repo.working_tree_dir) + 1:]
+ if os.path.isabs(path):
+ abspath = path
+ gitrelative_path = path[len(self.repo.working_tree_dir) + 1:]
+ else:
+ gitrelative_path = path
+ abspath = os.path.join(self.repo.working_tree_dir, gitrelative_path)
+ # end obtain relative and absolute paths
+
blob = Blob(self.repo, Blob.NULL_BIN_SHA,
stat_mode_to_index_mode(os.stat(abspath).st_mode),
to_native_path_linux(gitrelative_path))
diff --git a/git/test/lib/helper.py b/git/test/lib/helper.py
index a0b8dc15..c5c5a620 100644
--- a/git/test/lib/helper.py
+++ b/git/test/lib/helper.py
@@ -63,11 +63,11 @@ class StringProcessAdapter(object):
def _mktemp(*args):
"""Wrapper around default tempfile.mktemp to fix an osx issue
- :note: the OSX special case was removed as it was unclear why that was needed in the first place. It seems
+ :note: the OSX special case was removed as it was unclear why that was needed in the first place. It seems
to be just fine without it. However, if we leave this special case, and if TMPDIR is set to something custom,
prefixing /private/ will lead to incorrect paths on OSX."""
tdir = tempfile.mktemp(*args)
- # See :note: above to learn why this is comented out.
+ # See :note: above to learn why this is comented out.
# if sys.platform == 'darwin':
# tdir = '/private' + tdir
return tdir
diff --git a/git/test/test_index.py b/git/test/test_index.py
index 4fdd3d1b..021a8cd9 100644
--- a/git/test/test_index.py
+++ b/git/test/test_index.py
@@ -501,7 +501,7 @@ class TestIndex(TestBase):
# same file
entries = index.reset(new_commit).add(
- [os.path.abspath(os.path.join('lib', 'git', 'head.py'))] * 2, fprogress=self._fprogress_add)
+ [os.path.join(rw_repo.working_tree_dir, 'lib', 'git', 'head.py')] * 2, fprogress=self._fprogress_add)
self._assert_entries(entries)
assert entries[0].mode & 0o644 == 0o644
# would fail, test is too primitive to handle this case