Skip to content

Commit

Permalink
packfile: close commit-graph in close_all_packs
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
derrickstolee authored and gitster committed Jun 12, 2019
1 parent c3a3a96 commit 5472c32
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
}

/*
Expand Down

0 comments on commit 5472c32

Please sign in to comment.