@matheusbsbs / matheus-bagliano / commits / 41f222e87a
Fork 0

Be marginally more careful about removing objects

The git philosophy when it comes to disk accesses is "Laugh in the face of danger". Notably, since we never modify an existing object, we don't really care that deeply about flushing things to disk, since even if the machine crashes in the middle of a git operation, you can never really have lost any old work. At most, you'd need to figure out the proper heads (which git-fsck-objects can do for you) and re-do the operation. However, there's two exceptions to this: pruning and repacking. Those operations will actually _delete_ old objects that they know about in other ways (ie that they just repacked, or that they have found in other places). However, since they actually modify old state, we should thus be a bit more careful about them. If the machine crashes and the duplicate new objects haven't been flushed to disk, you can actually be in trouble. This is trivially stupid about it by calling "sync" before removing the objects. Not very smart, but we're talking about special operations than are usually done once a week if that. Signed-off-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>

Linus Torvalds committed Oct 28, 2005 at 09:45 UTC 41f222e87a9062833712367d66114cae90b3769a
3 files changed +3
git-prune.sh
+1
@@ -15,6 +15,7 @@ do
15 shift;
16 done
17
18 +sync
19 git-fsck-objects --full --cache --unreachable "$@" |
20 sed -ne '/unreachable /{
21 s/unreachable [^ ][^ ]* //
git-repack.sh
+1
@@ -62,6 +62,7 @@ then
62 # all-into-one is used.
63 if test "$all_into_one" != '' && test "$existing" != ''
64 then
65 + sync
66 ( cd "$PACKDIR" &&
67 for e in $existing
68 do
prune-packed.c
+1
@@ -71,6 +71,7 @@ int main(int argc, char **argv)
71 /* Handle arguments here .. */
72 usage(prune_packed_usage);
73 }
74 + sync();
75 prune_packed_objects();
76 return 0;
77 }