From: Junio C Hamano Date: Mon, 26 Aug 2024 18:32:20 +0000 (-0700) Subject: Merge branch 'ps/maintenance-detach-fix' X-Git-Tag: v2.47.0-rc0~98 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1e8962ee082934a60b5fc71fab0e36cb1cab39bd;p=thirdparty%2Fgit.git Merge branch 'ps/maintenance-detach-fix' Maintenance tasks other than "gc" now properly go background when "git maintenance" runs them. * ps/maintenance-detach-fix: run-command: fix detaching when running auto maintenance builtin/maintenance: add a `--detach` flag builtin/gc: add a `--detach` flag builtin/gc: stop processing log file on signal builtin/gc: fix leaking config values builtin/gc: refactor to read config into structure config: fix constness of out parameter for `git_config_get_expiry()` --- 1e8962ee082934a60b5fc71fab0e36cb1cab39bd diff --cc builtin/gc.c index 45f14fb09b,bafee330a2..bd0a1b92ba --- a/builtin/gc.c +++ b/builtin/gc.c @@@ -158,24 -179,43 +179,43 @@@ static void gc_config(struct gc_config if (gc_config_is_timestamp_never("gc.reflogexpire") && gc_config_is_timestamp_never("gc.reflogexpireunreachable")) - prune_reflogs = 0; + cfg->prune_reflogs = 0; + + git_config_get_int("gc.aggressivewindow", &cfg->aggressive_window); + git_config_get_int("gc.aggressivedepth", &cfg->aggressive_depth); + git_config_get_int("gc.auto", &cfg->gc_auto_threshold); + git_config_get_int("gc.autopacklimit", &cfg->gc_auto_pack_limit); + git_config_get_bool("gc.autodetach", &cfg->detach_auto); + git_config_get_bool("gc.cruftpacks", &cfg->cruft_packs); + git_config_get_ulong("gc.maxcruftsize", &cfg->max_cruft_size); + - if (!git_config_get_expiry("gc.pruneexpire", &owned)) { ++ if (!repo_config_get_expiry(the_repository, "gc.pruneexpire", &owned)) { + free(cfg->prune_expire); + cfg->prune_expire = owned; + } - git_config_get_int("gc.aggressivewindow", &aggressive_window); - git_config_get_int("gc.aggressivedepth", &aggressive_depth); - git_config_get_int("gc.auto", &gc_auto_threshold); - git_config_get_int("gc.autopacklimit", &gc_auto_pack_limit); - git_config_get_bool("gc.autodetach", &detach_auto); - git_config_get_bool("gc.cruftpacks", &cruft_packs); - git_config_get_ulong("gc.maxcruftsize", &max_cruft_size); - repo_config_get_expiry(the_repository, "gc.pruneexpire", &prune_expire); - repo_config_get_expiry(the_repository, "gc.worktreepruneexpire", &prune_worktrees_expire); - repo_config_get_expiry(the_repository, "gc.logexpiry", &gc_log_expire); - if (!git_config_get_expiry("gc.worktreepruneexpire", &owned)) { ++ if (!repo_config_get_expiry(the_repository, "gc.worktreepruneexpire", &owned)) { + free(cfg->prune_worktrees_expire); + cfg->prune_worktrees_expire = owned; + } + - if (!git_config_get_expiry("gc.logexpiry", &owned)) { ++ if (!repo_config_get_expiry(the_repository, "gc.logexpiry", &owned)) { + free(cfg->gc_log_expire); + cfg->gc_log_expire = owned; + } - git_config_get_ulong("gc.bigpackthreshold", &big_pack_threshold); - git_config_get_ulong("pack.deltacachesize", &max_delta_cache_size); + git_config_get_ulong("gc.bigpackthreshold", &cfg->big_pack_threshold); + git_config_get_ulong("pack.deltacachesize", &cfg->max_delta_cache_size); - git_config_get_string("gc.repackfilter", &repack_filter); - git_config_get_string("gc.repackfilterto", &repack_filter_to); + if (!git_config_get_string("gc.repackfilter", &owned)) { + free(cfg->repack_filter); + cfg->repack_filter = owned; + } + + if (!git_config_get_string("gc.repackfilterto", &owned)) { + free(cfg->repack_filter_to); + cfg->repack_filter_to = owned; + } git_config(git_default_config, NULL); } diff --cc config.c index 9850897524,dfa4df1417..56b5862e59 --- a/config.c +++ b/config.c @@@ -2694,9 -2694,81 +2694,10 @@@ void git_protected_config(config_fn_t f configset_iter(&protected_config, fn, data); } - int repo_config_get_expiry(struct repository *r, const char *key, const char **output) -/* Functions used historically to read configuration from 'the_repository' */ -void git_config(config_fn_t fn, void *data) ++int repo_config_get_expiry(struct repository *r, const char *key, char **output) { - int ret = repo_config_get_string(r, key, (char **)output); - repo_config(the_repository, fn, data); -} ++ int ret = repo_config_get_string(r, key, output); + -void git_config_clear(void) -{ - repo_config_clear(the_repository); -} - -int git_config_get(const char *key) -{ - return repo_config_get(the_repository, key); -} - -int git_config_get_value(const char *key, const char **value) -{ - return repo_config_get_value(the_repository, key, value); -} - -int git_config_get_value_multi(const char *key, const struct string_list **dest) -{ - return repo_config_get_value_multi(the_repository, key, dest); -} - -int git_config_get_string_multi(const char *key, - const struct string_list **dest) -{ - return repo_config_get_string_multi(the_repository, key, dest); -} - -int git_config_get_string(const char *key, char **dest) -{ - return repo_config_get_string(the_repository, key, dest); -} - -int git_config_get_string_tmp(const char *key, const char **dest) -{ - return repo_config_get_string_tmp(the_repository, key, dest); -} - -int git_config_get_int(const char *key, int *dest) -{ - return repo_config_get_int(the_repository, key, dest); -} - -int git_config_get_ulong(const char *key, unsigned long *dest) -{ - return repo_config_get_ulong(the_repository, key, dest); -} - -int git_config_get_bool(const char *key, int *dest) -{ - return repo_config_get_bool(the_repository, key, dest); -} - -int git_config_get_bool_or_int(const char *key, int *is_bool, int *dest) -{ - return repo_config_get_bool_or_int(the_repository, key, is_bool, dest); -} - -int git_config_get_maybe_bool(const char *key, int *dest) -{ - return repo_config_get_maybe_bool(the_repository, key, dest); -} - -int git_config_get_pathname(const char *key, char **dest) -{ - return repo_config_get_pathname(the_repository, key, dest); -} - -int git_config_get_expiry(const char *key, char **output) -{ - int ret = git_config_get_string(key, output); if (ret) return ret; if (strcmp(*output, "now")) { diff --cc config.h index 4d319a4193,4801391c32..d0497157c5 --- a/config.h +++ b/config.h @@@ -651,32 -676,35 +651,32 @@@ int repo_config_get_ulong(struct reposi * configuration variable `key` is not found, returns 1 without touching * `dest`. */ -int git_config_get_bool(const char *key, int *dest); +int repo_config_get_bool(struct repository *r, const char *key, int *dest); /** - * Similar to `git_config_get_bool`, except that integers are copied as-is, + * Similar to `repo_config_get_bool`, except that integers are copied as-is, * and `is_bool` flag is unset. */ -int git_config_get_bool_or_int(const char *key, int *is_bool, int *dest); +int repo_config_get_bool_or_int(struct repository *r, const char *key, + int *is_bool, int *dest); /** - * Similar to `git_config_get_bool`, except that it returns -1 on error + * Similar to `repo_config_get_bool`, except that it returns -1 on error * rather than dying. */ -int git_config_get_maybe_bool(const char *key, int *dest); - -/** - * Similar to `git_config_get_string`, but expands `~` or `~user` into - * the user's home directory when found at the beginning of the path. - */ -int git_config_get_pathname(const char *key, char **dest); +int repo_config_get_maybe_bool(struct repository *r, + const char *key, int *dest); -int git_config_get_index_threads(int *dest); -int git_config_get_split_index(void); -int git_config_get_max_percent_split_change(void); +int repo_config_get_index_threads(struct repository *r, int *dest); +int repo_config_get_split_index(struct repository *r); +int repo_config_get_max_percent_split_change(struct repository *r); /* This dies if the configured or default date is in the future */ - int repo_config_get_expiry(struct repository *r, const char *key, const char **output); -int git_config_get_expiry(const char *key, char **output); ++int repo_config_get_expiry(struct repository *r, const char *key, char **output); /* parse either "this many days" integer, or "5.days.ago" approxidate */ -int git_config_get_expiry_in_days(const char *key, timestamp_t *, timestamp_t now); +int repo_config_get_expiry_in_days(struct repository *r, const char *key, + timestamp_t *, timestamp_t now); /** * First prints the error message specified by the caller in `err` and then diff --cc read-cache.c index 5464398162,7f393ee687..4e67dc182e --- a/read-cache.c +++ b/read-cache.c @@@ -3203,10 -3182,18 +3201,18 @@@ static unsigned long get_shared_index_e static int shared_index_expire_date_prepared; if (!shared_index_expire_date_prepared) { + const char *shared_index_expire = "2.weeks.ago"; + char *value = NULL; + - git_config_get_expiry("splitindex.sharedindexexpire", - &value); + repo_config_get_expiry(the_repository, "splitindex.sharedindexexpire", - &shared_index_expire); ++ &value); + if (value) + shared_index_expire = value; + shared_index_expire_date = approxidate(shared_index_expire); shared_index_expire_date_prepared = 1; + + free(value); } return shared_index_expire_date;