Commit cf06de46 by Edward Thomson

iterator: support sha256

parent a47bc4ea
......@@ -1036,6 +1036,8 @@ typedef struct {
git_index *index;
git_vector index_snapshot;
git_oid_t oid_type;
git_array_t(filesystem_iterator_frame) frames;
git_ignores ignores;
......@@ -1271,7 +1273,7 @@ static int filesystem_iterator_entry_hash(
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;
}
......@@ -1281,7 +1283,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, iter->oid_type);
git_str_dispose(&fullpath);
return error;
......@@ -1530,7 +1532,7 @@ static void filesystem_iterator_set_current(
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;
......@@ -1975,6 +1977,8 @@ static int iterator_for_filesystem(
(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;
......@@ -1989,10 +1993,15 @@ on_error:
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(
......@@ -2019,6 +2028,12 @@ int git_iterator_for_workdir_ext(
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);
}
......
......@@ -63,6 +63,9 @@ typedef struct {
/* flags, from above */
unsigned int flags;
/* oid type - necessary for non-workdir filesystem iterators */
git_oid_t oid_type;
} git_iterator_options;
#define GIT_ITERATOR_OPTIONS_INIT {0}
......
......@@ -805,7 +805,9 @@ static void refdb_fs_backend__iterator_free(git_reference_iterator *_iter)
git__free(iter);
}
static int iter_load_loose_paths(refdb_fs_backend *backend, refdb_fs_iter *iter)
static int iter_load_loose_paths(
refdb_fs_backend *backend,
refdb_fs_iter *iter)
{
int error = 0;
git_str path = GIT_STR_INIT;
......@@ -819,6 +821,7 @@ static int iter_load_loose_paths(refdb_fs_backend *backend, refdb_fs_iter *iter)
return 0;
fsit_opts.flags = backend->iterator_flags;
fsit_opts.oid_type = backend->oid_type;
if (iter->glob) {
const char *last_sep = NULL;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment