git_repository_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 just use the git_odb_hashfile() API. 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.

Note: if the repository has core.safecrlf set to fail and the filtering triggers that failure, then this function will return an error and not calculate the hash of the file.

extern (C) nothrow @nogc
int
git_repository_hashfile

Parameters

out_ libgit2_d.oid.git_oid*

Output value of calculated SHA

repo libgit2_d.types.git_repository*

Repository pointer

path const(char)*

Path to file on disk whose contents should be hashed. If the repository is not null, this can be a relative path.

type libgit2_d.types.git_object_t

The object type to hash as (e.g. git_object_t.GIT_OBJECT_BLOB)

as_path const(char)*

The path to use to look up filtering rules. If this is null, then the path parameter will be used instead. If this is passed as the empty string, then no filters will be applied when calculating the hash.

Return Value

Type: int

0 on success, or an error code

Meta