Shawn Pearce <spearce@xxxxxxxxxxx> wrote: > Why not just use create a new flag file? > > Lets say that a pack X is NOT eligible to be repacked if > "$GIT_DIR/objects/pack/pack-X.keep" exists. Here's the `git repack -a -d` portion of that. Thoughts? -- >8 -- [PATCH] Only repack active packs by skipping over kept packs. During `git repack -a -d` only repack objects which are loose or which reside in an active (a non-kept) pack. This allows the user to keep large packs as-is without continuous repacking and can be very helpful on large repositories. It should also help us resolve a race condition between `git repack -a -d` and the new pack store functionality in `git-receive-pack`. Kept packs are those which have a corresponding .keep file in $GIT_OBJECT_DIRECTORY/pack. That is pack-X.pack will be kept (not repacked and not deleted) if pack-X.keep exists in the same directory when `git repack -a -d` starts. Currently this feature is not documented and there is no user interface to keep an existing pack. Signed-off-by: Shawn O. Pearce <spearce@xxxxxxxxxxx> --- git-repack.sh | 48 +++++++++++++++++++++++++++++++----------------- 1 files changed, 31 insertions(+), 17 deletions(-) diff --git a/git-repack.sh b/git-repack.sh index 17e2452..fe1e2ef 100755 --- a/git-repack.sh +++ b/git-repack.sh @@ -43,13 +43,30 @@ trap 'rm -f "$PACKTMP"-*' 0 1 2 3 15 case ",$all_into_one," in ,,) args='--unpacked --incremental' + active= ;; ,t,) - args= - - # Redundancy check in all-into-one case is trivial. - existing=`test -d "$PACKDIR" && cd "$PACKDIR" && \ - find . -type f \( -name '*.pack' -o -name '*.idx' \) -print` + args=--unpacked + active= + if test -d "$PACKDIR" + then + for p in `find "$PACKDIR" -type f -name '*.pack' -print` + do + n=`basename "$p" .pack` + d=`dirname "$p"` + if test -e "$d/$n.keep" + then + : keep + else + args="$args --unpacked=$p" + active="$active $n" + fi + done + fi + if test "X$args" = X--unpacked + then + args='--unpacked --incremental' + fi ;; esac @@ -86,20 +103,17 @@ fi if test "$remove_redundant" = t then - # We know $existing are all redundant only when - # all-into-one is used. - if test "$all_into_one" != '' && test "$existing" != '' + # We know $active are all redundant. + if test "$active" != '' then sync - ( cd "$PACKDIR" && - for e in $existing - do - case "$e" in - ./pack-$name.pack | ./pack-$name.idx) ;; - *) rm -f $e ;; - esac - done - ) + for n in $active + do + if test "$n" != "pack-$name" + then + rm -f "$PACKDIR/$n.pack" "$PACKDIR/$n.idx" + fi + done fi git-prune-packed fi -- 1.4.3.3.g7d63 - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html