summaryrefslogtreecommitdiff
path: root/test/git/test_refs.py
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2010-11-18 23:11:32 +0100
committerSebastian Thiel <byronimo@gmail.com>2010-11-18 23:11:32 +0100
commitf1545bd9cd6953c5b39c488bf7fe179676060499 (patch)
tree8bd4b8829768fe0195d41a3aa067aa1ac7435605 /test/git/test_refs.py
parenta1d1d2cb421f16bd277d7c4ce88398ff0f5afb29 (diff)
parent7cf2d5fcf0a3db793678dd6ba9fc1c24d4eeb36a (diff)
downloadgitpython-f1545bd9cd6953c5b39c488bf7fe179676060499.tar.gz
Merge branch 'submodule'
Diffstat (limited to 'test/git/test_refs.py')
-rw-r--r--test/git/test_refs.py55
1 files changed, 53 insertions, 2 deletions
diff --git a/test/git/test_refs.py b/test/git/test_refs.py
index 5f13d0b7..fa26bae9 100644
--- a/test/git/test_refs.py
+++ b/test/git/test_refs.py
@@ -63,8 +63,9 @@ class TestRefs(TestBase):
assert len(s) == ref_count
assert len(s|s) == ref_count
- def test_heads(self):
- for head in self.rorepo.heads:
+ @with_rw_repo('HEAD', bare=False)
+ def test_heads(self, rwrepo):
+ for head in rwrepo.heads:
assert head.name
assert head.path
assert "refs/heads" in head.path
@@ -72,8 +73,56 @@ class TestRefs(TestBase):
cur_object = head.object
assert prev_object == cur_object # represent the same git object
assert prev_object is not cur_object # but are different instances
+
+ writer = head.config_writer()
+ tv = "testopt"
+ writer.set_value(tv, 1)
+ assert writer.get_value(tv) == 1
+ del(writer)
+ assert head.config_reader().get_value(tv) == 1
+ head.config_writer().remove_option(tv)
+
+ # after the clone, we might still have a tracking branch setup
+ head.set_tracking_branch(None)
+ assert head.tracking_branch() is None
+ remote_ref = rwrepo.remotes[0].refs[0]
+ assert head.set_tracking_branch(remote_ref) is head
+ assert head.tracking_branch() == remote_ref
+ head.set_tracking_branch(None)
+ 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:
@@ -208,6 +257,8 @@ class TestRefs(TestBase):
refs = remote.refs
RemoteReference.delete(rw_repo, *refs)
remote_refs_so_far += len(refs)
+ for ref in refs:
+ assert ref.remote_name == remote.name
# END for each ref to delete
assert remote_refs_so_far