From: Michael J Gruber <git@grubix.eu>
To: git@vger.kernel.org
Subject: [PATCH 2/6] do not discard const: make git-compat-util ISOC23-like
Date: Thu, 26 Mar 2026 16:22:48 +0100 [thread overview]
Message-ID: <cfea3c6f006f926319da79bb7d97d57fb3b580e9.1774537954.git.git@grubix.eu> (raw)
In-Reply-To: <cover.1774537954.git.git@grubix.eu>
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
next prev parent reply other threads:[~2026-03-26 15:58 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-26 15:22 [PATCH 0/6] ISOC23: quell warnings on discarding const Michael J Gruber
2026-03-26 15:22 ` [PATCH 1/6] do not discard const: the simple cases Michael J Gruber
2026-03-26 17:34 ` Jeff King
2026-03-26 17:45 ` Junio C Hamano
2026-03-26 19:23 ` [PATCH] config: store allocated string in non-const pointer Jeff King
2026-03-26 15:22 ` Michael J Gruber [this message]
2026-03-26 15:22 ` [PATCH 3/6] do not discard const: adjust to non-const data types Michael J Gruber
2026-03-26 17:28 ` Junio C Hamano
2026-03-26 15:22 ` [PATCH 4/6] do not discard const: declare const where we stay const Michael J Gruber
2026-03-26 15:22 ` [PATCH 5/6] do not discard const: keep signature Michael J Gruber
2026-03-26 17:18 ` Junio C Hamano
2026-03-26 15:22 ` [PATCH 6/6] do not discard const: the ugly truth Michael J Gruber
2026-03-26 17:07 ` Junio C Hamano
2026-03-26 17:42 ` Jeff King
2026-03-26 19:02 ` [PATCH 0/4] fix const issues in revision parser Jeff King
2026-03-26 19:04 ` [PATCH 1/4] revision: make handle_dotdot() interface less confusing Jeff King
2026-03-26 19:28 ` Junio C Hamano
2026-03-26 23:14 ` Jeff King
2026-03-27 15:55 ` Junio C Hamano
2026-03-26 19:05 ` [PATCH 2/4] rev-parse: simplify dotdot parsing Jeff King
2026-03-26 19:13 ` [PATCH 3/4] revision: avoid writing to const string for parent marks Jeff King
2026-03-26 19:14 ` [PATCH 4/4] rev-parse: " Jeff King
2026-03-26 16:26 ` [PATCH 0/6] ISOC23: quell warnings on discarding const D. Ben Knoble
2026-03-27 17:45 ` Michael J Gruber
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cfea3c6f006f926319da79bb7d97d57fb3b580e9.1774537954.git.git@grubix.eu \
--to=git@grubix.eu \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).