vendor/libgit2/src/libgit2/iterator.c in rugged-1.6.5 vs vendor/libgit2/src/libgit2/iterator.c in rugged-1.7.1

- old
+ new

@@ -1034,10 +1034,12 @@ git_tree *tree; git_index *index; git_vector index_snapshot; + git_oid_t oid_type; + git_array_t(filesystem_iterator_frame) frames; git_ignores ignores; /* info about the current entry */ git_index_entry entry; @@ -1269,21 +1271,21 @@ { git_str fullpath = GIT_STR_INIT; int error; if (S_ISDIR(entry->st.st_mode)) { - memset(&entry->id, 0, GIT_OID_SHA1_SIZE); + memset(&entry->id, 0, git_oid_size(iter->oid_type)); return 0; } if (iter->base.type == GIT_ITERATOR_WORKDIR) return git_repository_hashfile(&entry->id, iter->base.repo, entry->path, GIT_OBJECT_BLOB, NULL); 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, iter->oid_type); git_str_dispose(&fullpath); return error; } @@ -1528,11 +1530,11 @@ iter->entry.file_size = (uint32_t)entry->st.st_size; if (iter->base.flags & GIT_ITERATOR_INCLUDE_HASH) git_oid_cpy(&iter->entry.id, &entry->id); else - git_oid_clear(&iter->entry.id, GIT_OID_SHA1); + git_oid_clear(&iter->entry.id, iter->oid_type); iter->entry.path = entry->path; iter->current_is_ignored = GIT_IGNORE_UNCHECKED; } @@ -1973,10 +1975,12 @@ (iterator__ignore_case(&iter->base) ? GIT_FS_PATH_DIR_IGNORE_CASE : 0) | (iterator__flag(&iter->base, PRECOMPOSE_UNICODE) ? GIT_FS_PATH_DIR_PRECOMPOSE_UNICODE : 0); + iter->oid_type = options->oid_type; + if ((error = filesystem_iterator_init(iter)) < 0) goto on_error; *out = &iter->base; return 0; @@ -1987,14 +1991,19 @@ } int git_iterator_for_filesystem( git_iterator **out, const char *root, - git_iterator_options *options) + git_iterator_options *given_opts) { + git_iterator_options options = GIT_ITERATOR_OPTIONS_INIT; + + if (given_opts) + memcpy(&options, given_opts, sizeof(git_iterator_options)); + return iterator_for_filesystem(out, - NULL, root, NULL, NULL, GIT_ITERATOR_FS, options); + NULL, root, NULL, NULL, GIT_ITERATOR_FS, &options); } int git_iterator_for_workdir_ext( git_iterator **out, git_repository *repo, @@ -2016,9 +2025,15 @@ if (given_opts) memcpy(&options, given_opts, sizeof(git_iterator_options)); options.flags |= GIT_ITERATOR_HONOR_IGNORES | GIT_ITERATOR_IGNORE_DOT_GIT; + + if (!options.oid_type) + options.oid_type = repo->oid_type; + else if (options.oid_type != repo->oid_type) + git_error_set(GIT_ERROR_INVALID, + "specified object ID type does not match repository object ID type"); return iterator_for_filesystem(out, repo, repo_workdir, index, tree, GIT_ITERATOR_WORKDIR, &options); }