@@ -111,7 +111,21 @@ static void initLibGit2()
111111git_oid hashToOID (const Hash & hash)
112112{
113113 git_oid oid;
114- if (git_oid_fromstr (&oid, hash.gitRev ().c_str ()))
114+ git_oid_t t;
115+ #pragma GCC diagnostic push
116+ #pragma GCC diagnostic ignored "-Wswitch-enum"
117+ switch (hash.algo ) {
118+ case HashAlgorithm::SHA1:
119+ t = GIT_OID_SHA1;
120+ break ;
121+ case HashAlgorithm::SHA256:
122+ t = GIT_OID_SHA256;
123+ break ;
124+ default :
125+ throw Error (" unsupported hash algorithm for Git: %s" , printHashAlgo (hash.algo ));
126+ }
127+ #pragma GCC diagnostic pop
128+ if (git_oid_fromstr (&oid, hash.gitRev ().c_str (), t))
115129 throw Error (" cannot convert '%s' to a Git OID" , hash.gitRev ());
116130 return oid;
117131}
@@ -304,7 +318,8 @@ struct GitRepoImpl : GitRepo, std::enable_shared_from_this<GitRepoImpl>
304318 // (synchronously on the git_packbuilder_write_buf thread)
305319 Indexer indexer;
306320 git_indexer_progress stats;
307- if (git_indexer_new (Setter (indexer), pack_dir_path.c_str (), 0 , nullptr , nullptr ))
321+ git_indexer_options indexer_opts = GIT_INDEXER_OPTIONS_INIT;
322+ if (git_indexer_new (Setter (indexer), pack_dir_path.c_str (), &indexer_opts))
308323 throw Error (" creating git packfile indexer: %s" , git_error_last ()->message );
309324
310325 // TODO: provide index callback for checkInterrupt() termination
0 commit comments