summaryrefslogtreecommitdiff
path: root/test/git/test_refs.py
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2010-11-18 10:40:16 +0100
committerSebastian Thiel <byronimo@gmail.com>2010-11-18 10:46:39 +0100
commit82849578e61a7dfb47fc76dcbe18b1e3b6a36951 (patch)
treedb49b89e8956d7ebf5231aea4c23e2664668ab77 /test/git/test_refs.py
parent7a320abc52307b4d4010166bd899ac75024ec9a7 (diff)
downloadgitpython-82849578e61a7dfb47fc76dcbe18b1e3b6a36951.tar.gz
ORIG_HEAD handling is now implemented in the ref-class itself, instead of being a special case of the commit method; includes tests
util: Fixed iterable lists, which broke due to an incorrectly implemented __contains__ method
Diffstat (limited to 'test/git/test_refs.py')
-rw-r--r--test/git/test_refs.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/git/test_refs.py b/test/git/test_refs.py
index 4cfd952e..fa26bae9 100644
--- a/test/git/test_refs.py
+++ b/test/git/test_refs.py
@@ -92,6 +92,37 @@ class TestRefs(TestBase):
assert head.tracking_branch() is None
# END for each head
+ # verify ORIG_HEAD gets set for detached heads
+ head = rwrepo.head
+ orig_head = head.orig_head()
+ cur_head = head.ref
+ cur_commit = cur_head.commit
+ pcommit = cur_head.commit.parents[0].parents[0]
+ head.ref = pcommit # detach head
+ assert orig_head.commit == cur_commit
+
+ # even if we set it through its reference - chaning the ref
+ # will adjust the orig_head, which still points to cur_commit
+ head.ref = cur_head
+ assert orig_head.commit == pcommit
+ assert head.commit == cur_commit == cur_head.commit
+
+ cur_head.commit = pcommit
+ assert head.commit == pcommit
+ assert orig_head.commit == cur_commit
+
+ # with automatic dereferencing
+ head.commit = cur_commit
+ assert orig_head.commit == pcommit
+
+ # changing branches which are not checked out doesn't affect the ORIG_HEAD
+ other_head = Head.create(rwrepo, 'mynewhead', pcommit)
+ assert other_head.commit == pcommit
+ assert orig_head.commit == pcommit
+ other_head.commit = pcommit.parents[0]
+ assert orig_head.commit == pcommit
+
+
def test_refs(self):
types_found = set()
for ref in self.rorepo.refs: