summaryrefslogtreecommitdiff
path: root/lib/git/refs.py
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2009-10-14 19:41:27 +0200
committerSebastian Thiel <byronimo@gmail.com>2009-10-14 19:41:27 +0200
commitc5df44408218003eb49e3b8fc94329c5e8b46c7d (patch)
tree2e0c757af71c05cc5d4580cf80ba97abb00fe1be /lib/git/refs.py
parent6745f4542cfb74bbf3b933dba7a59ef2f54a4380 (diff)
downloadgitpython-c5df44408218003eb49e3b8fc94329c5e8b46c7d.tar.gz
persistent command signature changed to also return the hexsha from a possible input ref - the objects pointed to by refs are now baked on demand - perhaps it should change to always be re-retrieved using a property as it is relatively fast - this way refs can always be cached
Diffstat (limited to 'lib/git/refs.py')
-rw-r--r--lib/git/refs.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/git/refs.py b/lib/git/refs.py
index 9754f65d..be02fb40 100644
--- a/lib/git/refs.py
+++ b/lib/git/refs.py
@@ -38,10 +38,11 @@ class Ref(LazyMixin, Iterable):
if attr == "object":
# have to be dynamic here as we may be a tag which can point to anything
# it uses our path to stay dynamic
- typename, size = self.repo.git.get_object_header(self.path)
- # explicitly do not set the size as it may change if the our ref path points
- # at some other place when the head changes for instance ...
- self.object = get_object_type_by_name(typename)(self.repo, self.path)
+ hexsha, typename, size = self.repo.git.get_object_header(self.path)
+ # pin-point our object to a specific sha, even though it might not
+ # reflect the our cached object anymore in case our rev now points
+ # to a different commit
+ self.object = get_object_type_by_name(typename)(self.repo, hexsha)
else:
super(Ref, self)._set_cache_(attr)
@@ -128,7 +129,9 @@ class Ref(LazyMixin, Iterable):
full_path, hexsha, type_name, object_size = line.split("\x00")
# No, we keep the object dynamic by allowing it to be retrieved by
- # our path on demand - due to perstent commands it is fast
+ # our path on demand - due to perstent commands it is fast.
+ # This reduces the risk that the object does not match
+ # the changed ref anymore in case it changes in the meanwhile
return cls(repo, full_path)
# obj = get_object_type_by_name(type_name)(repo, hexsha)