packfile: close commit-graph in close_all_packs

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> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Derrick Stolee committed May 17, 2019 at 11:41 UTC 5472c32c3724e1404c3d80368edc28910969c29a
1 file changed +3
packfile.c
+3
@@ -16,6 +16,7 @@
16 #include "tree.h"
17 #include "object-store.h"
18 #include "midx.h"
19 +#include "commit-graph.h"
20
21 char *odb_pack_name(struct strbuf *buf,
22 const unsigned char *sha1,
@@ -350,6 +351,8 @@ void close_all_packs(struct raw_object_store *o)
351 close_midx(o->multi_pack_index);
352 o->multi_pack_index = NULL;
353 }
354 +
355 + close_commit_graph(o);
356 }
357
358 /*