GitRepo.hashFile

Calculate hash of file using repository filtering rules.

If you simply want to calculate the hash of a file on disk with no filters, you can use the global hashFile function. However, if you want to hash a file in the repository and you want to apply filtering rules (e.g. crlf filters) before generating the SHA, then use this function.

struct GitRepo
hashFile
(
in char[] path
,,
in char[] asPath = null
)

Examples

auto repo = initRepo(_userRepo, OpenBare.yes);
scope(exit) rmdirRecurse(_userRepo);

string objPath = buildPath(repo.path, "test.d");
string text = "import std.stdio;";
std.file.write(objPath, text);

auto oid = repo.hashFile(objPath, GitType.blob);

Meta