diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2009-11-30 11:28:15 +0100 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2009-11-30 13:50:12 +0100 |
commit | f22ddca351c45edab9f71359765e34ae16205fa1 (patch) | |
tree | 4980a0eaf343a20fc4b0f9d988f0e41a19786032 | |
parent | bac518bfa621a6d07e3e4d9f9b481863a98db293 (diff) | |
download | gitpython-f22ddca351c45edab9f71359765e34ae16205fa1.tar.gz |
SymbolicReference.delete: Now takes SymbolicReference instances as well, not only paths
diff.__str__: fixed incorrect message generation error
-rw-r--r-- | lib/git/diff.py | 2 | ||||
-rw-r--r-- | lib/git/refs.py | 3 | ||||
-rw-r--r-- | test/git/test_refs.py | 5 |
3 files changed, 7 insertions, 3 deletions
diff --git a/lib/git/diff.py b/lib/git/diff.py index 38430827..9b07b5ea 100644 --- a/lib/git/diff.py +++ b/lib/git/diff.py @@ -248,7 +248,7 @@ class Diff(object): h = "%s" if self.a_blob: h %= self.a_blob.path - if self.b_blob: + elif self.b_blob: h %= self.b_blob.path msg = '' diff --git a/lib/git/refs.py b/lib/git/refs.py index 208ce880..cf829cb6 100644 --- a/lib/git/refs.py +++ b/lib/git/refs.py @@ -236,6 +236,8 @@ class SymbolicReference(object): @classmethod def _to_full_path(cls, repo, path): + if isinstance(path, SymbolicReference): + path = path.path full_ref_path = path if not cls._common_path_default: return full_ref_path @@ -253,6 +255,7 @@ class SymbolicReference(object): ``path`` Short or full path pointing to the reference, i.e. refs/myreference or just "myreference", hence 'refs/' is implied. + Alternatively the symbolic reference to be deleted """ full_ref_path = cls._to_full_path(repo, path) abs_path = os.path.join(repo.path, full_ref_path) diff --git a/test/git/test_refs.py b/test/git/test_refs.py index 30c08081..55982b23 100644 --- a/test/git/test_refs.py +++ b/test/git/test_refs.py @@ -233,6 +233,7 @@ class TestRefs(TestBase): far_away_head = rw_repo.create_head("far_head",'HEAD~100') self.failUnlessRaises(GitCommandError, far_away_head.checkout) assert active_branch == active_branch.checkout(force=True) + assert rw_repo.head.reference != far_away_head # test reference creation partial_ref = 'sub/ref' @@ -261,8 +262,8 @@ class TestRefs(TestBase): assert symref.reference == cur_head.reference self.failUnlessRaises(OSError, SymbolicReference.create, rw_repo, symref_path, cur_head.reference) - SymbolicReference.delete(rw_repo, symref_path) - # would raise if the symref wouldn't have been deleted + SymbolicReference.delete(rw_repo, symref) + # would raise if the symref wouldn't have been deletedpbl symref = SymbolicReference.create(rw_repo, symref_path, cur_head.reference) # test symbolic references which are not at default locations like HEAD |