From 450f437fb0fe276a6e946c281c768118e39dc9e7 Mon Sep 17 00:00:00 2001 From: David Reiss Date: Mon, 19 May 2008 23:49:34 -0700 Subject: [PATCH] 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 --- setup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.c b/setup.c index c14b10636f..045ca20b32 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; -- GitLab