diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2010-11-24 17:51:22 +0100 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2010-11-24 17:51:22 +0100 |
commit | c946bf260d3f7ca54bffb796a82218dce0eb703f (patch) | |
tree | 5b8ebe421280b187f856af7e3e9a76a9b47d548d /refs/reference.py | |
parent | 264ba6f54f928da31a037966198a0849325b3732 (diff) | |
download | gitpython-c946bf260d3f7ca54bffb796a82218dce0eb703f.tar.gz |
Added tests for creation and adjustments of reference, verifying the log gets written
Diffstat (limited to 'refs/reference.py')
-rw-r--r-- | refs/reference.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/refs/reference.py b/refs/reference.py index e7cdfdee..c44ebf00 100644 --- a/refs/reference.py +++ b/refs/reference.py @@ -37,6 +37,36 @@ class Reference(SymbolicReference, LazyMixin, Iterable): def __str__(self): return self.name + def set_object(self, object, msg = None): + """Special version which checks if the head-log needs an update as well""" + oldbinsha = None + if msg is not None: + head = self.repo.head + if not head.is_detached and head.ref == self: + oldbinsha = self.commit.binsha + #END handle commit retrieval + #END handle message is set + + super(Reference, self).set_object(object, msg) + + if oldbinsha is not None: + # /* from refs.c in git-source + # * Special hack: If a branch is updated directly and HEAD + # * points to it (may happen on the remote side of a push + # * for example) then logically the HEAD reflog should be + # * updated too. + # * A generic solution implies reverse symref information, + # * but finding all symrefs pointing to the given branch + # * would be rather costly for this rare event (the direct + # * update of a branch) to be worth it. So let's cheat and + # * check with HEAD only which should cover 99% of all usage + # * scenarios (even 100% of the default ones). + # */ + self.repo.head.log_append(oldbinsha, msg) + #END check if the head + + # NOTE: Don't have to overwrite properties as the will only work without a the log + @property def name(self): """:return: (shortest) Name of this reference - it may contain path components""" |