From: David Reiss <dreiss@facebook.com>
To: git@vger.kernel.org
Subject: [PATCH 4/4] Eliminate an unnecessary chdir("..")
Date: Mon, 19 May 2008 23:49:34 -0700 [thread overview]
Message-ID: <4832747E.7070607@facebook.com> (raw)
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>
---
Johannes originally asked me to squash this, then asked me to keep the
patch minimal. I'm including it here in case anyone else thinks it should
go in. It should be harmless because getcwd is not called in the loop,
and any nonlocal exit from the loop is either a "die" or does a chdir
to cwd, which is an absolute path.
setup.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/setup.c b/setup.c
index c14b106..045ca20 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;
--
1.5.4
reply other threads:[~2008-05-20 6:51 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4832747E.7070607@facebook.com \
--to=dreiss@facebook.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).