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@xxxxxxxxxx> --- 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 - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html