From: Junio C Hamano Date: Mon, 6 Jul 2026 22:50:24 +0000 (-0700) Subject: Merge branch 'ps/refs-onbranch-fixes' X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3442a0fb7927f3bb6710c1c75f03b4f783605d57;p=thirdparty%2Fgit.git Merge branch 'ps/refs-onbranch-fixes' Reference backend configuration has been updated to load lazily to avoid recursive calls during repository initialization when 'onbranch' configuration conditions are evaluated. This has also fixed a memory leak and allowed the unused `chdir_notify_reparent()` machinery to be dropped. * ps/refs-onbranch-fixes: refs: protect against chicken-and-egg recursion refs/reftable: lazy-load configuration to fix chicken-and-egg reftable: split up write options refs/files: lazy-load configuration to fix chicken-and-egg refs: move parsing of "core.logAllRefUpdates" back into ref stores repository: free main reference database chdir-notify: drop unused `chdir_notify_reparent()` refs: unregister reference stores from "chdir_notify" setup: don't apply "GIT_REFERENCE_BACKEND" without a repository setup: stop applying repository format twice setup: inline `check_and_apply_repository_format()` --- 3442a0fb7927f3bb6710c1c75f03b4f783605d57 diff --cc refs/reftable-backend.c index c151d331e7,d74131a5ae..212408c769 --- a/refs/reftable-backend.c +++ b/refs/reftable-backend.c @@@ -1417,6 -1441,26 +1439,26 @@@ static int transaction_update_cmp(cons return strcmp(update_a->update->refname, update_b->update->refname); } + static int should_write_log(struct reftable_ref_store *refs, const char *refname) + { + enum log_refs_config log_refs_cfg = reftable_be_write_options(refs)->log_all_ref_updates; + if (log_refs_cfg == LOG_REFS_UNSET) - log_refs_cfg = is_bare_repository() ? LOG_REFS_NONE : LOG_REFS_NORMAL; ++ log_refs_cfg = is_bare_repository(refs->base.repo) ? LOG_REFS_NONE : LOG_REFS_NORMAL; + + switch (log_refs_cfg) { + case LOG_REFS_NONE: + return refs_reflog_exists(&refs->base, refname); + case LOG_REFS_ALWAYS: + return 1; + case LOG_REFS_NORMAL: + if (should_autocreate_reflog(log_refs_cfg, refname)) + return 1; + return refs_reflog_exists(&refs->base, refname); + default: + BUG("unhandled core.logAllRefUpdates value %d", log_refs_cfg); + } + } + static int write_transaction_table(struct reftable_writer *writer, void *cb_data) { struct write_transaction_table_arg *arg = cb_data; diff --cc setup.c index 1eb7dba367,592753457c..0de56a074f --- a/setup.c +++ b/setup.c @@@ -2610,13 -2581,17 +2591,17 @@@ static int create_default_files(struct } repo_config_set(repo, "core.filemode", filemode ? "true" : "false"); - if (is_bare_repository()) + if (is_bare_repository(repo)) repo_config_set(repo, "core.bare", "true"); else { + const char *value; + repo_config_set(repo, "core.bare", "false"); + /* allow template config file to override the default */ - if (repo_settings_get_log_all_ref_updates(repo) == LOG_REFS_UNSET) + if (repo_config_get_string_tmp(repo, "core.logallrefupdates", &value)) repo_config_set(repo, "core.logallrefupdates", "true"); + if (needs_work_tree_config(original_git_dir, work_tree)) repo_config_set(repo, "core.worktree", work_tree); }