MCPcopy Create free account
hub / github.com/git/git / reftable_be_init

Function reftable_be_init

refs/reftable-backend.c:368–458  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

366}
367
368static struct ref_store *reftable_be_init(struct repository *repo,
369 const char *payload,
370 const char *gitdir,
371 const struct ref_store_init_options *opts)
372{
373 struct reftable_ref_store *refs = xcalloc(1, sizeof(*refs));
374 struct strbuf ref_common_dir = STRBUF_INIT;
375 struct strbuf refdir = STRBUF_INIT;
376 struct strbuf path = STRBUF_INIT;
377 bool is_worktree;
378 mode_t mask;
379
380 mask = umask(0);
381 umask(mask);
382
383 refs_compute_filesystem_location(gitdir, payload, &is_worktree, &refdir,
384 &ref_common_dir);
385
386 base_ref_store_init(&refs->base, repo, refdir.buf, &refs_be_reftable);
387 strmap_init(&refs->worktree_backends);
388 refs->log_all_ref_updates = opts->log_all_ref_updates;
389 refs->store_flags = opts->access_flags;
390
391 switch (repo->hash_algo->format_id) {
392 case GIT_SHA1_FORMAT_ID:
393 refs->write_options.hash_id = REFTABLE_HASH_SHA1;
394 break;
395 case GIT_SHA256_FORMAT_ID:
396 refs->write_options.hash_id = REFTABLE_HASH_SHA256;
397 break;
398 default:
399 BUG("unknown hash algorithm %d", repo->hash_algo->format_id);
400 }
401 refs->write_options.default_permissions = calc_shared_perm(repo, 0666 & ~mask);
402 refs->write_options.disable_auto_compact =
403 !git_env_bool("GIT_TEST_REFTABLE_AUTOCOMPACTION", 1);
404 refs->write_options.lock_timeout_ms = 100;
405
406 repo_config(repo, reftable_be_config, &refs->write_options);
407
408 /*
409 * It is somewhat unfortunate that we have to mirror the default block
410 * size of the reftable library here. But given that the write options
411 * wouldn't be updated by the library here, and given that we require
412 * the proper block size to trim reflog message so that they fit, we
413 * must set up a proper value here.
414 */
415 if (!refs->write_options.block_size)
416 refs->write_options.block_size = 4096;
417
418 /*
419 * Set up the main reftable stack that is hosted in GIT_COMMON_DIR.
420 * This stack contains both the shared and the main worktree refs.
421 */
422 strbuf_addbuf(&path, &ref_common_dir);
423 if (!is_worktree) {
424 strbuf_reset(&path);
425 strbuf_realpath(&path, ref_common_dir.buf, 0);

Callers

nothing calls this directly

Calls 13

xcallocFunction · 0.85
base_ref_store_initFunction · 0.85
strmap_initFunction · 0.85
calc_shared_permFunction · 0.85
git_env_boolFunction · 0.85
strbuf_addbufFunction · 0.85
strbuf_realpathFunction · 0.85
strbuf_addstrFunction · 0.85
reftable_backend_initFunction · 0.85
chdir_notify_reparentFunction · 0.85
strbuf_releaseFunction · 0.85

Tested by

no test coverage detected