From 11ef76a9f5bc04cb61760abebc68e6ac5045bf68 Mon Sep 17 00:00:00 2001 From: Edward Thomson Date: Sat, 22 Jan 2022 13:31:02 -0500 Subject: index: use a byte array for checksum The index's checksum is not an object ID, so we should not use the `git_oid` type. Use a byte array for checksum calculation and storage. Deprecate the `git_index_checksum` function without a replacement. This is an abstraction that callers should not care about (and indeed do not seem to be using). Remove the unused `git_index__changed_relative_to` function. --- include/git2/index.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include/git2') diff --git a/include/git2/index.h b/include/git2/index.h index 3cf64d827..981535dad 100644 --- a/include/git2/index.h +++ b/include/git2/index.h @@ -296,6 +296,7 @@ GIT_EXTERN(int) git_index_write(git_index *index); */ GIT_EXTERN(const char *) git_index_path(const git_index *index); +#ifndef GIT_DEPRECATE_HARD /** * Get the checksum of the index * @@ -303,10 +304,12 @@ GIT_EXTERN(const char *) git_index_path(const git_index *index); * last 20 bytes which are the checksum itself). In cases where the * index does not exist on-disk, it will be zeroed out. * + * @deprecated this function is deprecated with no replacement * @param index an existing index object * @return a pointer to the checksum of the index */ GIT_EXTERN(const git_oid *) git_index_checksum(git_index *index); +#endif /** * Read a tree into the index file with stats -- cgit v1.2.1 From d2458af7b7227f0b378e1509d7dfeb958c339590 Mon Sep 17 00:00:00 2001 From: Edward Thomson Date: Sat, 22 Jan 2022 14:19:13 -0500 Subject: indexer: use a byte array for checksum The index's checksum is not an object ID, so we should not use the `git_oid` type. Use a byte array for checksum calculation and storage. Deprecate the `git_indexer_hash` function. Callers should use the new `git_indexer_name` function which provides a unique packfile name. --- include/git2/indexer.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'include/git2') diff --git a/include/git2/indexer.h b/include/git2/indexer.h index 4bacbd317..ffe9bf366 100644 --- a/include/git2/indexer.h +++ b/include/git2/indexer.h @@ -129,16 +129,30 @@ GIT_EXTERN(int) git_indexer_append(git_indexer *idx, const void *data, size_t si */ GIT_EXTERN(int) git_indexer_commit(git_indexer *idx, git_indexer_progress *stats); +#ifndef GIT_DEPRECATE_HARD /** * Get the packfile's hash * * A packfile's name is derived from the sorted hashing of all object * names. This is only correct after the index has been finalized. * + * @deprecated use git_indexer_name * @param idx the indexer instance * @return the packfile's hash */ GIT_EXTERN(const git_oid *) git_indexer_hash(const git_indexer *idx); +#endif + +/** + * Get the unique name for the resulting packfile. + * + * The packfile's name is derived from the packfile's content. + * This is only correct after the index has been finalized. + * + * @param idx the indexer instance + * @return a NUL terminated string for the packfile name + */ +GIT_EXTERN(const char *) git_indexer_name(const git_indexer *idx); /** * Free the indexer and its resources -- cgit v1.2.1 From 70d9bfa47c14fd230d081cebb9933622136479ea Mon Sep 17 00:00:00 2001 From: Edward Thomson Date: Sat, 22 Jan 2022 17:34:36 -0500 Subject: packbuilder: use the packfile name instead of hash Deprecate the `git_packfile_hash` function. Callers should use the new `git_packfile_name` function which provides a unique packfile name. --- include/git2/pack.h | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) (limited to 'include/git2') diff --git a/include/git2/pack.h b/include/git2/pack.h index 253a860cd..0f6bd2ab9 100644 --- a/include/git2/pack.h +++ b/include/git2/pack.h @@ -170,16 +170,30 @@ GIT_EXTERN(int) git_packbuilder_write( git_indexer_progress_cb progress_cb, void *progress_cb_payload); +#ifndef GIT_DEPRECATE_HARD /** -* Get the packfile's hash -* -* A packfile's name is derived from the sorted hashing of all object -* names. This is only correct after the packfile has been written. -* -* @param pb The packbuilder object + * Get the packfile's hash + * + * A packfile's name is derived from the sorted hashing of all object + * names. This is only correct after the packfile has been written. + * + * @deprecated use git_packbuilder_name + * @param pb The packbuilder object * @return 0 or an error code -*/ + */ GIT_EXTERN(const git_oid *) git_packbuilder_hash(git_packbuilder *pb); +#endif + +/** + * Get the unique name for the resulting packfile. + * + * The packfile's name is derived from the packfile's content. + * This is only correct after the packfile has been written. + * + * @param pb the packbuilder instance + * @return a NUL terminated string for the packfile name + */ +GIT_EXTERN(const char *) git_packbuilder_name(git_packbuilder *pb); /** * Callback used to iterate over packed objects -- cgit v1.2.1