X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=git-repack.sh;h=da8e67f7a558229aa09216e7eb74713ca6c970cd;hb=38ebbacd93eb547b3608b64a2efc60fd79e1ea85;hp=4fb3f26e834f78d40ea629dcd6732d390a129d58;hpb=328b710d800dc3786fe2b8595e5553dc4a4af424;p=git.git diff --git a/git-repack.sh b/git-repack.sh index 4fb3f26e8..da8e67f7a 100755 --- a/git-repack.sh +++ b/git-repack.sh @@ -3,7 +3,8 @@ # Copyright (c) 2005 Linus Torvalds # -USAGE='[-a] [-d] [-f] [-l] [-n] [-q]' +USAGE='[-a] [-d] [-f] [-l] [-n] [-q] [--window=N] [--depth=N]' +SUBDIRECTORY_OK='Yes' . git-sh-setup no_update_info= all_into_one= remove_redundant= @@ -24,58 +25,92 @@ do shift done -rm -f .tmp-pack-* +# Later we will default repack.UseDeltaBaseOffset to true +default_dbo=false + +case "`git repo-config --bool repack.usedeltabaseoffset || + echo $default_dbo`" in +true) + extra="$extra --delta-base-offset" ;; +esac + PACKDIR="$GIT_OBJECT_DIRECTORY/pack" +PACKTMP="$GIT_DIR/.tmp-$$-pack" +rm -f "$PACKTMP"-* +trap 'rm -f "$PACKTMP"-*' 0 1 2 3 15 # There will be more repacking strategies to come... case ",$all_into_one," in ,,) - rev_list='--unpacked' - pack_objects='--incremental' + args='--unpacked --incremental' ;; ,t,) - rev_list= - pack_objects= - - # Redundancy check in all-into-one case is trivial. - existing=`cd "$PACKDIR" && \ - find . -type f \( -name '*.pack' -o -name '*.idx' \) -print` + if [ -d "$PACKDIR" ]; then + for e in `cd "$PACKDIR" && find . -type f -name '*.pack' \ + | sed -e 's/^\.\///' -e 's/\.pack$//'` + do + if [ -e "$PACKDIR/$e.keep" ]; then + : keep + else + args="$args --unpacked=$e.pack" + existing="$existing $e" + fi + done + fi + [ -z "$args" ] && args='--unpacked --incremental' ;; esac -pack_objects="$pack_objects $local $quiet $no_reuse_delta$extra" -name=$(git-rev-list --objects --all $rev_list 2>&1 | - git-pack-objects --non-empty $pack_objects .tmp-pack) || + +args="$args $local $quiet $no_reuse_delta$extra" +name=$(git-pack-objects --non-empty --all --reflog $args &2 "Couldn't replace the existing pack with updated one." + echo >&2 "The original set of packs have been saved as" + echo >&2 "old-pack-$name.{pack,idx} in $PACKDIR." + exit 1 + } + rm -f "$PACKDIR/old-pack-$name.pack" "$PACKDIR/old-pack-$name.idx" 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 $existing are all redundant. + if [ -n "$existing" ] then sync ( cd "$PACKDIR" && for e in $existing do case "$e" in - ./pack-$name.pack | ./pack-$name.idx) ;; - *) rm -f $e ;; + pack-$name) ;; + *) rm -f "$e.pack" "$e.idx" "$e.keep" ;; esac done ) fi - git-prune-packed + git-prune-packed $quiet fi case "$no_update_info" in