git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] config: use git_parse_int() in git_config_get_expiry_in_days()

From
René Scharfe <l.s.r@web.de>
Date
Dec 27, 2025, 09:29 UTC
Message-ID
<1bd3c7f3-fcf6-4d8e-aa38-c15e3d51ce4c@web.de>

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>
---
Patch formatted with --function-context for easier review.
 config.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/config.c b/config.c
index 1738c0cb0d..7f6d53b473 100644
--- a/config.c
+++ b/config.c
@@ -2434,22 +2434,22 @@ int repo_config_get_expiry(struct repository *r, const char *key, char **output)
 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;
 	}
 
 	if (!parse_expiry_date(expiry_string, &when)) {
 		*expiry = when;
 		return 0;
 	}
 	return -1; /* thing exists but cannot be parsed */
 }
-- 
2.52.0
Message 1 of 1 in “config: use git_parse_int() in git_config_get_expiry_in_days()”
  1. config: use git_parse_int() in git_config_get_expiry_in_days()René Scharfe, Dec 27, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.