Skip to content

Commit 6c1e654

Browse files
dschogitster
authored andcommitted
setup_git_directory(): use is_dir_sep() helper
It is okay in practice to test for forward slashes in the output of getcwd(), because we go out of our way to convert backslashes to forward slashes in getcwd()'s output on Windows. Still, the correct way to test for a dir separator is by using the helper function we introduced for that very purpose. It also serves as a good documentation what the code tries to do (not "how"). Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 551d535 commit 6c1e654

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

setup.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -910,7 +910,9 @@ static const char *setup_git_directory_gently_1(int *nongit_ok)
910910
return setup_bare_git_dir(&cwd, offset, nongit_ok);
911911

912912
offset_parent = offset;
913-
while (--offset_parent > ceil_offset && cwd.buf[offset_parent] != '/');
913+
while (--offset_parent > ceil_offset &&
914+
!is_dir_sep(cwd.buf[offset_parent]))
915+
; /* continue */
914916
if (offset_parent <= ceil_offset)
915917
return setup_nongit(cwd.buf, nongit_ok);
916918
if (one_filesystem) {

0 commit comments

Comments
 (0)