Subject: [PATCH 2/6] do not discard const: make git-compat-util ISOC23-like

From: Michael J Gruber <[email-masked]>
Date: Thu, 26 Mar 2026 16:22:48 +0100

find_last_dir() should and can return a const pointer. This change fixes
the warnings with ISOC23 for git-compat-util and - via explicit casts -
makes it clear where we mutate the returned memory.
---
 git-compat-util.h | 2 +-
 scalar.c          | 2 +-
 submodule.c       | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/git-compat-util.h b/git-compat-util.h
index 4b4ea2498f..3c3dbe298c 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -335,7 +335,7 @@ static inline int is_path_owned_by_current_uid(const char *path,
 #endif
 
 #ifndef find_last_dir_sep
-static inline char *git_find_last_dir_sep(const char *path)
+static inline const char *git_find_last_dir_sep(const char *path)
 {
 	return strrchr(path, '/');
 }
diff --git a/scalar.c b/scalar.c
index 4efb6ac36d..44f432d7f0 100644
--- a/scalar.c
+++ b/scalar.c
@@ -479,7 +479,7 @@ static int cmd_clone(int argc, const char **argv)
 		/* Strip suffix `.git`, if any */
 		strbuf_strip_suffix(&buf, ".git");
 
-		enlistment = find_last_dir_sep(buf.buf);
+		enlistment = (char *) find_last_dir_sep(buf.buf);
 		if (!enlistment) {
 			die(_("cannot deduce worktree name from '%s'"), url);
 		}
diff --git a/submodule.c b/submodule.c
index b1a0363f9d..57933386bc 100644
--- a/submodule.c
+++ b/submodule.c
@@ -2268,7 +2268,7 @@ static int check_casefolding_conflict(const char *git_dir,
 	DIR *dir = NULL;
 	int ret = 0;
 
-	if ((p = find_last_dir_sep(modules_dir)))
+	if ((p = (char *) find_last_dir_sep(modules_dir)))
 		*p = '\0';
 
 	/* No conflict is possible if modules_dir doesn't exist (first clone) */
-- 
2.53.0.1195.g771ffcb452