2005-07-03 20:38:01 +00:00
|
|
|
#!/bin/sh
|
2005-08-24 17:40:58 +00:00
|
|
|
#
|
|
|
|
# Copyright (c) 2005 Linus Torvalds
|
|
|
|
#
|
|
|
|
|
2006-02-16 19:57:18 +00:00
|
|
|
USAGE='[-a] [-d] [-f] [-l] [-n] [-q]'
|
2005-11-24 08:12:11 +00:00
|
|
|
. git-sh-setup
|
2006-04-19 17:05:12 +00:00
|
|
|
|
2006-02-16 19:57:18 +00:00
|
|
|
no_update_info= all_into_one= remove_redundant=
|
2006-04-19 17:05:12 +00:00
|
|
|
local= quiet= no_reuse_delta= extra=
|
2005-08-24 17:40:58 +00:00
|
|
|
while case "$#" in 0) break ;; esac
|
|
|
|
do
|
|
|
|
case "$1" in
|
|
|
|
-n) no_update_info=t ;;
|
2005-08-29 17:29:53 +00:00
|
|
|
-a) all_into_one=t ;;
|
2005-11-17 14:34:47 +00:00
|
|
|
-d) remove_redundant=t ;;
|
2006-02-16 19:57:18 +00:00
|
|
|
-q) quiet=-q ;;
|
|
|
|
-f) no_reuse_delta=--no-reuse-delta ;;
|
|
|
|
-l) local=--local ;;
|
2006-04-19 17:05:12 +00:00
|
|
|
--window=*) extra="$extra $1" ;;
|
|
|
|
--depth=*) extra="$extra $1" ;;
|
2005-12-13 22:30:32 +00:00
|
|
|
*) usage ;;
|
2005-08-24 17:40:58 +00:00
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
2005-07-03 22:34:04 +00:00
|
|
|
rm -f .tmp-pack-*
|
2005-08-29 17:29:53 +00:00
|
|
|
PACKDIR="$GIT_OBJECT_DIRECTORY/pack"
|
|
|
|
|
|
|
|
# There will be more repacking strategies to come...
|
|
|
|
case ",$all_into_one," in
|
|
|
|
,,)
|
|
|
|
rev_list='--unpacked'
|
|
|
|
pack_objects='--incremental'
|
|
|
|
;;
|
|
|
|
,t,)
|
|
|
|
rev_list=
|
|
|
|
pack_objects=
|
2005-11-19 20:13:53 +00:00
|
|
|
|
|
|
|
# Redundancy check in all-into-one case is trivial.
|
|
|
|
existing=`cd "$PACKDIR" && \
|
|
|
|
find . -type f \( -name '*.pack' -o -name '*.idx' \) -print`
|
2005-08-29 17:29:53 +00:00
|
|
|
;;
|
|
|
|
esac
|
2006-04-19 17:05:12 +00:00
|
|
|
pack_objects="$pack_objects $local $quiet $no_reuse_delta$extra"
|
2006-04-03 03:50:17 +00:00
|
|
|
name=$(git-rev-list --objects --all $rev_list 2>&1 |
|
2005-08-29 17:29:53 +00:00
|
|
|
git-pack-objects --non-empty $pack_objects .tmp-pack) ||
|
2005-07-03 20:38:01 +00:00
|
|
|
exit 1
|
2005-08-29 17:29:53 +00:00
|
|
|
if [ -z "$name" ]; then
|
|
|
|
echo Nothing new to pack.
|
2006-05-07 18:18:53 +00:00
|
|
|
else
|
|
|
|
echo "Pack pack-$name created."
|
2005-08-29 17:29:53 +00:00
|
|
|
|
2006-05-07 18:18:53 +00:00
|
|
|
mkdir -p "$PACKDIR" || exit
|
2005-08-29 17:29:53 +00:00
|
|
|
|
2006-05-07 18:18:53 +00:00
|
|
|
mv .tmp-pack-$name.pack "$PACKDIR/pack-$name.pack" &&
|
|
|
|
mv .tmp-pack-$name.idx "$PACKDIR/pack-$name.idx" ||
|
|
|
|
exit
|
|
|
|
fi
|
2005-08-29 17:29:53 +00:00
|
|
|
|
2005-11-17 14:34:47 +00:00
|
|
|
if test "$remove_redundant" = t
|
2005-08-29 17:29:53 +00:00
|
|
|
then
|
2005-11-19 20:13:53 +00:00
|
|
|
# We know $existing are all redundant only when
|
|
|
|
# all-into-one is used.
|
|
|
|
if test "$all_into_one" != '' && test "$existing" != ''
|
2005-11-18 20:36:12 +00:00
|
|
|
then
|
2005-11-19 20:13:53 +00:00
|
|
|
sync
|
|
|
|
( cd "$PACKDIR" &&
|
|
|
|
for e in $existing
|
|
|
|
do
|
2005-11-18 20:36:12 +00:00
|
|
|
case "$e" in
|
|
|
|
./pack-$name.pack | ./pack-$name.idx) ;;
|
2005-11-19 20:13:53 +00:00
|
|
|
*) rm -f $e ;;
|
2005-11-18 20:36:12 +00:00
|
|
|
esac
|
2005-11-19 20:13:53 +00:00
|
|
|
done
|
|
|
|
)
|
2005-08-29 17:29:53 +00:00
|
|
|
fi
|
2006-03-11 06:05:47 +00:00
|
|
|
git-prune-packed
|
2005-08-29 17:29:53 +00:00
|
|
|
fi
|
2005-08-24 17:40:58 +00:00
|
|
|
|
|
|
|
case "$no_update_info" in
|
|
|
|
t) : ;;
|
|
|
|
*) git-update-server-info ;;
|
|
|
|
esac
|