From f7aac2eac96b637755c89c2405a41749c8f6033a Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Thu, 13 Oct 2005 15:38:29 -0700 Subject: Add "-l" flag for repacking only local packs This uses the new "--local" flag to git-pack-objects. It currently only makes a difference together with "-a", since a normal incremental repack won't pack any packed objects at all (whether local or remote). Eventually, it might end up skipping any objects that aren't local to the current object directory, but for now it only knows to skip packed objects. Signed-off-by: Linus Torvalds Signed-off-by: Junio C Hamano --- git-repack.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'git-repack.sh') diff --git a/git-repack.sh b/git-repack.sh index b395d0ef34..49547a77c7 100755 --- a/git-repack.sh +++ b/git-repack.sh @@ -5,13 +5,14 @@ . git-sh-setup || die "Not a git archive" -no_update_info= all_into_one= remove_redundant= +no_update_info= all_into_one= remove_redundant= local= while case "$#" in 0) break ;; esac do case "$1" in -n) no_update_info=t ;; -a) all_into_one=t ;; -d) remove_redandant=t ;; + -l) local=t ;; *) break ;; esac shift @@ -37,6 +38,9 @@ case ",$all_into_one," in find . -type f \( -name '*.pack' -o -name '*.idx' \) -print` ;; esac +if [ "$local" ]; then + pack_objects="$pack_objects --local" +fi name=$(git-rev-list --objects $rev_list $(git-rev-parse $rev_parse) | git-pack-objects --non-empty $pack_objects .tmp-pack) || exit 1 -- cgit v1.3 From 41f222e87a9062833712367d66114cae90b3769a Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Fri, 28 Oct 2005 09:45:53 -0700 Subject: 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 Signed-off-by: Junio C Hamano --- git-prune.sh | 1 + git-repack.sh | 1 + prune-packed.c | 1 + 3 files changed, 3 insertions(+) (limited to 'git-repack.sh') diff --git a/git-prune.sh b/git-prune.sh index b28630cacf..ef31bd2a68 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 49547a77c7..d341966efb 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 16685d1d8b..26123f7f6b 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; } -- cgit v1.3