Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion 8 git/repo/fun.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,13 @@ def rev_parse(repo: "Repo", rev: str) -> AnyGitObject:

# Handle type.
if output_type == "commit":
pass # Default.
obj = cast("TagObject", obj)
if obj and obj.type == "tag":
obj = deref_tag(obj)
else:
# Cannot do anything for non-tags.
pass
# END handle tag
elif output_type == "tree":
try:
obj = cast(AnyGitObject, obj)
Expand Down
4 changes: 2 additions & 2 deletions 4 test/test_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -1064,9 +1064,9 @@ def test_rev_parse(self):
# TODO: Dereference tag into a blob 0.1.7^{blob} - quite a special one.
# Needs a tag which points to a blob.

# ref^0 returns commit being pointed to, same with ref~0, and ^{}
# ref^0 returns commit being pointed to, same with ref~0, ^{}, and ^{commit}
tag = rev_parse("0.1.4")
for token in ("~0", "^0", "^{}"):
for token in ("~0", "^0", "^{}", "^{commit}"):
self.assertEqual(tag.object, rev_parse("0.1.4%s" % token))
# END handle multiple tokens

Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.