Skip to content

gbroques/zlib-git-nodejs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

zlib-git-nodejs

Read, hash, and store git objects, compressed with zlib, using Node JS.

Meant for educational purposes, and understanding git internals.

Currently storing git objects is not implemented.

Usage

cat-file

Node.js equivalent to git cat-file -p <object hash>.

$ git cat-file -p 9daeafb9864cf43055ae93beb0afd6c7d144bfa4 ↵
test

For viewing the header containing object type, size in bytes, and null character separating header from content.

$ node cat-file.js 9daeafb9864cf43055ae93beb0afd6c7d144bfa4 ↵
blob 5test

console-dir

Uses console.dir to output contents from stdin to stdout.

$ node cat-file.js 9daeafb9864cf43055ae93beb0afd6c7d144bfa4 | node console-dir.js ↵
'blob 5\x00test\n'

For viewing hidden characters such as null characters (\x00) or new-line characters (\n).

hash-object

Node.js equivalent to git hash-object --stdin.

$ echo 'test' | git hash-object --stdin ↵
9daeafb9864cf43055ae93beb0afd6c7d144bfa4

For illustrative purposes, demonstrating the hash is the SHA-1 of the object's full content, including header information.

$ node cat-file.js 9daeafb9864cf43055ae93beb0afd6c7d144bfa4 | node hash-object.js ↵
9daeafb9864cf43055ae93beb0afd6c7d144bfa4

Limitations

Currently works with blobs, commits, but not trees.

Articles

Releases

No releases published

Packages

No packages published