git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Johannes Schindelin <johannes.schindelin@gmx.de>,
	Johannes Schindelin <johannes.schindelin@gmx.de>
Subject: [PATCH 3/4] run_auto_maintenance(): implicitly close the object store
Date: Thu, 09 Sep 2021 09:47:07 +0000	[thread overview]
Message-ID: <990d4ca934862845429506583b73bc2fd4ad2405.1631180828.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.1035.git.1631180828.gitgitgadget@gmail.com>

From: Johannes Schindelin <johannes.schindelin@gmx.de>

Before spawning the auto maintenance, we need to make sure that we
release all open file handles to all the `.pack` files (and MIDX files
and commit-graph files and...) so that the maintenance process has the
freedom to delete those files.

So far, we did this manually every time before calling
`run_auto_maintenance()`. With the new `close_object_store` flag, we can
do that implicitly in that function, which is more robust because future
callers won't be able to forget to close the object store.

Note: this changes behavior slightly, as we previously _always_ closed
the object store, but now we only close the object store when actually
running the auto maintenance. In practice, this should not matter (if
anything, it might speed up operations where auto maintenance is
disabled).

Suggested-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 builtin/am.c     | 1 -
 builtin/fetch.c  | 2 --
 builtin/merge.c  | 1 -
 builtin/rebase.c | 1 -
 run-command.c    | 1 +
 5 files changed, 1 insertion(+), 5 deletions(-)

diff --git a/builtin/am.c b/builtin/am.c
index 0c2ad96b70e..f239e4ddde0 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -1848,7 +1848,6 @@ next:
 	 */
 	if (!state->rebasing) {
 		am_destroy(state);
-		close_object_store(the_repository->objects);
 		run_auto_maintenance(state->quiet);
 	}
 }
diff --git a/builtin/fetch.c b/builtin/fetch.c
index 25740c13df1..c9ac8664e18 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -2133,8 +2133,6 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
 					     NULL);
 	}
 
-	close_object_store(the_repository->objects);
-
 	if (enable_auto_gc)
 		run_auto_maintenance(verbosity < 0);
 
diff --git a/builtin/merge.c b/builtin/merge.c
index 22f23990b37..e4994e369af 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -469,7 +469,6 @@ static void finish(struct commit *head_commit,
 			 * We ignore errors in 'gc --auto', since the
 			 * user should see them.
 			 */
-			close_object_store(the_repository->objects);
 			run_auto_maintenance(verbosity < 0);
 		}
 	}
diff --git a/builtin/rebase.c b/builtin/rebase.c
index 33e09619005..ba09ebb9e66 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -740,7 +740,6 @@ static int finish_rebase(struct rebase_options *opts)
 	delete_ref(NULL, "REBASE_HEAD", NULL, REF_NO_DEREF);
 	unlink(git_path_auto_merge(the_repository));
 	apply_autostash(state_dir_path("autostash", opts));
-	close_object_store(the_repository->objects);
 	/*
 	 * We ignore errors in 'git maintenance run --auto', since the
 	 * user should see them.
diff --git a/run-command.c b/run-command.c
index e2dc6243774..229bdff9971 100644
--- a/run-command.c
+++ b/run-command.c
@@ -1891,6 +1891,7 @@ int run_auto_maintenance(int quiet)
 		return 0;
 
 	maint.git_cmd = 1;
+	maint.close_object_store = 1;
 	strvec_pushl(&maint.args, "maintenance", "run", "--auto", NULL);
 	strvec_push(&maint.args, quiet ? "--quiet" : "--no-quiet");
 
-- 
gitgitgadget


  parent reply	other threads:[~2021-09-09  9:47 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-09  9:47 [PATCH 0/4] Follow-up to js/pull-release-backs-before-fetching Johannes Schindelin via GitGitGadget
2021-09-09  9:47 ` [PATCH 1/4] run-command: prettify the `RUN_COMMAND_*` flags Johannes Schindelin via GitGitGadget
2021-09-09  9:47 ` [PATCH 2/4] run-command: offer to close the object store before running Johannes Schindelin via GitGitGadget
2021-09-09  9:47 ` Johannes Schindelin via GitGitGadget [this message]
2021-09-09  9:47 ` [PATCH 4/4] Close object store closer to spawning child processes Johannes Schindelin via GitGitGadget

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=990d4ca934862845429506583b73bc2fd4ad2405.1631180828.git.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=johannes.schindelin@gmx.de \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).