diff --git a/git/repo/fun.py b/git/repo/fun.py index 6aefd9d66..5437096cf 100644 --- a/git/repo/fun.py +++ b/git/repo/fun.py @@ -208,7 +208,14 @@ def rev_parse(repo, rev): ref = repo.head.ref else: if token == '@': - ref = name_to_object(repo, rev[:start], return_ref=True) + try: + ref = name_to_object(repo, rev[:start], return_ref=True) + except BadObject: + # If this doesn't result in an object we most likely + # encounter a reference containing the '@' character. + # In this case we just to continue the search. + start += 1 + continue else: obj = name_to_object(repo, rev[:start]) # END handle token diff --git a/git/test/test_repo.py b/git/test/test_repo.py index 7fc49f3b1..89889224f 100644 --- a/git/test/test_repo.py +++ b/git/test/test_repo.py @@ -701,6 +701,10 @@ def test_rw_rev_parse(self, rwrepo): ahead = rwrepo.create_head('aaaaaaaa') assert(rwrepo.rev_parse(str(ahead)) == ahead.commit) + # verify @ in branch names are possible + bhead = rwrepo.create_head('aaa@aaa') + assert (rwrepo.rev_parse(str(bhead)) == bhead.commit) + def test_rev_parse(self): rev_parse = self.rorepo.rev_parse