libgit2

git_object_id_from_file

Version:

Given an on-disk file that contains the raw content of an object, determine the object ID. This prepends the object header to the given data, and hashes the results with the hash corresponding to the given oid_type.

Note that this does not look at attributes or do any on-disk filtering (like line ending translation), so when used with blobs, it may not match the results for adding to the repository. To compute the object ID for a blob with filters, use git_repository_hashfile.

See

Signature

int git_object_id_from_file(git_oid *oid_out, const char *path, const git_object_id_options *opts);

Parameters

Out
oid_out

the resulting object id

const char *
In
path

the on-disk path to the raw object content

In
opts

the options for id calculation

Returns

int

0 on success, or an error code

Versions