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" ;;
27 PACKDIR
="$GIT_OBJECT_DIRECTORY/pack"
28 PACKTMP
="$GIT_DIR/.tmp-$$-pack"
30 trap 'rm -f "$PACKTMP"-*' 0 1 2 3 15
32 # There will be more repacking strategies to come...
33 case ",$all_into_one," in
36 pack_objects
='--incremental'
42 # Redundancy check in all-into-one case is trivial.
43 existing
=`test -d "$PACKDIR" && cd "$PACKDIR" && \
44 find . -type f \( -name '*.pack' -o -name '*.idx' \) -print`
48 pack_objects
="$pack_objects $local $quiet $no_reuse_delta$extra"
49 name
=$
( { git-rev-list
--objects --all $rev_list ||
50 echo "git-rev-list died with exit code $?"
52 git-pack-objects
--non-empty $pack_objects "$PACKTMP") ||
54 if [ -z "$name" ]; then
55 echo Nothing new to pack.
57 if test "$quiet" != '-q'; then
58 echo "Pack pack-$name created."
60 mkdir
-p "$PACKDIR" ||
exit
64 if test -f "$PACKDIR/pack-$name.$sfx"
66 mv -f "$PACKDIR/pack-$name.$sfx" \
67 "$PACKDIR/old-pack-$name.$sfx"
70 mv -f "$PACKTMP-$name.pack" "$PACKDIR/pack-$name.pack" &&
71 mv -f "$PACKTMP-$name.idx" "$PACKDIR/pack-$name.idx" &&
72 test -f "$PACKDIR/pack-$name.pack" &&
73 test -f "$PACKDIR/pack-$name.idx" ||
{
74 echo >&2 "Couldn't replace the existing pack with updated one."
75 echo >&2 "The original set of packs have been saved as"
76 echo >&2 "old-pack-$name.{pack,idx} in $PACKDIR."
79 rm -f "$PACKDIR/old-pack-$name.pack" "$PACKDIR/old-pack-$name.idx"
82 if test "$remove_redundant" = t
84 # We know $existing are all redundant only when
85 # all-into-one is used.
86 if test "$all_into_one" != '' && test "$existing" != ''
93 .
/pack-
$name.pack | .
/pack-
$name.idx
) ;;
102 case "$no_update_info" in
104 *) git-update-server-info
;;