From: "Karsten Blees via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Patrick Steinhardt <ps@pks.im>,
Johannes Schindelin <johannes.schindelin@gmx.de>,
Karsten Blees <karsten.blees@gmail.com>
Subject: [PATCH v2 5/5] trim_last_path_component(): avoid hard-coding the directory separator
Date: Fri, 09 Jan 2026 20:05:09 +0000 [thread overview]
Message-ID: <9823cbb6df84eedfa40d7120d3949f70d2f960ba.1767989109.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.2017.v2.git.1767989109.gitgitgadget@gmail.com>
From: Karsten Blees <karsten.blees@gmail.com>
Currently, this function hard-codes the directory separator as the
forward slash.
However, on Windows the backslash character is valid, too. And we want
to call this function in the upcoming support for symlinks on Windows
with the symlink targets (which naturally use the canonical directory
separator on Windows, which is _not_ the forward slash).
Prepare that function to be useful also in that context.
Signed-off-by: Karsten Blees <karsten.blees@gmail.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
lockfile.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lockfile.c b/lockfile.c
index 1d5ed01682..67082a9caa 100644
--- a/lockfile.c
+++ b/lockfile.c
@@ -19,14 +19,14 @@ static void trim_last_path_component(struct strbuf *path)
int i = path->len;
/* back up past trailing slashes, if any */
- while (i && path->buf[i - 1] == '/')
+ while (i && is_dir_sep(path->buf[i - 1]))
i--;
/*
* then go backwards until a slash, or the beginning of the
* string
*/
- while (i && path->buf[i - 1] != '/')
+ while (i && !is_dir_sep(path->buf[i - 1]))
i--;
strbuf_setlen(path, i);
--
gitgitgadget
next prev parent reply other threads:[~2026-01-09 20:05 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-16 15:33 [PATCH 0/5] Last preparations before upstreaming Git for Windows' symlink support Johannes Schindelin via GitGitGadget
2025-12-16 15:33 ` [PATCH 1/5] mingw: do resolve symlinks in `getcwd()` Johannes Schindelin via GitGitGadget
2025-12-17 14:44 ` Patrick Steinhardt
2025-12-16 15:33 ` [PATCH 2/5] init: do parse _all_ core.* settings early Johannes Schindelin via GitGitGadget
2025-12-17 14:44 ` Patrick Steinhardt
2025-12-16 15:33 ` [PATCH 3/5] strbuf_readlink(): avoid calling `readlink()` twice in corner-cases Karsten Blees via GitGitGadget
2025-12-16 15:33 ` [PATCH 4/5] strbuf_readlink(): support link targets that exceed PATH_MAX Karsten Blees via GitGitGadget
2025-12-17 14:44 ` Patrick Steinhardt
2025-12-19 8:50 ` Johannes Schindelin
2025-12-19 11:51 ` Patrick Steinhardt
2025-12-30 5:00 ` Junio C Hamano
2025-12-17 23:39 ` Junio C Hamano
2025-12-16 15:33 ` [PATCH 5/5] trim_last_path_component(): avoid hard-coding the directory separator Karsten Blees via GitGitGadget
2026-01-09 20:05 ` [PATCH v2 0/5] Last preparations before upstreaming Git for Windows' symlink support Johannes Schindelin via GitGitGadget
2026-01-09 20:05 ` [PATCH v2 1/5] mingw: do resolve symlinks in `getcwd()` Johannes Schindelin via GitGitGadget
2026-01-09 20:05 ` [PATCH v2 2/5] init: do parse _all_ core.* settings early Johannes Schindelin via GitGitGadget
2026-01-09 20:05 ` [PATCH v2 3/5] strbuf_readlink(): avoid calling `readlink()` twice in corner-cases Karsten Blees via GitGitGadget
2026-01-09 20:05 ` [PATCH v2 4/5] strbuf_readlink(): support link targets that exceed 2*PATH_MAX Johannes Schindelin via GitGitGadget
2026-01-09 20:05 ` Karsten Blees via GitGitGadget [this message]
2026-01-11 4:04 ` [PATCH v2 0/5] Last preparations before upstreaming Git for Windows' symlink support Junio C Hamano
2026-01-12 8:35 ` Patrick Steinhardt
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=9823cbb6df84eedfa40d7120d3949f70d2f960ba.1767989109.git.gitgitgadget@gmail.com \
--to=gitgitgadget@gmail.com \
--cc=git@vger.kernel.org \
--cc=johannes.schindelin@gmx.de \
--cc=karsten.blees@gmail.com \
--cc=ps@pks.im \
/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