Skip to content

saveBlob の実装#13

Merged
massan02 merged 4 commits intomainfrom
ulxsth/blob-dump
Mar 27, 2025
Merged

saveBlob の実装#13
massan02 merged 4 commits intomainfrom
ulxsth/blob-dump

Conversation

@ulxsth
Copy link
Contributor

@ulxsth ulxsth commented Mar 27, 2025

Details

GitBlobObject オブジェクトから Blob ファイルを作成し、 .git/objects 内に格納する関数 saveBlob を実装しました。

Debug

example フォルダに入ったのち、以下のコマンドを実行してください。

nlx tsx ../src/blob.ts

内部ではテストデータがセーブされたのち、ロードされています。

// test
const data: GitBlobObject = {type: "blob", size: 5, content: "Hello\n"};
saveBlob(data);
console.log(blob2Hash(data));
console.log(loadBlob(blob2Hash(data)));

ログに対象 Blob のハッシュ値とテストデータの内容が表示されれば OK。

 nlx tsx ../src/blob.ts
e965047ad7c57865823c7d992b1d046ea66edf78
{ type: 'blob', size: 6, content: 'Hello\n' }

念のため、 git cat-file で確認しておくとよいです。

$ git cat-file -p e965047ad7c57865823c7d992b1d046ea66edf78
Hello

@massan02 massan02 merged commit 5f51463 into main Mar 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants