Skip to content

Commit 6f6fe02

Browse files
kbleesgitster
authored andcommitted
trim_last_path_component(): avoid hard-coding the directory separator
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 <blees@dcon.de> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 9ce11d9 commit 6f6fe02

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lockfile.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ static void trim_last_path_component(struct strbuf *path)
1919
int i = path->len;
2020

2121
/* back up past trailing slashes, if any */
22-
while (i && path->buf[i - 1] == '/')
22+
while (i && is_dir_sep(path->buf[i - 1]))
2323
i--;
2424

2525
/*
2626
* then go backwards until a slash, or the beginning of the
2727
* string
2828
*/
29-
while (i && path->buf[i - 1] != '/')
29+
while (i && !is_dir_sep(path->buf[i - 1]))
3030
i--;
3131

3232
strbuf_setlen(path, i);

0 commit comments

Comments
 (0)