Only repack active packs by skipping over kept packs.
During `git repack -a -d` only repack objects which are loose or which reside in an active (a non-kept) pack. This allows the user to keep large packs as-is without continuous repacking and can be very helpful on large repositories. It should also help us resolve a race condition between `git repack -a -d` and the new pack store functionality in `git-receive-pack`. Kept packs are those which have a corresponding .keep file in $GIT_OBJECT_DIRECTORY/pack. That is pack-X.pack will be kept (not repacked and not deleted) if pack-X.keep exists in the same directory when `git repack -a -d` starts. Currently this feature is not documented and there is no user interface to keep an existing pack. Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:

committed by
Junio C Hamano

parent
d4ff6d92c3
commit
ce8590748b
@ -45,11 +45,19 @@ case ",$all_into_one," in
|
|||||||
args='--unpacked --incremental'
|
args='--unpacked --incremental'
|
||||||
;;
|
;;
|
||||||
,t,)
|
,t,)
|
||||||
args=
|
if [ -d "$PACKDIR" ]; then
|
||||||
|
for e in `cd "$PACKDIR" && find . -type f -name '*.pack' \
|
||||||
# Redundancy check in all-into-one case is trivial.
|
| sed -e 's/^\.\///' -e 's/\.pack$//'`
|
||||||
existing=`test -d "$PACKDIR" && cd "$PACKDIR" && \
|
do
|
||||||
find . -type f \( -name '*.pack' -o -name '*.idx' \) -print`
|
if [ -e "$PACKDIR/$e.keep" ]; then
|
||||||
|
: keep
|
||||||
|
else
|
||||||
|
args="$args --unpacked=$e.pack"
|
||||||
|
existing="$existing $e"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
[ -z "$args" ] && args='--unpacked --incremental'
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
@ -86,17 +94,16 @@ fi
|
|||||||
|
|
||||||
if test "$remove_redundant" = t
|
if test "$remove_redundant" = t
|
||||||
then
|
then
|
||||||
# We know $existing are all redundant only when
|
# We know $existing are all redundant.
|
||||||
# all-into-one is used.
|
if [ -n "$existing" ]
|
||||||
if test "$all_into_one" != '' && test "$existing" != ''
|
|
||||||
then
|
then
|
||||||
sync
|
sync
|
||||||
( cd "$PACKDIR" &&
|
( cd "$PACKDIR" &&
|
||||||
for e in $existing
|
for e in $existing
|
||||||
do
|
do
|
||||||
case "$e" in
|
case "$e" in
|
||||||
./pack-$name.pack | ./pack-$name.idx) ;;
|
pack-$name) ;;
|
||||||
*) rm -f $e ;;
|
*) rm -f "$e.pack" "$e.idx" "$e.keep" ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user