Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
flichtenheld opened this issue Jan 9, 2025 · 4 comments · Fixed by #1996
Closed

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

flichtenheld opened this issue Jan 9, 2025 · 4 comments · Fixed by #1996

Comments

@flichtenheld
Copy link
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).

@flichtenheld
Copy link
Contributor Author

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

@flichtenheld
Copy link
Contributor Author

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
Copy link
Contributor Author

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

flichtenheld added a commit to flichtenheld/GitPython that referenced this issue Jan 9, 2025
This should resolve to commit object.

Fixes: gitpython-developers#1995

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
@Byron
Copy link
Member

Byron commented Jan 10, 2025

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
Development

Successfully merging a pull request may close this issue.

2 participants