Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Repository.resolve_refish can return a Tag, violates docstring and typehint

Open
#1,414 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
55/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
git, python
Domain
tooling

Research direction

Start at the Repository.resolve_refish entry point and inspect how symbolic references and direct object IDs are resolved. Look for existing tests covering Commit, Tag, and ref targets, then confirm the intended return contract with the maintainers. Done means the documented and typed behavior matches the verified behavior, with regression coverage for the two examples.

Written by the indexing model from the issue text.

Description

The typing hint and docstring of Repository.resolve_refish says it returns a Commit object. Actually, it will return a Tag object if given a tag's hex oid. Is this the expected behavior.

For example, in the Linux kernel:

assert pygit2.__version__ == "1.18.0"

# OID of `v6.12.1^{tag}` and v6.12.1^{commit}` in Linux kernel.                 
tag_oid = Oid(hex="a554dea023a451ad985c071f8aae6415f0e274df")   
commit_oid = Oid(hex="d390303b28dabbb91b2d32016a4f72da478733b9")
                                                                
# As documented, symbolic refs resolve to a commit object.
# But the ref target differs from the returned object. Is this the desired behavior?
obj, ref = repo.resolve_refish("v6.12.1")             
assert isinstance(obj, Commit)                                  
assert ref.target != obj.id
assert ref.target == tag_oid                               

# Contrary to the docstring and typing hint, this returns a Tag object.                                                                
obj, ref = repo.resolve_refish(str(tag_oid))                    
assert isinstance(obj, Tag)                                     
assert ref is None
Dominant language
Python
Stars
1.7k
Forks
408
Avg merge
2d 57m
Merged PRs (30d)
7

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from libgit2/pygit2

All issues in libgit2/pygit2

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.