Commit eeceaac06c12b488ca1cb538db067b44664f4db9

lhchavez 2021-09-07T08:38:35

Also remove a `ftruncate(2)` call in `git_indexer_commit` Now that we're not using `mmap(2)` for writing stuff, we don't need to truncate the file afterwards, since it'll have the correct size at the end of the process. Whee~!

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 a5c282a..d1e354a 100644
--- a/src/indexer.c
+++ b/src/indexer.c
@@ -1234,12 +1234,6 @@ int git_indexer_commit(git_indexer *idx, git_indexer_progress *stats)
 	if (git_mwindow_free_all(&idx->pack->mwf) < 0)
 		goto on_error;
 
-	/* Truncate file to undo rounding up to next page_size in append_to_pack */
-	if (p_ftruncate(idx->pack->mwf.fd, idx->pack->mwf.size) < 0) {
-		git_error_set(GIT_ERROR_OS, "failed to truncate pack file '%s'", idx->pack->pack_name);
-		return -1;
-	}
-
 	if (idx->do_fsync && p_fsync(idx->pack->mwf.fd) < 0) {
 		git_error_set(GIT_ERROR_OS, "failed to fsync packfile");
 		goto on_error;