3 # Copyright (c) 2005 Linus Torvalds
6 USAGE='[-a] [-d] [-f] [-l] [-n] [-q]'
9 no_update_info= all_into_one= remove_redundant=
10 local= quiet= no_reuse_delta= extra=
11 while case "$#" in 0) break ;; esac
14 -n) no_update_info=t ;;
16 -d) remove_redundant=t ;;
18 -f) no_reuse_delta=--no-reuse-delta ;;
20 --window=*) extra="$extra $1" ;;
21 --depth=*) extra="$extra $1" ;;
28 PACKDIR="$GIT_OBJECT_DIRECTORY/pack"
30 # There will be more repacking strategies to come...
31 case ",$all_into_one," in
34 pack_objects='--incremental'
40 # Redundancy check in all-into-one case is trivial.
41 existing=`cd "$PACKDIR" && \
42 find . -type f \( -name '*.pack' -o -name '*.idx' \) -print`
45 pack_objects="$pack_objects $local $quiet $no_reuse_delta$extra"
46 name=$( { git-rev-list --objects --all $rev_list ||
47 echo "git-rev-list died with exit code $?"
49 git-pack-objects --non-empty $pack_objects .tmp-pack) ||
51 if [ -z "$name" ]; then
52 echo Nothing new to pack.
54 if test "$quiet" != '-q'; then
55 echo "Pack pack-$name created."
57 mkdir -p "$PACKDIR" || exit
61 if test -f "$PACKDIR/pack-$name.$sfx"
63 mv -f "$PACKDIR/pack-$name.$sfx" \
64 "$PACKDIR/old-pack-$name.$sfx"
67 mv -f .tmp-pack-$name.pack "$PACKDIR/pack-$name.pack" &&
68 mv -f .tmp-pack-$name.idx "$PACKDIR/pack-$name.idx" &&
69 test -f "$PACKDIR/pack-$name.pack" &&
70 test -f "$PACKDIR/pack-$name.idx" || {
71 echo >&2 "Couldn't replace the existing pack with updated one."
72 echo >&2 "The original set of packs have been saved as"
73 echo >&2 "old-pack-$name.{pack,idx} in $PACKDIR."
76 rm -f "$PACKDIR/old-pack-$name.pack" "$PACKDIR/old-pack-$name.idx"
79 if test "$remove_redundant" = t
81 # We know $existing are all redundant only when
82 # all-into-one is used.
83 if test "$all_into_one" != '' && test "$existing" != ''
90 ./pack-$name.pack | ./pack-$name.idx) ;;
99 case "$no_update_info" in
101 *) git-update-server-info ;;