git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/2] pull: release packs before fetching

From
Johannes Schindelin via GitGitGadget <gitgitgadget@gmail.com>
Date
Sep 8, 2021, 08:29 UTC
Message-ID
<0e956ae7bba906277c77103ae329bce6d6da4cfe.1631089771.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.1032.git.1631089771.gitgitgadget@gmail.com>
From: Johannes Schindelin <johannes.schindelin@gmx.de>

On Windows, files cannot be removed nor renamed if there are still handles held by a process. To remedy that, we try to release all open handles to any `.pack` file before e.g. repacking (which would want to remove the original `.pack` file(s) after it is done).

Since the `read_cache_unmerged()` and/or the `get_oid()` call in `git pull` can cause `.pack` files to be opened, we need to release the open handles before calling `git fetch`: the latter process might want to spawn an auto-gc, which in turn might want to repack the objects.

This commit is similar in spirit to 5bdece0d705 (gc/repack: release packs when needed, 2018-12-15).

This fixes https://github.com/git-for-windows/git/issues/3336.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 builtin/pull.c | 2 ++
 1 file changed, 2 insertions(+)
diff --git a/builtin/pull.c b/builtin/pull.c
index 3e13f810843..d9f0156d969 100644
--- a/builtin/pull.c
+++ b/builtin/pull.c
@@ -26,6 +26,7 @@
 #include "wt-status.h"
 #include "commit-reach.h"
 #include "sequencer.h"
+#include "packfile.h"
 
 /**
  * Parses the value of --rebase. If value is a false value, returns
@@ -998,6 +999,7 @@ int cmd_pull(int argc, const char **argv, const char *prefix)
 			oidclr(&rebase_fork_point);
 	}
 
+	close_object_store(the_repository->objects);
 	if (run_fetch(repo, refspecs))
 		return 1;
 
-- 
gitgitgadget
Previous: Johannes Schindelin via GitGitGadgetNext: Junio C Hamano
Message 3 of 5 in “pull: release handles to pack files before potentially gc'ing”
  1. 0/2 pull: release handles to pack files before potentially gc'ingJohannes Schindelin via GitGitGadget, Sep 8, 2021
  2. 1/2 commit-graph: when closing the graph, also release the slabJohannes Schindelin via GitGitGadget, Sep 8, 2021
  3. 2/2 pull: release packs before fetchingJohannes Schindelin via GitGitGadget, Sep 8, 2021
  4. Junio C HamanoSep 8, 2021
  5. Johannes SchindelinSep 9, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.