Mini Git
A reduced version of Git
|
#include <string>
Functions | |
int | store_file_as_blob (const std::string &path, const std::string &sha1) |
Stores a file as a blob object in the repository. | |
int store_file_as_blob | ( | const std::string & | path, |
const std::string & | sha1 ) |
Stores a file as a blob object in the repository.
Each Git Blob is stored as a separate file in the .git/objects directory. The file contains a header and the contents of the blob object, compressed using Zlib.
The format of a blob object file looks like this (after Zlib decompression):
<size>
is the size of the content (in bytes)\0
is a null byte<content>
is the actual content of the fileFor example, if the contents of a file are hello world, the blob object file would look like this (after Zlib decompression):
path | Path to the file |
sha1 | Precomputed SHA-1 hash of the file contents (to avoid recomputing it) |