libgit2

git_repository_hashfile

Version:

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.

Signature

int git_repository_hashfile(git_oid *out, git_repository *repo, const char *path, git_otype type, const char *as_path);

Parameters

In
out

Output value of calculated SHA

In
repo

Repository pointer

const char *
In
path

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

In
type

The object type to hash as (e.g. GIT_OBJ_BLOB)

const char *
In
as_path

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.

Returns

int

Versions