Skip to content

Commit 54352bb

Browse files
torvaldsgitster
authored andcommitted
Remove now unnecessary 'sync()' calls
Since the pack-files are now always created stably on disk, there is no need to sync() before pruning lose objects or old stale pack-files. [jc: with Nico's clean-up] Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 4c81b03 commit 54352bb

File tree

4 files changed

+4
-6
lines changed

4 files changed

+4
-6
lines changed

builtin-pack-objects.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -514,9 +514,10 @@ static void write_pack_file(void)
514514
* Did we write the wrong # entries in the header?
515515
* If so, rewrite it like in fast-import
516516
*/
517-
if (pack_to_stdout || nr_written == nr_remaining) {
518-
unsigned flags = pack_to_stdout ? CSUM_CLOSE : CSUM_FSYNC;
519-
sha1close(f, sha1, flags);
517+
if (pack_to_stdout) {
518+
sha1close(f, sha1, CSUM_CLOSE);
519+
} else if (nr_written == nr_remaining) {
520+
sha1close(f, sha1, CSUM_FSYNC);
520521
} else {
521522
int fd = sha1close(f, NULL, 0);
522523
fixup_pack_header_footer(fd, sha1, pack_tmp_name, nr_written);

builtin-prune-packed.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ int cmd_prune_packed(int argc, const char **argv, const char *prefix)
8585
/* Handle arguments here .. */
8686
usage(prune_packed_usage);
8787
}
88-
sync();
8988
prune_packed_objects(opts);
9089
return 0;
9190
}

builtin-prune.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@ int cmd_prune(int argc, const char **argv, const char *prefix)
156156
mark_reachable_objects(&revs, 1);
157157
prune_object_dir(get_object_directory());
158158

159-
sync();
160159
prune_packed_objects(show_only);
161160
remove_temporary_files();
162161
return 0;

git-repack.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ then
125125
# We know $existing are all redundant.
126126
if [ -n "$existing" ]
127127
then
128-
sync
129128
( cd "$PACKDIR" &&
130129
for e in $existing
131130
do

0 commit comments

Comments
 (0)