diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2010-11-24 15:56:49 +0100 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2010-11-24 15:56:49 +0100 |
commit | ec0657cf5de9aeb5629cc4f4f38b36f48490493e (patch) | |
tree | ae7f08094c6fdcddad194783f3e18b5a724c0197 /refs/reference.py | |
parent | a17c43d0662bab137903075f2cff34bcabc7e1d1 (diff) | |
download | gitpython-ec0657cf5de9aeb5629cc4f4f38b36f48490493e.tar.gz |
Unified object and commit handling which should make the reflog handling much easier. There is some bug in it though, it still needs fixing
Diffstat (limited to 'refs/reference.py')
-rw-r--r-- | refs/reference.py | 37 |
1 files changed, 1 insertions, 36 deletions
diff --git a/refs/reference.py b/refs/reference.py index 446196c3..e7cdfdee 100644 --- a/refs/reference.py +++ b/refs/reference.py @@ -18,6 +18,7 @@ class Reference(SymbolicReference, LazyMixin, Iterable): """Represents a named reference to any object. Subclasses may apply restrictions though, i.e. Heads can only point to commits.""" __slots__ = tuple() + _points_to_commits_only = False _resolve_ref_on_create = True _common_path_default = "refs" @@ -36,42 +37,6 @@ class Reference(SymbolicReference, LazyMixin, Iterable): def __str__(self): return self.name - def _get_object(self): - """ - :return: - The object our ref currently refers to. Refs can be cached, they will - always point to the actual object as it gets re-created on each query""" - # have to be dynamic here as we may be a tag which can point to anything - # Our path will be resolved to the hexsha which will be used accordingly - return Object.new_from_sha(self.repo, hex_to_bin(self.dereference_recursive(self.repo, self.path))) - - def _set_object(self, ref): - """ - Set our reference to point to the given ref. It will be converted - to a specific hexsha. - If the reference does not exist, it will be created. - - :note: - TypeChecking is done by the git command""" - abs_path = self.abspath - existed = True - if not isfile(abs_path): - existed = False - open(abs_path, 'wb').write(Object.NULL_HEX_SHA) - # END quick create - - # do it safely by specifying the old value - try: - self.repo.git.update_ref(self.path, ref, (existed and self._get_object().hexsha) or None) - except: - if not existed: - os.remove(abs_path) - # END remove file on error if it didn't exist before - raise - # END exception handling - - object = property(_get_object, _set_object, doc="Return the object our ref currently refers to") - @property def name(self): """:return: (shortest) Name of this reference - it may contain path components""" |