summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorNeeraj Singh <neerajsi@microsoft.com>2021-12-06 22:05:04 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-12-08 22:06:36 (GMT)
commitb3cecf49eac00d62e361bf6e6e81392f5a2fb571 (patch)
treeae4937eebd6d08bb828dd1967d043369c496c945 /builtin
parentcefe983a320c03d7843ac78e73bd513a27806845 (diff)
downloadgit-b3cecf49eac00d62e361bf6e6e81392f5a2fb571.zip
git-b3cecf49eac00d62e361bf6e6e81392f5a2fb571.tar.gz
git-b3cecf49eac00d62e361bf6e6e81392f5a2fb571.tar.bz2
tmp-objdir: new API for creating temporary writable databases
The tmp_objdir API provides the ability to create temporary object directories, but was designed with the goal of having subprocesses access these object stores, followed by the main process migrating objects from it to the main object store or just deleting it. The subprocesses would view it as their primary datastore and write to it. Here we add the tmp_objdir_replace_primary_odb function that replaces the current process's writable "main" object directory with the specified one. The previous main object directory is restored in either tmp_objdir_migrate or tmp_objdir_destroy. For the --remerge-diff usecase, add a new `will_destroy` flag in `struct object_database` to mark ephemeral object databases that do not require fsync durability. Add 'git prune' support for removing temporary object databases, and make sure that they have a name starting with tmp_ and containing an operation-specific name. Based-on-patch-by: Elijah Newren <newren@gmail.com> Signed-off-by: Neeraj Singh <neerajsi@microsoft.com> Reviewed-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/prune.c20
-rw-r--r--builtin/receive-pack.c2
2 files changed, 17 insertions, 5 deletions
diff --git a/builtin/prune.c b/builtin/prune.c
index 02c6ab7..5a344bb 100644
--- a/builtin/prune.c
+++ b/builtin/prune.c
@@ -26,10 +26,22 @@ static int prune_tmp_file(const char *fullpath)
return error("Could not stat '%s'", fullpath);
if (st.st_mtime > expire)
return 0;
- if (show_only || verbose)
- printf("Removing stale temporary file %s\n", fullpath);
- if (!show_only)
- unlink_or_warn(fullpath);
+ if (S_ISDIR(st.st_mode)) {
+ if (show_only || verbose)
+ printf("Removing stale temporary directory %s\n", fullpath);
+ if (!show_only) {
+ struct strbuf remove_dir_buf = STRBUF_INIT;
+
+ strbuf_addstr(&remove_dir_buf, fullpath);
+ remove_dir_recursively(&remove_dir_buf, 0);
+ strbuf_release(&remove_dir_buf);
+ }
+ } else {
+ if (show_only || verbose)
+ printf("Removing stale temporary file %s\n", fullpath);
+ if (!show_only)
+ unlink_or_warn(fullpath);
+ }
return 0;
}
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index 48960a9..418a42c 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -2208,7 +2208,7 @@ static const char *unpack(int err_fd, struct shallow_info *si)
strvec_push(&child.args, alt_shallow_file);
}
- tmp_objdir = tmp_objdir_create();
+ tmp_objdir = tmp_objdir_create("incoming");
if (!tmp_objdir) {
if (err_fd > 0)
close(err_fd);