]> git.ipfire.org Git - thirdparty/git.git/commitdiff
config: use git_parse_int() in git_config_get_expiry_in_days()
authorRené Scharfe <l.s.r@web.de>
Sat, 27 Dec 2025 09:29:35 +0000 (10:29 +0100)
committerJunio C Hamano <gitster@pobox.com>
Sun, 28 Dec 2025 05:04:15 +0000 (14:04 +0900)
git_config_get_expiry_in_days() calls git_parse_signed() with the
maximum value of int, which is equivalent to calling git_parse_int().
Do that instead, as its shorter and clearer.

This requires demoting "days" to int to match.  Promote "scale" to
intmax_t in turn to arrive at the same result when multiplying them.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
config.c

index f1def0dcfbacba5fb4f915fbf5c244ffd6e40009..2d3e4d441a2124d829ae5d7993f133ba23d80cdc 100644 (file)
--- a/config.c
+++ b/config.c
@@ -2434,14 +2434,14 @@ int repo_config_get_expiry_in_days(struct repository *r, const char *key,
                                   timestamp_t *expiry, timestamp_t now)
 {
        const char *expiry_string;
-       intmax_t days;
+       int days;
        timestamp_t when;
 
        if (repo_config_get_string_tmp(r, key, &expiry_string))
                return 1; /* no such thing */
 
-       if (git_parse_signed(expiry_string, &days, maximum_signed_value_of_type(int))) {
-               const int scale = 86400;
+       if (git_parse_int(expiry_string, &days)) {
+               const intmax_t scale = 86400;
                *expiry = now - days * scale;
                return 0;
        }