# Using ts-node
npx ts-node <path/to/git.ts> cat-file [options] <object>
# Using node
node <path/to/git.js> cat-file [options] <object>
-
object
The hash of the object to show.
-
-p
Pretty-print the contents of
object
based on its type. -
-t
Instead of the content, show the object type identified by
object
.
Provide content or type information for repository objects.
-
First check if the given hash corresponds to a valid object or not. This is done via the helper function
parseObject()
present in utils.ts.Note: Objects stored in the packfile are not supported. Refer to the JSDOC of the
parseObject
function for more details. -
The
parseObject
function will given us thetype
,byteLength
and thedata
in form of the Buffer. -
The
blob
andcommit
type files can be printed as is. Thetree
type file requires some level of decoding.