* Be marginally more careful about removing objects
@ 2005-10-28 16:45 Linus Torvalds
0 siblings, 0 replies; only message in thread
From: Linus Torvalds @ 2005-10-28 16:45 UTC (permalink / raw)
To: Junio C Hamano, Git Mailing List
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>
---
diff --git a/git-prune.sh b/git-prune.sh
index b28630c..ef31bd2 100755
--- a/git-prune.sh
+++ b/git-prune.sh
@@ -15,6 +15,7 @@ do
shift;
done
+sync
git-fsck-objects --full --cache --unreachable "$@" |
sed -ne '/unreachable /{
s/unreachable [^ ][^ ]* //
diff --git a/git-repack.sh b/git-repack.sh
index 49547a7..d341966 100755
--- a/git-repack.sh
+++ b/git-repack.sh
@@ -62,6 +62,7 @@ then
# all-into-one is used.
if test "$all_into_one" != '' && test "$existing" != ''
then
+ sync
( cd "$PACKDIR" &&
for e in $existing
do
diff --git a/prune-packed.c b/prune-packed.c
index 16685d1..26123f7 100644
--- a/prune-packed.c
+++ b/prune-packed.c
@@ -71,6 +71,7 @@ int main(int argc, char **argv)
/* Handle arguments here .. */
usage(prune_packed_usage);
}
+ sync();
prune_packed_objects();
return 0;
}
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2005-10-28 16:46 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-10-28 16:45 Be marginally more careful about removing objects Linus Torvalds
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox