3 # Copyright (c) 2005 Linus Torvalds
6 USAGE
='[-a] [-d] [-f] [-l] [-n] [-q]'
10 no_update_info
= all_into_one
= remove_redundant
=
11 local= quiet
= no_reuse_delta
= extra
=
12 while case "$#" in 0) break ;; esac
15 -n) no_update_info
=t
;;
17 -d) remove_redundant
=t
;;
19 -f) no_reuse_delta
=--no-reuse-delta ;;
21 --window=*) extra
="$extra $1" ;;
22 --depth=*) extra
="$extra $1" ;;
28 PACKDIR
="$GIT_OBJECT_DIRECTORY/pack"
29 PACKTMP
="$GIT_DIR/.tmp-$$-pack"
31 trap 'rm -f "$PACKTMP"-*' 0 1 2 3 15
33 # There will be more repacking strategies to come...
34 case ",$all_into_one," in
36 args
='--unpacked --incremental'
41 # Redundancy check in all-into-one case is trivial.
42 existing
=`test -d "$PACKDIR" && cd "$PACKDIR" && \
43 find . -type f \( -name '*.pack' -o -name '*.idx' \) -print`
47 args
="$args $local $quiet $no_reuse_delta$extra"
48 name
=$
(git-pack-objects
--non-empty --all $args </dev
/null
"$PACKTMP") ||
50 if [ -z "$name" ]; then
51 echo Nothing new to pack.
53 if test "$quiet" != '-q'; then
54 echo "Pack pack-$name created."
56 mkdir
-p "$PACKDIR" ||
exit
60 if test -f "$PACKDIR/pack-$name.$sfx"
62 mv -f "$PACKDIR/pack-$name.$sfx" \
63 "$PACKDIR/old-pack-$name.$sfx"
66 mv -f "$PACKTMP-$name.pack" "$PACKDIR/pack-$name.pack" &&
67 mv -f "$PACKTMP-$name.idx" "$PACKDIR/pack-$name.idx" &&
68 test -f "$PACKDIR/pack-$name.pack" &&
69 test -f "$PACKDIR/pack-$name.idx" ||
{
70 echo >&2 "Couldn't replace the existing pack with updated one."
71 echo >&2 "The original set of packs have been saved as"
72 echo >&2 "old-pack-$name.{pack,idx} in $PACKDIR."
75 rm -f "$PACKDIR/old-pack-$name.pack" "$PACKDIR/old-pack-$name.idx"
78 if test "$remove_redundant" = t
80 # We know $existing are all redundant only when
81 # all-into-one is used.
82 if test "$all_into_one" != '' && test "$existing" != ''
89 .
/pack-
$name.pack | .
/pack-
$name.idx
) ;;
98 case "$no_update_info" in
100 *) git-update-server-info
;;