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>
Patrick Steinhardt committed
Nov 19, 2025 at 08:51 UTC
ac65c70663b092e823b0d3de1c1cfdee0a4fbc8e
2 files changed
+7
-5
odb.c
+7
@@ -24,6 +24,7 @@
24
#include "strbuf.h"
25
#include "strvec.h"
26
#include "submodule.h"
27
+#include "tmp-objdir.h"
28
#include "trace2.h"
29
#include "write-or-die.h"
30
@@ -1041,8 +1042,11 @@ static void odb_update_commondir(const char *name UNUSED,
1042
void *cb_data)
1043
{
1044
struct object_database *odb = cb_data;
1045
+ struct tmp_objdir *tmp_objdir;
1046
struct odb_source *source;
1047
1048
+ tmp_objdir = tmp_objdir_unapply_primary_odb();
1049
+
1050
/*
1051
* In theory, we only have to do this for the primary object source, as
1052
* alternates' paths are always resolved to an absolute path.
@@ -1059,6 +1063,9 @@ static void odb_update_commondir(const char *name UNUSED,
1063
free(source->path);
1064
source->path = path;
1065
}
1066
+
1067
+ if (tmp_objdir)
1068
+ tmp_objdir_reapply_primary_odb(tmp_objdir, old_cwd, new_cwd);
1069
}
1070
1071
struct object_database *odb_new(struct repository *repo,
setup.c
-5
@@ -22,7 +22,6 @@
22
#include "chdir-notify.h"
23
#include "path.h"
24
#include "quote.h"
25
-#include "tmp-objdir.h"
25
#include "trace.h"
26
#include "trace2.h"
27
#include "worktree.h"
@@ -1056,14 +1055,10 @@ static void update_relative_gitdir(const char *name UNUSED,
1055
{
1056
char *path = reparent_relative_path(old_cwd, new_cwd,
1057
repo_get_git_dir(the_repository));
1059
- struct tmp_objdir *tmp_objdir = tmp_objdir_unapply_primary_odb();
1060
-
1058
trace_printf_key(&trace_setup_key,
1059
"setup: move $GIT_DIR to '%s'",
1060
path);
1061
set_git_dir_1(path, true);
1065
- if (tmp_objdir)
1066
- tmp_objdir_reapply_primary_odb(tmp_objdir, old_cwd, new_cwd);
1062
free(path);
1063
}
1064