From: Junio C Hamano <gitster@pobox.com>
To: "Delilah Ashley Wu via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, Delilah Ashley Wu <delilahwu@microsoft.com>,
Derrick Stolee <stolee@gmail.com>,
Johannes Schindelin <johannes.schindelin@gmx.de>,
Patrick Steinhardt <ps@pks.im>,
Delilah Ashley Wu <delilahwu@linux.microsoft.com>
Subject: Re: [PATCH/RFC 1/4] cleanup_path: force forward slashes on Windows
Date: Wed, 19 Nov 2025 09:47:24 -0800 [thread overview]
Message-ID: <xmqq7bvldidv.fsf@gitster.g> (raw)
In-Reply-To: <c8df6a042b9e971f392b2fd2d09a9c3c655dbceb.1760058849.git.gitgitgadget@gmail.com> (Delilah Ashley Wu via GitGitGadget's message of "Fri, 10 Oct 2025 01:14:06 +0000")
"Delilah Ashley Wu via GitGitGadget" <gitgitgadget@gmail.com>
writes:
> All existing callers of
> `cleanup_path()` pass `char *` anyways, so this change is compatible.
Not just compatible ;-). If there is a caller that wants
cleanup_path() not to munge what it passes, this change will
introduce a bug for them. Have you made sure that none of these
callers mind that backslashes are converted into forward slashes?
> The next patch, config: test home and xdg files in `list --global`, will
> assert that the XDG config path uses forward slashes.
The path to the leaf-level blobs is always slash separated in the
index, a tree object sorts an entry that points at a subtree as if
its path component has terminating slash, etc., and only when these
paths are externalized, they are converted to filesystem dependent
hierarchy separator (by system call like creat(2) even on platforms
like Windows whose filesystem uses backslashes as the pathname
separator). Canonicalizing end-user supplied path early at a
central place does make sense.
> -static const char *cleanup_path(const char *path)
> +static char *cleanup_path(char *path)
> {
> /* Clean it up */
> - if (skip_prefix(path, "./", &path)) {
> + if (skip_prefix(path, "./", (const char **)&path))
> while (*path == '/')
> path++;
> - }
Hmph, the need for cast is a bit annoying, but more importantly, why
don't we have to worry about leading ".\\\\" instead of ".////"?
Shouldn't we be stripping backslashes the same way on Windows?
> +#ifdef GIT_WINDOWS_NATIVE
> + convert_slashes(path);
> +#endif
In other words, why do it here, not _before_ the loop that says "If
the path begins with dot (i.e. the thing is relative to the current
directory) followed by a directory separator, remove it together
with any extra directory separators that come immediately after it"?
> return path;
> }
next prev parent reply other threads:[~2025-11-19 17:47 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-10 1:14 [PATCH/RFC 0/4] config: read both home and xdg files for --global Delilah Ashley Wu via GitGitGadget
2025-10-10 1:14 ` [PATCH/RFC 1/4] cleanup_path: force forward slashes on Windows Delilah Ashley Wu via GitGitGadget
2025-11-19 17:47 ` Junio C Hamano [this message]
2025-10-10 1:14 ` [PATCH/RFC 2/4] config: test home and xdg files in `list --global` Delilah Ashley Wu via GitGitGadget
2025-11-19 18:29 ` Junio C Hamano
2025-10-10 1:14 ` [PATCH/RFC 3/4] config: read global scope via config_sequence Delilah Ashley Wu via GitGitGadget
2025-11-19 18:39 ` Junio C Hamano
2025-10-10 1:14 ` [PATCH/RFC 4/4] config: keep bailing on unreadable global files Delilah Ashley Wu via GitGitGadget
2025-10-10 1:27 ` [PATCH/RFC 0/4] config: read both home and xdg files for --global Kristoffer Haugsbakk
2025-11-22 1:36 ` Delilah Ashley Wu
2025-11-17 13:29 ` Johannes Schindelin
2025-11-18 0:28 ` Junio C Hamano
2025-11-19 14:44 ` Junio C Hamano
2025-11-22 2:00 ` Delilah Ashley Wu
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqq7bvldidv.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=delilahwu@linux.microsoft.com \
--cc=delilahwu@microsoft.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=johannes.schindelin@gmx.de \
--cc=ps@pks.im \
--cc=stolee@gmail.com \
/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.
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 NNTP newsgroup(s).