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

[PATCH 2/3] packfile: close commit-graph in close_all_packs

From
Derrick Stolee via GitGitGadget <gitgitgadget@gmail.com>
Date
May 17, 2019, 18:41 UTC
Message-ID
<e4811af2ecb72fbaf22e41c74d9fe0dc6fef246e.1558118506.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.208.git.gitgitgadget@gmail.com>
From: Derrick Stolee <dstolee@microsoft.com>

The close_all_packs() method is used to close all read handles to pack-files and the multi-pack-index before running 'git gc --auto'. This is particularly important on the Windows platform, where read handles block any writes to those files. Replacing one of these files with a rename() will fail in this situation.

The commit-graph also performs a rename, so is susceptable to this problem. We are careful to close the commit-graph before writing, but that doesn't work when a 'git fetch' (or similar) process runs 'git gc --auto' which may write a commit-graph.

Here, close the commit-graph as part of close_all_packs().
Reported-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
---
 packfile.c | 3 +++
 1 file changed, 3 insertions(+)
diff --git a/packfile.c b/packfile.c
index 16bcb75262..ce12bffe3e 100644
--- a/packfile.c
+++ b/packfile.c
@@ -16,6 +16,7 @@
 #include "tree.h"
 #include "object-store.h"
 #include "midx.h"
+#include "commit-graph.h"
 
 char *odb_pack_name(struct strbuf *buf,
 		    const unsigned char *sha1,
@@ -350,6 +351,8 @@ void close_all_packs(struct raw_object_store *o)
 		close_midx(o->multi_pack_index);
 		o->multi_pack_index = NULL;
 	}
+
+	close_commit_graph(o);
 }
 
 /*
-- 
gitgitgadget
Previous: Derrick Stolee via GitGitGadgetNext: Derrick Stolee via GitGitGadget
Message 3 of 11 in “Close commit-graph before calling 'gc'”
  1. 0/3 Close commit-graph before calling 'gc'Derrick Stolee via GitGitGadget, May 17, 2019
  2. 1/3 commit-graph: use raw_object_store when closingDerrick Stolee via GitGitGadget, May 17, 2019
  3. 2/3 packfile: close commit-graph in close_all_packsDerrick Stolee via GitGitGadget, May 17, 2019
  4. 3/3 packfile: close_all_packs to close_object_storeDerrick Stolee via GitGitGadget, May 17, 2019
  5. Johannes SchindelinMay 20, 2019
  6. Derrick StoleeMay 20, 2019
  7. Junio C HamanoMay 28, 2019
  8. Junio C HamanoMay 19, 2019
  9. Johannes SchindelinMay 20, 2019
  10. Derrick StoleeMay 20, 2019
  11. Johannes SchindelinMay 20, 2019

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.