diff options
author | Russell Belfer <rb@github.com> | 2012-09-07 13:27:49 -0700 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2012-09-11 15:01:09 -0700 |
commit | 47bfa0be6d509b60eda92705b57d3f7ba89c1c6b (patch) | |
tree | 4122605efca76be4958c77bc8ca1a34f87a6227d /include/git2/repository.h | |
parent | 412293dcc95369f0a42ae9a94f30fe7328a5491c (diff) | |
download | libgit2-47bfa0be6d509b60eda92705b57d3f7ba89c1c6b.tar.gz |
Add git_repository_hashfile to hash with filters
The existing `git_odb_hashfile` does not apply text filtering
rules because it doesn't have a repository context to evaluate
the correct rules to apply. This adds a new hashfile function
that will apply repository-specific filters (based on config,
attributes, and filename) before calculating the hash.
Diffstat (limited to 'include/git2/repository.h')
-rw-r--r-- | include/git2/repository.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/include/git2/repository.h b/include/git2/repository.h index f520d5433..ebea3b0d4 100644 --- a/include/git2/repository.h +++ b/include/git2/repository.h @@ -481,6 +481,31 @@ GIT_EXTERN(int) git_repository_message(char *buffer, size_t len, git_repository */ GIT_EXTERN(int) git_repository_message_remove(git_repository *repo); +/** + * 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. + * + * @param out Output value of calculated SHA + * @param repo Repository pointer. NULL is allowed to just use global and + * system attributes for choosing filters. + * @param path Path to file on disk whose contents should be hashed. If the + * repository is not NULL, this can be a relative path. + * @param type The object type to hash as (e.g. GIT_OBJ_BLOB) + * @param 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. + */ +GIT_EXTERN(int) git_repository_hashfile( + git_oid *out, + git_repository *repo, + const char *path, + git_otype type, + const char *as_path); /** @} */ GIT_END_DECL |