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 <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Johannes Schindelin committed
Mar 7, 2017 at 15:32 UTC
6c1e654437b7d3fff8bb8315d61afa0e930d6776
1 file changed
+3
-1
setup.c
+3
-1
@@ -910,7 +910,9 @@ static const char *setup_git_directory_gently_1(int *nongit_ok)
910
return setup_bare_git_dir(&cwd, offset, nongit_ok);
911
912
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 */
916
if (offset_parent <= ceil_offset)
917
return setup_nongit(cwd.buf, nongit_ok);
918
if (one_filesystem) {