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

Sign up
Appearance settings

How to perform git cat-file? #1570

Unanswered
JackyLiang522 asked this question in Q&A
Discussion options

Is there an API for git cat-file? I did not find it in the docs.

You must be logged in to vote

Replies: 1 comment

Comment options

Use repo.rev_parse("revspec") to obtain an object hash, and with repo.odb.info(hash) it should be possible to learn what kind of object it is. All objects except for trees can be printed directly. That can probably be done with repo.odb.stream(hash) or maybe there is a method for that on the info object returned earlier.

It's not obvious how to figure that out from the docs, it's hard to discover, and the above will need some experimentation but should give enough hints to figure the details out from there. If in doubt, repo.git.cat_file("revspec", p=true) will definitely do it.

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
Converted from issue

This discussion was converted from issue #1569 on April 04, 2023 11:22.

AltStyle によって変換されたページ (->オリジナル) /