From: Christian Thaeter <ct@pipapo.org>
To: git@vger.kernel.org
Cc: gitster@pobox.com, Christian Thaeter <ct@pipapo.org>
Subject: [PATCH 5/5] Make setup_git_directory reentrant
Date: Mon, 7 Jan 2008 06:47:35 +0100 [thread overview]
Message-ID: <1199684855-14246-5-git-send-email-ct@pipapo.org> (raw)
In-Reply-To: <1199684855-14246-4-git-send-email-ct@pipapo.org>
Reentrant means here one can call it serveral times for different repos.
The functionality introduced here (based on earlier commits) is sufficent
to call setup_git_directory() for inspecting the refs like generating a
repository list for a browser. For full reset some more works needs
to be done later.
Signed-off-by: Christian Thaeter <ct@pipapo.org>
---
setup.c | 13 ++++++++++++-
1 files changed, 12 insertions(+), 1 deletions(-)
diff --git a/setup.c b/setup.c
index adede16..770dc41 100644
--- a/setup.c
+++ b/setup.c
@@ -200,6 +200,8 @@ static const char *set_work_tree(const char *dir)
if (!getcwd(buffer, sizeof(buffer)))
die ("Could not get the current working directory");
+ if (git_work_tree_cfg)
+ free (git_work_tree_cfg);
git_work_tree_cfg = xstrdup(buffer);
inside_work_tree = 1;
@@ -329,6 +331,8 @@ const char *setup_git_directory_gently(int *nongit_ok)
inside_git_dir = 0;
if (!work_tree_env)
inside_work_tree = 1;
+ if (git_work_tree_cfg)
+ free (git_work_tree_cfg);
git_work_tree_cfg = xstrndup(cwd, offset);
if (check_repository_format_gently(nongit_ok))
return NULL;
@@ -387,7 +391,14 @@ int check_repository_format(void)
const char *setup_git_directory(void)
{
- const char *retval = setup_git_directory_gently(NULL);
+ const char *retval;
+
+ inside_git_dir = -1;
+ inside_work_tree = -1;
+ git_invalidate_cached_refs();
+ reset_packed_git();
+ reset_git_work_tree();
+ retval = setup_git_directory_gently(NULL);
/* If the work tree is not the default one, recompute prefix */
if (inside_work_tree < 0) {
--
1.5.3.7
next prev parent reply other threads:[~2008-01-07 5:49 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-07 5:47 [PATCH 1/5] Add streq() to compat-util Christian Thaeter
2008-01-07 5:47 ` [PATCH 2/5] First step, making setup (somewhat) reentrant Christian Thaeter
2008-01-07 5:47 ` [PATCH 3/5] provide a reset_packed_git() function Christian Thaeter
2008-01-07 5:47 ` [PATCH 4/5] Export some more functions to enable resetting the git state Christian Thaeter
2008-01-07 5:47 ` Christian Thaeter [this message]
2008-01-07 8:50 ` [PATCH 2/5] First step, making setup (somewhat) reentrant Johannes Schindelin
2008-01-07 9:22 ` Junio C Hamano
2008-01-07 11:28 ` Johannes Schindelin
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=1199684855-14246-5-git-send-email-ct@pipapo.org \
--to=ct@pipapo.org \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/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).