Skip to content

Commit

Permalink
lockfile.c: use is_dir_sep() instead of hardcoded '/' checks
Browse files Browse the repository at this point in the history
Signed-off-by: Karsten Blees <blees@dcon.de>
  • Loading branch information
kblees authored and dscho committed Sep 18, 2024
1 parent 5bcdd25 commit 0ccd0dd
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lockfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 0ccd0dd

Please sign in to comment.