2005-07-03 20:38:01 +00:00
|
|
|
#!/bin/sh
|
2005-08-24 17:40:58 +00:00
|
|
|
#
|
|
|
|
# Copyright (c) 2005 Linus Torvalds
|
|
|
|
#
|
|
|
|
|
2005-09-08 00:26:23 +00:00
|
|
|
. git-sh-setup || die "Not a git archive"
|
2005-07-08 17:57:21 +00:00
|
|
|
|
2005-10-13 22:38:29 +00:00
|
|
|
no_update_info= all_into_one= remove_redundant= local=
|
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 ;;
|
2005-10-13 22:38:29 +00:00
|
|
|
-l) local=t ;;
|
2005-08-24 17:40:58 +00:00
|
|
|
*) break ;;
|
|
|
|
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'
|
|
|
|
rev_parse='--all'
|
|
|
|
pack_objects='--incremental'
|
|
|
|
;;
|
|
|
|
,t,)
|
|
|
|
rev_list=
|
|
|
|
rev_parse='--all'
|
|
|
|
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
|
2005-10-13 22:38:29 +00:00
|
|
|
if [ "$local" ]; then
|
|
|
|
pack_objects="$pack_objects --local"
|
|
|
|
fi
|
2005-11-21 20:38:31 +00:00
|
|
|
name=$(git-rev-list --objects $rev_list $(git-rev-parse $rev_parse) 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.
|
2005-07-03 20:38:01 +00:00
|
|
|
exit 0
|
|
|
|
fi
|
2005-08-29 17:29:53 +00:00
|
|
|
echo "Pack pack-$name created."
|
|
|
|
|
|
|
|
mkdir -p "$PACKDIR" || exit
|
|
|
|
|
|
|
|
mv .tmp-pack-$name.pack "$PACKDIR/pack-$name.pack" &&
|
|
|
|
mv .tmp-pack-$name.idx "$PACKDIR/pack-$name.idx" ||
|
|
|
|
exit
|
|
|
|
|
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
|
|
|
|
fi
|
2005-08-24 17:40:58 +00:00
|
|
|
|
|
|
|
case "$no_update_info" in
|
|
|
|
t) : ;;
|
|
|
|
*) git-update-server-info ;;
|
|
|
|
esac
|