@matheusbsbs / matheus-bagliano / commits / 450f437fb0
Fork 0

Eliminate an unnecessary chdir("..")

In the case where setup_git_directory_gently fails, avoid the last chdir("..") by moving it after the ceil_offset check. Signed-off-by: David Reiss <dreiss@facebook.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

David Reiss committed May 19, 2008 at 23:49 UTC 450f437fb0fe276a6e946c281c768118e39dc9e7
1 file changed +1 -1
setup.c
+1 -1
@@ -446,7 +446,6 @@ const char *setup_git_directory_gently(int *nongit_ok)
446 check_repository_format_gently(nongit_ok);
447 return NULL;
448 }
449 - chdir("..");
449 while (--offset > ceil_offset && cwd[offset] != '/');
450 if (offset <= ceil_offset) {
451 if (nongit_ok) {
@@ -457,6 +456,7 @@ const char *setup_git_directory_gently(int *nongit_ok)
456 }
457 die("Not a git repository");
458 }
459 + chdir("..");
460 }
461
462 inside_git_dir = 0;