diff options
| author | Edward Thomson <ethomson@edwardthomson.com> | 2022-07-13 22:25:11 -0400 |
|---|---|---|
| committer | Edward Thomson <ethomson@edwardthomson.com> | 2022-07-13 22:50:33 -0400 |
| commit | b43567d655b6fbc562a165095a6980d19c4ae278 (patch) | |
| tree | ee84020f9f2c9f53a1f11656e2cd1205502cda48 /src/libgit2 | |
| parent | 433a133402fae298f8ee7613bcfd997c2712d269 (diff) | |
| download | libgit2-b43567d655b6fbc562a165095a6980d19c4ae278.tar.gz | |
sha256: indirection for experimental functions
The experimental function signature is only available when
`GIT_EXPERIMENTAL_SHA256` is enabled.
Diffstat (limited to 'src/libgit2')
| -rw-r--r-- | src/libgit2/commit_graph.c | 4 | ||||
| -rw-r--r-- | src/libgit2/diff_file.c | 4 | ||||
| -rw-r--r-- | src/libgit2/fetch.c | 3 | ||||
| -rw-r--r-- | src/libgit2/fetchhead.c | 2 | ||||
| -rw-r--r-- | src/libgit2/index.c | 4 | ||||
| -rw-r--r-- | src/libgit2/indexer.c | 2 | ||||
| -rw-r--r-- | src/libgit2/iterator.c | 2 | ||||
| -rw-r--r-- | src/libgit2/merge.c | 2 | ||||
| -rw-r--r-- | src/libgit2/midx.c | 4 | ||||
| -rw-r--r-- | src/libgit2/notes.c | 2 | ||||
| -rw-r--r-- | src/libgit2/object.c | 4 | ||||
| -rw-r--r-- | src/libgit2/odb.c | 74 | ||||
| -rw-r--r-- | src/libgit2/odb.h | 28 | ||||
| -rw-r--r-- | src/libgit2/odb_loose.c | 4 | ||||
| -rw-r--r-- | src/libgit2/oid.c | 55 | ||||
| -rw-r--r-- | src/libgit2/oid.h | 14 | ||||
| -rw-r--r-- | src/libgit2/pack.c | 10 | ||||
| -rw-r--r-- | src/libgit2/parse.c | 3 | ||||
| -rw-r--r-- | src/libgit2/patch_parse.c | 2 | ||||
| -rw-r--r-- | src/libgit2/reader.c | 2 | ||||
| -rw-r--r-- | src/libgit2/rebase.c | 10 | ||||
| -rw-r--r-- | src/libgit2/refdb_fs.c | 10 | ||||
| -rw-r--r-- | src/libgit2/reflog.c | 2 | ||||
| -rw-r--r-- | src/libgit2/remote.c | 2 | ||||
| -rw-r--r-- | src/libgit2/repository.c | 4 | ||||
| -rw-r--r-- | src/libgit2/revparse.c | 2 | ||||
| -rw-r--r-- | src/libgit2/transports/smart_pkt.c | 5 | ||||
| -rw-r--r-- | src/libgit2/tree-cache.c | 2 | ||||
| -rw-r--r-- | src/libgit2/tree.c | 2 |
29 files changed, 206 insertions, 58 deletions
diff --git a/src/libgit2/commit_graph.c b/src/libgit2/commit_graph.c index 2edf51a58..322d24b19 100644 --- a/src/libgit2/commit_graph.c +++ b/src/libgit2/commit_graph.c @@ -437,7 +437,7 @@ static int git_commit_graph_entry_get_byindex( } commit_data = file->commit_data + pos * (GIT_OID_SHA1_SIZE + 4 * sizeof(uint32_t)); - git_oid_fromraw(&e->tree_oid, commit_data, GIT_OID_SHA1); + git_oid__fromraw(&e->tree_oid, commit_data, GIT_OID_SHA1); e->parent_indices[0] = ntohl(*((uint32_t *)(commit_data + GIT_OID_SHA1_SIZE))); e->parent_indices[1] = ntohl( *((uint32_t *)(commit_data + GIT_OID_SHA1_SIZE + sizeof(uint32_t)))); @@ -471,7 +471,7 @@ static int git_commit_graph_entry_get_byindex( } } - git_oid_fromraw(&e->sha1, &file->oid_lookup[pos * GIT_OID_SHA1_SIZE], GIT_OID_SHA1); + git_oid__fromraw(&e->sha1, &file->oid_lookup[pos * GIT_OID_SHA1_SIZE], GIT_OID_SHA1); return 0; } diff --git a/src/libgit2/diff_file.c b/src/libgit2/diff_file.c index 4d63317eb..5f4336658 100644 --- a/src/libgit2/diff_file.c +++ b/src/libgit2/diff_file.c @@ -162,7 +162,7 @@ int git_diff_file_content__init_from_src( fc->flags |= GIT_DIFF_FLAG__FREE_BLOB; } else { int error; - if ((error = git_odb_hash(&fc->file->id, src->buf, src->buflen, GIT_OBJECT_BLOB, GIT_OID_SHA1)) < 0) + if ((error = git_odb__hash(&fc->file->id, src->buf, src->buflen, GIT_OBJECT_BLOB, GIT_OID_SHA1)) < 0) return error; fc->file->size = src->buflen; fc->file->id_abbrev = GIT_OID_SHA1_HEXSIZE; @@ -411,7 +411,7 @@ static int diff_file_content_load_workdir( /* once data is loaded, update OID if we didn't have it previously */ if (!error && (fc->file->flags & GIT_DIFF_FLAG_VALID_ID) == 0) { - error = git_odb_hash( + error = git_odb__hash( &fc->file->id, fc->map.data, fc->map.len, GIT_OBJECT_BLOB, GIT_OID_SHA1); fc->file->flags |= GIT_DIFF_FLAG_VALID_ID; diff --git a/src/libgit2/fetch.c b/src/libgit2/fetch.c index c27857078..5c2fee617 100644 --- a/src/libgit2/fetch.c +++ b/src/libgit2/fetch.c @@ -13,6 +13,7 @@ #include "git2/transport.h" #include "git2/sys/remote.h" +#include "oid.h" #include "remote.h" #include "refspec.h" #include "pack.h" @@ -75,7 +76,7 @@ static int maybe_want_oid(git_remote *remote, git_refspec *spec) oid_head = git__calloc(1, sizeof(git_remote_head)); GIT_ERROR_CHECK_ALLOC(oid_head); - git_oid_fromstr(&oid_head->oid, spec->src, GIT_OID_SHA1); + git_oid__fromstr(&oid_head->oid, spec->src, GIT_OID_SHA1); if (spec->dst) { oid_head->name = git__strdup(spec->dst); diff --git a/src/libgit2/fetchhead.c b/src/libgit2/fetchhead.c index 117d7a01d..0ebfe5c43 100644 --- a/src/libgit2/fetchhead.c +++ b/src/libgit2/fetchhead.c @@ -202,7 +202,7 @@ static int fetchhead_ref_parse( return -1; } - if (git_oid_fromstr(oid, oid_str, GIT_OID_SHA1) < 0) { + if (git_oid__fromstr(oid, oid_str, GIT_OID_SHA1) < 0) { const git_error *oid_err = git_error_last(); const char *err_msg = oid_err ? oid_err->message : "invalid object ID"; diff --git a/src/libgit2/index.c b/src/libgit2/index.c index 91d74a01e..1821f6027 100644 --- a/src/libgit2/index.c +++ b/src/libgit2/index.c @@ -2359,7 +2359,7 @@ static int read_reuc(git_index *index, const char *buffer, size_t size) return index_error_invalid("reading reuc entry oid"); } - if (git_oid_fromraw(&lost->oid[i], (const unsigned char *) buffer, GIT_OID_SHA1) < 0) + if (git_oid__fromraw(&lost->oid[i], (const unsigned char *) buffer, GIT_OID_SHA1) < 0) return -1; size -= GIT_OID_SHA1_SIZE; @@ -2484,7 +2484,7 @@ static int read_entry( entry.file_size = ntohl(source.file_size); entry.flags = ntohs(source.flags); - if (git_oid_fromraw(&entry.id, source.oid, GIT_OID_SHA1) < 0) + if (git_oid__fromraw(&entry.id, source.oid, GIT_OID_SHA1) < 0) return -1; if (entry.flags & GIT_INDEX_ENTRY_EXTENDED) { diff --git a/src/libgit2/indexer.c b/src/libgit2/indexer.c index ace73386c..62bb70393 100644 --- a/src/libgit2/indexer.c +++ b/src/libgit2/indexer.c @@ -1051,7 +1051,7 @@ static int fix_thin_pack(git_indexer *idx, git_indexer_progress *stats) return -1; } - git_oid_fromraw(&base, base_info, GIT_OID_SHA1); + git_oid__fromraw(&base, base_info, GIT_OID_SHA1); git_mwindow_close(&w); if (has_entry(idx, &base)) diff --git a/src/libgit2/iterator.c b/src/libgit2/iterator.c index a8377f704..1ee8e25f5 100644 --- a/src/libgit2/iterator.c +++ b/src/libgit2/iterator.c @@ -1281,7 +1281,7 @@ static int filesystem_iterator_entry_hash( if (!(error = git_str_joinpath(&fullpath, iter->root, entry->path)) && !(error = git_path_validate_str_length(iter->base.repo, &fullpath))) - error = git_odb_hashfile(&entry->id, fullpath.ptr, GIT_OBJECT_BLOB, GIT_OID_SHA1); + error = git_odb__hashfile(&entry->id, fullpath.ptr, GIT_OBJECT_BLOB, GIT_OID_SHA1); git_str_dispose(&fullpath); return error; diff --git a/src/libgit2/merge.c b/src/libgit2/merge.c index 06c52a67c..df2cefb29 100644 --- a/src/libgit2/merge.c +++ b/src/libgit2/merge.c @@ -617,7 +617,7 @@ int git_repository_mergehead_foreach( goto cleanup; } - if ((error = git_oid_fromstr(&oid, line, GIT_OID_SHA1)) < 0) + if ((error = git_oid__fromstr(&oid, line, GIT_OID_SHA1)) < 0) goto cleanup; if ((error = cb(&oid, payload)) != 0) { diff --git a/src/libgit2/midx.c b/src/libgit2/midx.c index 8c0b8df40..51b2d6cc7 100644 --- a/src/libgit2/midx.c +++ b/src/libgit2/midx.c @@ -443,7 +443,7 @@ int git_midx_entry_find( return midx_error("invalid index into the packfile names table"); e->pack_index = pack_index; e->offset = offset; - git_oid_fromraw(&e->sha1, current, GIT_OID_SHA1); + git_oid__fromraw(&e->sha1, current, GIT_OID_SHA1); return 0; } @@ -459,7 +459,7 @@ int git_midx_foreach_entry( GIT_ASSERT_ARG(idx); for (i = 0; i < idx->num_objects; ++i) { - if ((error = git_oid_fromraw(&oid, &idx->oid_lookup[i * GIT_OID_SHA1_SIZE], GIT_OID_SHA1)) < 0) + if ((error = git_oid__fromraw(&oid, &idx->oid_lookup[i * GIT_OID_SHA1_SIZE], GIT_OID_SHA1)) < 0) return error; if ((error = cb(&oid, data)) != 0) diff --git a/src/libgit2/notes.c b/src/libgit2/notes.c index 08395aef5..1b1935330 100644 --- a/src/libgit2/notes.c +++ b/src/libgit2/notes.c @@ -703,7 +703,7 @@ static int process_entry_path( goto cleanup; } - error = git_oid_fromstr(annotated_object_id, buf.ptr, GIT_OID_SHA1); + error = git_oid__fromstr(annotated_object_id, buf.ptr, GIT_OID_SHA1); cleanup: git_str_dispose(&buf); diff --git a/src/libgit2/object.c b/src/libgit2/object.c index 1e939384c..d45465678 100644 --- a/src/libgit2/object.c +++ b/src/libgit2/object.c @@ -86,7 +86,7 @@ int git_object__from_raw( GIT_ERROR_CHECK_ALLOC(object); object->cached.flags = GIT_CACHE_STORE_PARSED; object->cached.type = type; - if ((error = git_odb_hash(&object->cached.oid, data, size, type, GIT_OID_SHA1)) < 0) + if ((error = git_odb__hash(&object->cached.oid, data, size, type, GIT_OID_SHA1)) < 0) return error; /* Parse raw object data */ @@ -625,7 +625,7 @@ int git_object__parse_oid_header( if (buffer[header_len + sha_len] != '\n') return -1; - if (git_oid_fromstr(oid, buffer + header_len, oid_type) < 0) + if (git_oid__fromstr(oid, buffer + header_len, oid_type) < 0) return -1; *buffer_out = buffer + (header_len + sha_len + 1); diff --git a/src/libgit2/odb.c b/src/libgit2/odb.c index 00d68d6f4..aa2dd3cb2 100644 --- a/src/libgit2/odb.c +++ b/src/libgit2/odb.c @@ -291,7 +291,7 @@ int git_odb__hashfd_filtered( error = git_filter_list__convert_buf(&post, fl, &raw); if (!error) - error = git_odb_hash(out, post.ptr, post.size, object_type, oid_type); + error = git_odb__hash(out, post.ptr, post.size, object_type, oid_type); git_str_dispose(&post); } @@ -333,7 +333,7 @@ int git_odb__hashlink(git_oid *out, const char *path, git_oid_t oid_type) GIT_ASSERT(read_len <= size); link_data[read_len] = '\0'; - result = git_odb_hash(out, link_data, read_len, GIT_OBJECT_BLOB, oid_type); + result = git_odb__hash(out, link_data, read_len, GIT_OBJECT_BLOB, oid_type); git__free(link_data); } else { int fd = git_futils_open_ro(path); @@ -346,7 +346,7 @@ int git_odb__hashlink(git_oid *out, const char *path, git_oid_t oid_type) return result; } -int git_odb_hashfile( +int git_odb__hashfile( git_oid *out, const char *path, git_object_t object_type, @@ -374,7 +374,26 @@ done: return error; } -int git_odb_hash( +#ifdef GIT_EXPERIMENTAL_SHA256 +int git_odb_hashfile( + git_oid *out, + const char *path, + git_object_t object_type, + git_oid_t oid_type) +{ + return git_odb__hashfile(out, path, object_type, oid_type); +} +#else +int git_odb_hashfile( + git_oid *out, + const char *path, + git_object_t object_type) +{ + return git_odb__hashfile(out, path, object_type, GIT_OID_SHA1); +} +#endif + +int git_odb__hash( git_oid *id, const void *data, size_t len, @@ -392,6 +411,27 @@ int git_odb_hash( return git_odb__hashobj(id, &raw, oid_type); } +#ifdef GIT_EXPERIMENTAL_SHA256 +int git_odb_hash( + git_oid *out, + const void *data, + size_t len, + git_object_t object_type, + git_oid_t oid_type) +{ + return git_odb__hash(out, data, len, object_type, oid_type); +} +#else +int git_odb_hash( + git_oid *out, + const void *data, + size_t len, + git_object_t type) +{ + return git_odb__hash(out, data, len, type, GIT_OID_SHA1); +} +#endif + /** * FAKE WSTREAM */ @@ -496,7 +536,7 @@ static void normalize_options( opts->oid_type = GIT_OID_DEFAULT; } -int git_odb_new(git_odb **out, const git_odb_options *opts) +int git_odb__new(git_odb **out, const git_odb_options *opts) { git_odb *db = git__calloc(1, sizeof(*db)); GIT_ERROR_CHECK_ALLOC(db); @@ -524,6 +564,18 @@ int git_odb_new(git_odb **out, const git_odb_options *opts) return 0; } +#ifdef GIT_EXPERIMENTAL_SHA256 +int git_odb_new(git_odb **out, const git_odb_options *opts) +{ + return git_odb__new(out, opts); +} +#else +int git_odb_new(git_odb **out) +{ + return git_odb__new(out, NULL); +} +#endif + static int add_backend_internal( git_odb *odb, git_odb_backend *backend, int priority, bool is_alternate, ino_t disk_inode) @@ -672,7 +724,7 @@ int git_odb__add_default_backends( loose_opts.oid_type = db->options.oid_type; /* add the loose object backend */ - if (git_odb_backend_loose(&loose, objects_dir, &loose_opts) < 0 || + if (git_odb__backend_loose(&loose, objects_dir, &loose_opts) < 0 || add_backend_internal(db, loose, git_odb__loose_priority, as_alternates, inode) < 0) return -1; @@ -769,7 +821,7 @@ int git_odb_set_commit_graph(git_odb *odb, git_commit_graph *cgraph) return error; } -int git_odb_open( +int git_odb__open( git_odb **out, const char *objects_dir, const git_odb_options *opts) @@ -781,7 +833,7 @@ int git_odb_open( *out = NULL; - if (git_odb_new(&db, opts) < 0) + if (git_odb__new(&db, opts) < 0) return -1; if (git_odb__add_default_backends(db, objects_dir, 0, 0) < 0) { @@ -1294,7 +1346,7 @@ static int odb_read_1( return GIT_ENOTFOUND; if (git_odb__strict_hash_verification) { - if ((error = git_odb_hash(&hashed, raw.data, raw.len, raw.type, db->options.oid_type)) < 0) + if ((error = git_odb__hash(&hashed, raw.data, raw.len, raw.type, db->options.oid_type)) < 0) goto out; if (!git_oid_equal(id, &hashed)) { @@ -1435,7 +1487,7 @@ static int read_prefix_1(git_odb_object **out, git_odb *db, if (git_odb__strict_hash_verification) { git_oid hash; - if ((error = git_odb_hash(&hash, raw.data, raw.len, raw.type, db->options.oid_type)) < 0) + if ((error = git_odb__hash(&hash, raw.data, raw.len, raw.type, db->options.oid_type)) < 0) goto out; if (!git_oid_equal(&found_full_oid, &hash)) { @@ -1536,7 +1588,7 @@ int git_odb_write( GIT_ASSERT_ARG(oid); GIT_ASSERT_ARG(db); - if ((error = git_odb_hash(oid, data, len, type, db->options.oid_type)) < 0) + if ((error = git_odb__hash(oid, data, len, type, db->options.oid_type)) < 0) return error; if (git_oid_is_zero(oid)) diff --git a/src/libgit2/odb.h b/src/libgit2/odb.h index 6baa45b82..7a712e202 100644 --- a/src/libgit2/odb.h +++ b/src/libgit2/odb.h @@ -10,6 +10,7 @@ #include "common.h" #include "git2/odb.h" +#include "git2/odb_backend.h" #include "git2/oid.h" #include "git2/types.h" #include "git2/sys/commit_graph.h" @@ -157,4 +158,31 @@ int git_odb__freshen(git_odb *db, const git_oid *id); /* fully free the object; internal method, DO NOT EXPORT */ void git_odb_object__free(void *object); +/* SHA256 support */ + +int git_odb__new(git_odb **out, const git_odb_options *opts); + +int git_odb__open( + git_odb **out, + const char *objects_dir, + const git_odb_options *opts); + +int git_odb__hash( + git_oid *out, + const void *data, + size_t len, + git_object_t object_type, + git_oid_t oid_type); + +int git_odb__hashfile( + git_oid *out, + const char *path, + git_object_t object_type, + git_oid_t oid_type); + +GIT_EXTERN(int) git_odb__backend_loose( + git_odb_backend **out, + const char *objects_dir, + git_odb_backend_loose_options *opts); + #endif diff --git a/src/libgit2/odb_loose.c b/src/libgit2/odb_loose.c index 49180bbd1..d1abbe233 100644 --- a/src/libgit2/odb_loose.c +++ b/src/libgit2/odb_loose.c @@ -552,7 +552,7 @@ static int locate_object_short_oid( return git_odb__error_ambiguous("multiple matches in loose objects"); /* Convert obtained hex formatted oid to raw */ - error = git_oid_fromstr(res_oid, (char *)state.res_oid, backend->options.oid_type); + error = git_oid__fromstr(res_oid, (char *)state.res_oid, backend->options.oid_type); if (error) return error; @@ -1161,7 +1161,7 @@ static void normalize_options( opts->oid_type = GIT_OID_DEFAULT; } -int git_odb_backend_loose( +int git_odb__backend_loose( git_odb_backend **backend_out, const char *objects_dir, git_odb_backend_loose_options *opts) diff --git a/src/libgit2/oid.c b/src/libgit2/oid.c index cea70c3b3..6cc21641d 100644 --- a/src/libgit2/oid.c +++ b/src/libgit2/oid.c @@ -28,7 +28,7 @@ static int oid_error_invalid(const char *msg) return -1; } -int git_oid_fromstrn( +int git_oid__fromstrn( git_oid *out, const char *str, size_t length, @@ -65,6 +65,26 @@ int git_oid_fromstrn( return 0; } +int git_oid__fromstrp(git_oid *out, const char *str, git_oid_t type) +{ + return git_oid__fromstrn(out, str, strlen(str), type); +} + +int git_oid__fromstr(git_oid *out, const char *str, git_oid_t type) +{ + return git_oid__fromstrn(out, str, git_oid_hexsize(type), type); +} + +#ifdef GIT_EXPERIMENTAL_SHA256 +int git_oid_fromstrn( + git_oid *out, + const char *str, + size_t length, + git_oid_t type) +{ + return git_oid__fromstrn(out, str, length, type); +} + int git_oid_fromstrp(git_oid *out, const char *str, git_oid_t type) { return git_oid_fromstrn(out, str, strlen(str), type); @@ -74,6 +94,25 @@ int git_oid_fromstr(git_oid *out, const char *str, git_oid_t type) { return git_oid_fromstrn(out, str, git_oid_hexsize(type), type); } +#else +int git_oid_fromstrn( + git_oid *out, + const char *str, + size_t length) +{ + return git_oid__fromstrn(out, str, length, GIT_OID_SHA1); +} + +int git_oid_fromstrp(git_oid *out, const char *str) +{ + return git_oid__fromstrn(out, str, strlen(str), GIT_OID_SHA1); +} + +int git_oid_fromstr(git_oid *out, const char *str) +{ + return git_oid__fromstrn(out, str, GIT_OID_SHA1_HEXSIZE, GIT_OID_SHA1); +} +#endif int git_oid_nfmt(char *str, size_t n, const git_oid *oid) { @@ -155,7 +194,7 @@ char *git_oid_tostr(char *out, size_t n, const git_oid *oid) return out; } -int git_oid_fromraw(git_oid *out, const unsigned char *raw, git_oid_t type) +int git_oid__fromraw(git_oid *out, const unsigned char *raw, git_oid_t type) { size_t size; @@ -169,6 +208,18 @@ int git_oid_fromraw(git_oid *out, const unsigned char *raw, git_oid_t type) return 0; } +#ifdef GIT_EXPERIMENTAL_SHA256 +int git_oid_fromraw(git_oid *out, const unsigned char *raw, git_oid_t type) +{ + return git_oid__fromraw(out, raw, type); +} +#else +int git_oid_fromraw(git_oid *out, const unsigned char *raw) +{ + return git_oid__fromraw(out, raw, GIT_OID_SHA1); +} +#endif + int git_oid_cpy(git_oid *out, const git_oid *src) { size_t size; diff --git a/src/libgit2/oid.h b/src/libgit2/oid.h index 47d2327e9..d775e180b 100644 --- a/src/libgit2/oid.h +++ b/src/libgit2/oid.h @@ -215,4 +215,18 @@ GIT_INLINE(void) git_oid_clear(git_oid *out, git_oid_t type) #endif } +/* SHA256 support */ + +int git_oid__fromstr(git_oid *out, const char *str, git_oid_t type); + +int git_oid__fromstrp(git_oid *out, const char *str, git_oid_t type); + +int git_oid__fromstrn( + git_oid *out, + const char *str, + size_t length, + git_oid_t type); + +int git_oid__fromraw(git_oid *out, const unsigned char *raw, git_oid_t type); + #endif diff --git a/src/libgit2/pack.c b/src/libgit2/pack.c index 18f51d107..d428729ea 100644 --- a/src/libgit2/pack.c +++ b/src/libgit2/pack.c @@ -1002,7 +1002,7 @@ int get_delta_base( *curpos += used; } else if (type == GIT_OBJECT_REF_DELTA) { git_oid base_oid; - git_oid_fromraw(&base_oid, base_info, GIT_OID_SHA1); + git_oid__fromraw(&base_oid, base_info, GIT_OID_SHA1); /* If we have the cooperative cache, search in it first */ if (p->has_cache) { @@ -1362,7 +1362,7 @@ int git_pack_foreach_entry( git_array_clear(oids); GIT_ERROR_CHECK_ALLOC(oid); } - git_oid_fromraw(oid, p->oids[i], GIT_OID_SHA1); + git_oid__fromraw(oid, p->oids[i], GIT_OID_SHA1); } git_mutex_unlock(&p->lock); @@ -1428,7 +1428,7 @@ int git_pack_foreach_entry_offset( ntohl(*((uint32_t *)(large_offset_ptr + 4))); } - git_oid_fromraw(¤t_oid, (index + 20 * i), GIT_OID_SHA1); + git_oid__fromraw(¤t_oid, (index + 20 * i), GIT_OID_SHA1); if ((error = cb(¤t_oid, current_offset, data)) != 0) { error = git_error_set_after_callback(error); goto cleanup; @@ -1437,7 +1437,7 @@ int git_pack_foreach_entry_offset( } else { for (i = 0; i < p->num_objects; i++) { current_offset = ntohl(*(const uint32_t *)(index + 24 * i)); - git_oid_fromraw(¤t_oid, (index + 24 * i + 4), GIT_OID_SHA1); + git_oid__fromraw(¤t_oid, (index + 24 * i + 4), GIT_OID_SHA1); if ((error = cb(¤t_oid, current_offset, data)) != 0) { error = git_error_set_after_callback(error); goto cleanup; @@ -1566,7 +1566,7 @@ static int pack_entry_find_offset( } *offset_out = offset; - git_oid_fromraw(found_oid, current, GIT_OID_SHA1); + git_oid__fromraw(found_oid, current, GIT_OID_SHA1); #ifdef INDEX_DEBUG_LOOKUP { diff --git a/src/libgit2/parse.c b/src/libgit2/parse.c index 703a6cdff..55d3cb10e 100644 --- a/src/libgit2/parse.c +++ b/src/libgit2/parse.c @@ -5,6 +5,7 @@ * a Linking Exception. For full terms see the included COPYING file. */ #include "parse.h" +#include "oid.h" int git_parse_ctx_init(git_parse_ctx *ctx, const char *content, size_t content_len) { @@ -105,7 +106,7 @@ int git_parse_advance_oid(git_oid *out, git_parse_ctx *ctx) { if (ctx->line_len < GIT_OID_SHA1_HEXSIZE) return -1; - if ((git_oid_fromstrn(out, ctx->line, GIT_OID_SHA1_HEXSIZE, GIT_OID_SHA1)) < 0) + if ((git_oid__fromstrn(out, ctx->line, GIT_OID_SHA1_HEXSIZE, GIT_OID_SHA1)) < 0) return -1; git_parse_advance_chars(ctx, GIT_OID_SHA1_HEXSIZE); return 0; diff --git a/src/libgit2/patch_parse.c b/src/libgit2/patch_parse.c index a3c7a6458..ffdb99231 100644 --- a/src/libgit2/patch_parse.c +++ b/src/libgit2/patch_parse.c @@ -174,7 +174,7 @@ static int parse_header_oid( } if (len < GIT_OID_MINPREFIXLEN || len > GIT_OID_SHA1_HEXSIZE || - git_oid_fromstrn(oid, ctx->parse_ctx.line, len, GIT_OID_SHA1) < 0) + git_oid__fromstrn(oid, ctx->parse_ctx.line, len, GIT_OID_SHA1) < 0) return git_parse_err("invalid hex formatted object id at line %"PRIuZ, ctx->parse_ctx.line_num); diff --git a/src/libgit2/reader.c b/src/libgit2/reader.c index 0ff9c89c3..be29bb41c 100644 --- a/src/libgit2/reader.c +++ b/src/libgit2/reader.c @@ -125,7 +125,7 @@ static int workdir_reader_read( goto done; if (out_id || reader->index) { - if ((error = git_odb_hash(&id, out->ptr, out->size, GIT_OBJECT_BLOB, GIT_OID_SHA1)) < 0) + if ((error = git_odb__hash(&id, out->ptr, out->size, GIT_OBJECT_BLOB, GIT_OID_SHA1)) < 0) goto done; } diff --git a/src/libgit2/rebase.c b/src/libgit2/rebase.c index 0b0c615df..1970d5ddc 100644 --- a/src/libgit2/rebase.c +++ b/src/libgit2/rebase.c @@ -182,7 +182,7 @@ GIT_INLINE(int) rebase_readoid( return error; if (str_out->size != GIT_OID_SHA1_HEXSIZE || - git_oid_fromstr(out, str_out->ptr, GIT_OID_SHA1) < 0) { + git_oid__fromstr(out, str_out->ptr, GIT_OID_SHA1) < 0) { git_error_set(GIT_ERROR_REBASE, "the file '%s' contains an invalid object ID", filename); return -1; } @@ -364,7 +364,7 @@ int git_rebase_open( git_str_rtrim(&orig_head_id); - if ((error = git_oid_fromstr(&rebase->orig_head_id, orig_head_id.ptr, GIT_OID_SHA1)) < 0) + if ((error = git_oid__fromstr(&rebase->orig_head_id, orig_head_id.ptr, GIT_OID_SHA1)) < 0) goto done; git_str_truncate(&path, state_path_len); @@ -375,7 +375,7 @@ int git_rebase_open( git_str_rtrim(&onto_id); - if ((error = git_oid_fromstr(&rebase->onto_id, onto_id.ptr, GIT_OID_SHA1)) < 0) + if ((error = git_oid__fromstr(&rebase->onto_id, onto_id.ptr, GIT_OID_SHA1)) < 0) goto done; if (!rebase->head_detached) @@ -1344,8 +1344,8 @@ static int rebase_copy_notes( if (strlen(fromstr) != GIT_OID_SHA1_HEXSIZE || strlen(tostr) != GIT_OID_SHA1_HEXSIZE || - git_oid_fromstr(&from, fromstr, GIT_OID_SHA1) < 0 || - git_oid_fromstr(&to, tostr, GIT_OID_SHA1) < 0) + git_oid__fromstr(&from, fromstr, GIT_OID_SHA1) < 0 || + git_oid__fromstr(&to, tostr, GIT_OID_SHA1) < 0) goto on_error; if ((error = rebase_copy_note(rebase, notes_ref.ptr, &from, &to, committer)) < 0) diff --git a/src/libgit2/refdb_fs.c b/src/libgit2/refdb_fs.c index 87fcb9118..43283b3e4 100644 --- a/src/libgit2/refdb_fs.c +++ b/src/libgit2/refdb_fs.c @@ -158,7 +158,7 @@ static int packed_reload(refdb_fs_backend *backend) /* parse "<OID> <refname>\n" */ - if (git_oid_fromstr(&oid, scan, GIT_OID_SHA1) < 0) + if (git_oid__fromstr(&oid, scan, GIT_OID_SHA1) < 0) goto parse_failed; scan += GIT_OID_SHA1_HEXSIZE; @@ -179,7 +179,7 @@ static int packed_reload(refdb_fs_backend *backend) /* look for optional "^<OID>\n" */ if (*scan == '^') { - if (git_oid_fromstr(&oid, scan + 1, GIT_OID_SHA1) < 0) + if (git_oid__fromstr(&oid, scan + 1, GIT_OID_SHA1) < 0) goto parse_failed; scan += GIT_OID_SHA1_HEXSIZE + 1; @@ -222,7 +222,7 @@ static int loose_parse_oid( goto corrupted; /* we need to get 40 OID characters from the file */ - if (git_oid_fromstr(oid, str, GIT_OID_SHA1) < 0) + if (git_oid__fromstr(oid, str, GIT_OID_SHA1) < 0) goto corrupted; /* If the file is longer than 40 chars, the 41st must be a space */ @@ -709,7 +709,7 @@ static int packed_lookup( git_oid oid, peel, *peel_ptr = NULL; if (data_end - rec < GIT_OID_SHA1_HEXSIZE || - git_oid_fromstr(&oid, rec, GIT_OID_SHA1) < 0) { + git_oid__fromstr(&oid, rec, GIT_OID_SHA1) < 0) { goto parse_failed; } rec += GIT_OID_SHA1_HEXSIZE + 1; @@ -725,7 +725,7 @@ static int packed_lookup( if (*rec == '^') { rec++; if (data_end - rec < GIT_OID_SHA1_HEXSIZE || - git_oid_fromstr(&peel, rec, GIT_OID_SHA1) < 0) { + git_oid__fromstr(&peel, rec, GIT_OID_SHA1) < 0) { goto parse_failed; } peel_ptr = &peel; diff --git a/src/libgit2/reflog.c b/src/libgit2/reflog.c index 1b03e83e7..eb0b7e48c 100644 --- a/src/libgit2/reflog.c +++ b/src/libgit2/reflog.c @@ -104,7 +104,7 @@ int git_reflog_append(git_reflog *reflog, const git_oid *new_oid, const git_sign previous = git_reflog_entry_byindex(reflog, 0); if (previous == NULL) - git_oid_fromstr(&entry->oid_old, GIT_OID_SHA1_HEXZERO, GIT_OID_SHA1); + git_oid__fromstr(&entry->oid_old, GIT_OID_SHA1_HEXZERO, GIT_OID_SHA1); else git_oid_cpy(&entry->oid_old, &previous->oid_cur); diff --git a/src/libgit2/remote.c b/src/libgit2/remote.c index 3330347bd..02d271d7d 100644 --- a/src/libgit2/remote.c +++ b/src/libgit2/remote.c @@ -1895,7 +1895,7 @@ static int update_tips_for_spec( if (git_oid__is_hexstr(spec->src, GIT_OID_SHA1)) { git_oid id; - if ((error = git_oid_fromstr(&id, spec->src, GIT_OID_SHA1)) < 0) + if ((error = git_oid__fromstr(&id, spec->src, GIT_OID_SHA1)) < 0) goto on_error; if (spec->dst && diff --git a/src/libgit2/repository.c b/src/libgit2/repository.c index 6bdb92d34..90ac91db9 100644 --- a/src/libgit2/repository.c +++ b/src/libgit2/repository.c @@ -843,7 +843,7 @@ static int _git_repository_open_ext_from_env( else if (error < 0) goto error; else { - error = git_odb_open(&odb, git_str_cstr(&object_dir_buf), NULL); + error = git_odb__open(&odb, git_str_cstr(&object_dir_buf), NULL); if (error < 0) goto error; } @@ -1268,7 +1268,7 @@ int git_repository_odb__weakptr(git_odb **out, git_repository *repo) if ((error = git_repository__item_path(&odb_path, repo, GIT_REPOSITORY_ITEM_OBJECTS)) < 0 || - (error = git_odb_new(&odb, NULL)) < 0) + (error = git_odb__new(&odb, NULL)) < 0) return error; GIT_REFCOUNT_OWN(odb, repo); diff --git a/src/libgit2/revparse.c b/src/libgit2/revparse.c index 1f3dc6c13..2ed282159 100644 --- a/src/libgit2/revparse.c +++ b/src/libgit2/revparse.c @@ -19,7 +19,7 @@ static int maybe_sha_or_abbrev(git_object **out, git_repository *repo, const cha { git_oid oid; - if (git_oid_fromstrn(&oid, spec, speclen, GIT_OID_SHA1) < 0) + if (git_oid__fromstrn(&oid, spec, speclen, GIT_OID_SHA1) < 0) return GIT_ENOTFOUND; return git_object_lookup_prefix(out, repo, &oid, speclen, GIT_OBJECT_ANY); diff --git a/src/libgit2/transports/smart_pkt.c b/src/libgit2/transports/smart_pkt.c index b11417f3e..e679819fa 100644 --- a/src/libgit2/transports/smart_pkt.c +++ b/src/libgit2/transports/smart_pkt.c @@ -12,6 +12,7 @@ #include "netops.h" #include "posix.h" #include "str.h" +#include "oid.h" #include "git2/types.h" #include "git2/errors.h" @@ -54,7 +55,7 @@ static int ack_pkt(git_pkt **out, const char *line, size_t len) len -= 4; if (len < GIT_OID_SHA1_HEXSIZE || - git_oid_fromstr(&pkt->oid, line, GIT_OID_SHA1) < 0) + git_oid__fromstr(&pkt->oid, line, GIT_OID_SHA1) < 0) goto out_err; line += GIT_OID_SHA1_HEXSIZE; len -= GIT_OID_SHA1_HEXSIZE; @@ -224,7 +225,7 @@ static int ref_pkt(git_pkt **out, const char *line, size_t len) pkt->type = GIT_PKT_REF; if (len < GIT_OID_SHA1_HEXSIZE || - git_oid_fromstr(&pkt->head.oid, line, GIT_OID_SHA1) < 0) + git_oid__fromstr(&pkt->head.oid, line, GIT_OID_SHA1) < 0) goto out_err; line += GIT_OID_SHA1_HEXSIZE; len -= GIT_OID_SHA1_HEXSIZE; diff --git a/src/libgit2/tree-cache.c b/src/libgit2/tree-cache.c index 59d124c0c..19fad85ae 100644 --- a/src/libgit2/tree-cache.c +++ b/src/libgit2/tree-cache.c @@ -114,7 +114,7 @@ static int read_tree_internal(git_tree_cache **out, if (buffer + GIT_OID_SHA1_SIZE > buffer_end) goto corrupted; - git_oid_fromraw(&tree->oid, (const unsigned char *)buffer, GIT_OID_SHA1); + git_oid__fromraw(&tree->oid, (const unsigned char *)buffer, GIT_OID_SHA1); buffer += GIT_OID_SHA1_SIZE; } diff --git a/src/libgit2/tree.c b/src/libgit2/tree.c index 0676192d3..9a43d585c 100644 --- a/src/libgit2/tree.c +++ b/src/libgit2/tree.c @@ -425,7 +425,7 @@ int git_tree__parse_raw(void *_tree, const char *data, size_t size) entry->attr = attr; entry->filename_len = (uint16_t)filename_len; entry->filename = buffer; - git_oid_fromraw(&entry->oid, ((unsigned char *) buffer + filename_len + 1), GIT_OID_SHA1); + git_oid__fromraw(&entry->oid, ((unsigned char *) buffer + filename_len + 1), GIT_OID_SHA1); } buffer += filename_len + 1; |
