From: David Reiss Date: Tue, 20 May 2008 06:49:34 +0000 (-0700) Subject: Eliminate an unnecessary chdir("..") X-Git-Tag: v1.6.0-rc0~121^2 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=450f437fb0fe276a6e946c281c768118e39dc9e7;p=git.git 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 Signed-off-by: Junio C Hamano --- diff --git a/setup.c b/setup.c index c14b10636..045ca20b3 100644 --- a/setup.c +++ b/setup.c @@ -446,7 +446,6 @@ const char *setup_git_directory_gently(int *nongit_ok) check_repository_format_gently(nongit_ok); return NULL; } - chdir(".."); while (--offset > ceil_offset && cwd[offset] != '/'); if (offset <= ceil_offset) { if (nongit_ok) { @@ -457,6 +456,7 @@ const char *setup_git_directory_gently(int *nongit_ok) } die("Not a git repository"); } + chdir(".."); } inside_git_dir = 0;