Skip to content

rev_parse does not handle <tag>^{commit} correctly #1995

@flichtenheld

Description

@flichtenheld
Contributor

git rev-parse <tag>^{commit} resolves to the commit that the tag points to.

repo.rev_parse("<tag>^{commit}") says ValueError: Could not accommodate requested object type 'commit', got tag

It should instead return TagObject.object (at least if that is a commit object).

Activity

flichtenheld

flichtenheld commented on Jan 9, 2025

@flichtenheld
ContributorAuthor

Re-verified that is present in the current release (3.1.44)

flichtenheld

flichtenheld commented on Jan 9, 2025

@flichtenheld
ContributorAuthor

Interestingly it tries to resolve the tag when you specify ^{blob} although it is not clear to me when this would ever work given that TagObject.object is usually a commit.

flichtenheld

flichtenheld commented on Jan 9, 2025

@flichtenheld
ContributorAuthor

Found from the test suite that <tag>^{} works. So this a usable work-around. Will prepare a patch anyway.

added a commit that references this issue on Jan 9, 2025
e4f1aa7
Byron

Byron commented on Jan 10, 2025

@Byron
Member

Thanks a lot for digging into this!

I may also add that this implementation is definitely not according to 'spec' and probably just superficially resembles git rev-parse semantics.
Probably it's just good enough for the common cases, which is a reason for issues around it being quite rare overall.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @Byron@flichtenheld

      Issue actions

        rev_parse does not handle <tag>^{commit} correctly · Issue #1995 · gitpython-developers/GitPython