summaryrefslogtreecommitdiff
path: root/lib/git
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2009-10-11 22:22:28 +0200
committerSebastian Thiel <byronimo@gmail.com>2009-10-11 22:22:28 +0200
commitb01824b1aecf8aadae4501e22feb45c20fb26bce (patch)
treed4bd7e5dc1f183938e95619de1b52944e23b9724 /lib/git
parent708b8dda8e7b87841a5f39c60b799c514e75a9c7 (diff)
downloadgitpython-b01824b1aecf8aadae4501e22feb45c20fb26bce.tar.gz
Fixed remaining tests to deal with the changes
mode is now generally an int compatible to the stat module
Diffstat (limited to 'lib/git')
-rw-r--r--lib/git/base.py18
-rw-r--r--lib/git/commit.py12
-rw-r--r--lib/git/diff.py4
3 files changed, 28 insertions, 6 deletions
diff --git a/lib/git/base.py b/lib/git/base.py
index b7976dab..4e5298e4 100644
--- a/lib/git/base.py
+++ b/lib/git/base.py
@@ -171,9 +171,27 @@ class IndexObject(Object):
file.ext or folder/other.ext
"""
super(IndexObject, self).__init__(repo, id)
+ if isinstance(mode, basestring):
+ mode = self._mode_str_to_int(mode)
self.mode = mode
self.path = path
+ @classmethod
+ def _mode_str_to_int( cls, modestr ):
+ """
+ ``modestr``
+ string like 755 or 644 or 100644 - only the last 3 chars will be used
+
+ Returns
+ String identifying a mode compatible to the mode methods ids of the
+ stat module regarding the rwx permissions for user, group and other
+ """
+ mode = 0
+ for iteration,char in enumerate(reversed(modestr[-3:])):
+ mode += int(char) << iteration*3
+ # END for each char
+ return mode
+
@property
def basename(self):
"""
diff --git a/lib/git/commit.py b/lib/git/commit.py
index 9bf753e0..68415be5 100644
--- a/lib/git/commit.py
+++ b/lib/git/commit.py
@@ -39,11 +39,11 @@ class Commit(base.Object):
``id``
is the sha id of the commit
- ``parents`` : list( Commit, ... )
- is a list of commit ids or actual Commits
+ ``parents`` : tuple( Commit, ... )
+ is a tuple of commit ids or actual Commits
``tree`` : Tree
- is the corresponding tree id
+ is the corresponding tree id or an actual Tree
``author`` : Actor
is the author string ( will be implicitly converted into an Actor object )
@@ -179,11 +179,11 @@ class Commit(base.Object):
# free line
lines.pop(0)
- messages = []
+ message_lines = []
while lines and not lines[0].startswith('commit'):
- messages.append(lines.pop(0).strip())
+ message_lines.append(lines.pop(0).strip())
# END while there are message lines
- message = '\n'.join(messages)
+ message = '\n'.join(message_lines[:-1]) # last line is empty
commits.append(Commit(repo, id=id, parents=parents, tree=tree, author=author, authored_date=authored_date,
committer=committer, committed_date=committed_date, message=message))
diff --git a/lib/git/diff.py b/lib/git/diff.py
index 7200b7e3..943fb08a 100644
--- a/lib/git/diff.py
+++ b/lib/git/diff.py
@@ -62,6 +62,10 @@ class Diff(object):
self.a_mode = a_mode
self.b_mode = b_mode
+ if self.a_mode:
+ self.a_mode = blob.Blob._mode_str_to_int( self.a_mode )
+ if self.b_mode:
+ self.b_mode = blob.Blob._mode_str_to_int( self.b_mode )
self.new_file = new_file
self.deleted_file = deleted_file
self.rename_from = rename_from