Skip to content

Commit ac65c70

Browse files
pks-tgitster
authored andcommitted
odb: handle recreation of quarantine directories
In the preceding commit we have moved the logic that reparents object database sources on chdir(3p) from "setup.c" into "odb.c". Let's also do the same for any temporary quarantine directories so that the complete reparenting logic is self-contained in "odb.c". Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 2816b74 commit ac65c70

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

odb.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "strbuf.h"
2525
#include "strvec.h"
2626
#include "submodule.h"
27+
#include "tmp-objdir.h"
2728
#include "trace2.h"
2829
#include "write-or-die.h"
2930

@@ -1041,8 +1042,11 @@ static void odb_update_commondir(const char *name UNUSED,
10411042
void *cb_data)
10421043
{
10431044
struct object_database *odb = cb_data;
1045+
struct tmp_objdir *tmp_objdir;
10441046
struct odb_source *source;
10451047

1048+
tmp_objdir = tmp_objdir_unapply_primary_odb();
1049+
10461050
/*
10471051
* In theory, we only have to do this for the primary object source, as
10481052
* alternates' paths are always resolved to an absolute path.
@@ -1059,6 +1063,9 @@ static void odb_update_commondir(const char *name UNUSED,
10591063
free(source->path);
10601064
source->path = path;
10611065
}
1066+
1067+
if (tmp_objdir)
1068+
tmp_objdir_reapply_primary_odb(tmp_objdir, old_cwd, new_cwd);
10621069
}
10631070

10641071
struct object_database *odb_new(struct repository *repo,

setup.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include "chdir-notify.h"
2323
#include "path.h"
2424
#include "quote.h"
25-
#include "tmp-objdir.h"
2625
#include "trace.h"
2726
#include "trace2.h"
2827
#include "worktree.h"
@@ -1056,14 +1055,10 @@ static void update_relative_gitdir(const char *name UNUSED,
10561055
{
10571056
char *path = reparent_relative_path(old_cwd, new_cwd,
10581057
repo_get_git_dir(the_repository));
1059-
struct tmp_objdir *tmp_objdir = tmp_objdir_unapply_primary_odb();
1060-
10611058
trace_printf_key(&trace_setup_key,
10621059
"setup: move $GIT_DIR to '%s'",
10631060
path);
10641061
set_git_dir_1(path, true);
1065-
if (tmp_objdir)
1066-
tmp_objdir_reapply_primary_odb(tmp_objdir, old_cwd, new_cwd);
10671062
free(path);
10681063
}
10691064

0 commit comments

Comments
 (0)