diff options
author | Patrick Steinhardt <ps@pks.im> | 2024-08-16 12:44:57 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2024-08-16 18:46:24 +0200 |
commit | a70a9bf6eec832b808a805de318601684b19f18e (patch) | |
tree | aca5b36515a0cf6fc94eec7e2cdf6573fb29f6dd /read-cache.c | |
parent | The third batch (diff) | |
download | git-a70a9bf6eec832b808a805de318601684b19f18e.tar.xz git-a70a9bf6eec832b808a805de318601684b19f18e.zip |
config: fix constness of out parameter for `git_config_get_expiry()`
The type of the out parameter of `git_config_get_expiry()` is a pointer
to a constant string, which creates the impression that ownership of the
returned data wasn't transferred to the caller. This isn't true though
and thus quite misleading.
Adapt the parameter to be of type `char **` and adjust callers
accordingly. While at it, refactor `get_shared_index_expire_date()` to
drop the static `shared_index_expire` variable. It is only used in that
function, and furthermore we would only hit the code where we parse the
expiry date a single time because we already use a static `prepared`
variable to track whether we did parse it.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to '')
-rw-r--r-- | read-cache.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/read-cache.c b/read-cache.c index 48bf24f87c..7f393ee687 100644 --- a/read-cache.c +++ b/read-cache.c @@ -3176,18 +3176,24 @@ static int write_split_index(struct index_state *istate, return ret; } -static const char *shared_index_expire = "2.weeks.ago"; - static unsigned long get_shared_index_expire_date(void) { static unsigned long shared_index_expire_date; 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", - &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; |