summaryrefslogtreecommitdiff
path: root/git/objects
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2011-05-30 16:32:56 +0200
committerSebastian Thiel <byronimo@gmail.com>2011-05-30 16:32:56 +0200
commit1f71ed94578799ee1667ba54b66a369e307f415b (patch)
treef8e1c3a8507b5306a6a04efa94ffec3c22731bcc /git/objects
parent024adf37acddd6a5d8293b6b5d15795c59a142c0 (diff)
downloadgitpython-1f71ed94578799ee1667ba54b66a369e307f415b.tar.gz
git cmd implementation of repository appears to work, at least this is what the test suggests. Pure python implementation still has some trouble, but this should be very fixable
Diffstat (limited to 'git/objects')
-rw-r--r--git/objects/base.py17
-rw-r--r--git/objects/submodule/base.py2
2 files changed, 14 insertions, 5 deletions
diff --git a/git/objects/base.py b/git/objects/base.py
index 24967e7b..e51afbed 100644
--- a/git/objects/base.py
+++ b/git/objects/base.py
@@ -14,7 +14,8 @@ from git.util import (
join_path_native,
stream_copy
)
-
+from git.db.interface import RepositoryPathsMixin
+from git.exc import UnsupportedOperation
from git.typ import ObjectType
_assertion_msg_format = "Created object %r whose python type %r disagrees with the acutal git object type %r"
@@ -173,7 +174,15 @@ class IndexObject(Object):
Absolute path to this index object in the file system ( as opposed to the
.path field which is a path relative to the git repository ).
- The returned path will be native to the system and contains '\' on windows. """
- assert False, "Only works if repository is not bare - provide this check in an interface"
- return join_path_native(dirname(self.odb.root_path()), self.path)
+ The returned path will be native to the system and contains '\' on windows.
+ :raise UnsupportedOperation: if underlying odb does not support the required method to obtain a working dir"""
+ # TODO: Here we suddenly need something better than a plain object database
+ # which indicates our odb should better be named repo !
+ root = ''
+ if isinstance(self.odb, RepositoryPathsMixin):
+ root = self.odb.working_tree_dir
+ else:
+ raise UnsupportedOperation("Cannot provide absolute path from a database without Repository path support")
+ #END handle odb type
+ return join_path_native(root, self.path)
diff --git a/git/objects/submodule/base.py b/git/objects/submodule/base.py
index a57111d3..e38b94f8 100644
--- a/git/objects/submodule/base.py
+++ b/git/objects/submodule/base.py
@@ -58,7 +58,7 @@ UPDWKTREE = UpdateProgress.UPDWKTREE
# IndexObject comes via util module, its a 'hacky' fix thanks to pythons import
# mechanism which cause plenty of trouble of the only reason for packages and
# modules is refactoring - subpackages shoudn't depend on parent packages
-class Submodule(Iterable, Traversable, RepoAliasMixin):
+class Submodule(util.IndexObject, Iterable, Traversable, RepoAliasMixin):
"""Implements access to a git submodule. They are special in that their sha
represents a commit in the submodule's repository which is to be checked out
at the path of this instance.