summaryrefslogtreecommitdiff
path: root/lib/git/index.py
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2010-05-11 00:06:14 +0200
committerSebastian Thiel <byronimo@gmail.com>2010-05-11 00:06:14 +0200
commit8caeec1b15645fa53ec5ddc6e990e7030ffb7c5a (patch)
treeda01b74f6c76a8965dee9b21dc471e41e3d0018a /lib/git/index.py
parentde5bc8f7076c5736ef1efa57345564fbc563bd19 (diff)
downloadgitpython-8caeec1b15645fa53ec5ddc6e990e7030ffb7c5a.tar.gz
IndexFile.add: Fixed incorrect path handling if path rewriting was desired and absolute paths were given
Commit.create_from_tree: fixed critical bug that would cause it to create a branch named master by default, instead of the reference actually set ( which is master in many, but not all cases ) - in fact it could be detached as well, we would fail ungracefully although we could assume master then ... although we cant really make the decision Repo.is_dirty: improved its abiility to deal with empty repositories and a missing head. Weird thing is that the test always worked fine with the previous code, but it didn't work for me in a similar situation without this change at least
Diffstat (limited to 'lib/git/index.py')
-rw-r--r--lib/git/index.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/git/index.py b/lib/git/index.py
index 0a5ba5a9..1b5d3180 100644
--- a/lib/git/index.py
+++ b/lib/git/index.py
@@ -907,8 +907,9 @@ class IndexFile(LazyMixin, diff.Diffable):
must be a path relative to our repository.
If their sha is null ( 40*0 ), their path must exist in the file system
- as an object will be created from the data at the path.The handling
- now very much equals the way string paths are processed, except that
+ relative to the git repository as an object will be created from
+ the data at the path.
+ The handling now very much equals the way string paths are processed, except that
the mode you have set will be kept. This allows you to create symlinks
by settings the mode respectively and writing the target of the symlink
directly into the file. This equals a default Linux-Symlink which
@@ -945,6 +946,7 @@ class IndexFile(LazyMixin, diff.Diffable):
is not identical to the layout of the actual files on your hard-dist.
If not None and ``items`` contain plain paths, these paths will be
converted to Entries beforehand and passed to the path_rewriter.
+ Please note that entry.path is relative to the git repository.
:return:
List(BaseIndexEntries) representing the entries just actually added.
@@ -962,8 +964,9 @@ class IndexFile(LazyMixin, diff.Diffable):
if paths and path_rewriter:
for path in paths:
- abspath = os.path.join(self.repo.working_tree_dir, path)
- blob = Blob(self.repo, Blob.NULL_HEX_SHA, os.stat(abspath).st_mode, path)
+ abspath = os.path.abspath(path)
+ gitrelative_path = abspath[len(self.repo.working_tree_dir)+1:]
+ blob = Blob(self.repo, Blob.NULL_HEX_SHA, os.stat(abspath).st_mode, gitrelative_path)
entries.append(BaseIndexEntry.from_blob(blob))
# END for each path
del(paths[:])
@@ -1197,8 +1200,6 @@ class IndexFile(LazyMixin, diff.Diffable):
return out
-
-
@default_index
def commit(self, message, parent_commits=None, head=True):
"""