Commit 96df833b63f37c21240094aa740f05600ef9c2b9

lhchavez 2017-01-03T19:15:09

Close the file before unlinking I forgot that Windows chokes while trying to delete open files.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
diff --git a/src/indexer.c b/src/indexer.c
index 27f4947..9315362 100644
--- a/src/indexer.c
+++ b/src/indexer.c
@@ -1091,6 +1091,12 @@ void git_indexer_free(git_indexer *idx)
 	git_vector_free_deep(&idx->deltas);
 
 	/* Try to delete the temporary file in case it was not committed. */
+	git_mwindow_free_all(&idx->pack->mwf);
+	/* We need to close the descriptor here so Windows doesn't choke on unlink */
+	if (idx->pack->mwf.fd != -1) {
+		(void)p_close(idx->pack->mwf.fd);
+		idx->pack->mwf.fd = -1;
+	}
 	(void)p_unlink(idx->pack->pack_name);
 
 	if (!git_mutex_lock(&git__mwindow_mutex)) {