@matheusbsbs / matheus-bagliano / commits / ce8590748b
Fork 0

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>

Shawn Pearce committed Oct 29, 2006 at 04:37 UTC ce8590748b918687abc4c7cd2d432dd23f07ae40
1 file changed +17 -10
git-repack.sh
+17 -10
@@ -45,11 +45,19 @@ case ",$all_into_one," in
45 args='--unpacked --incremental'
46 ;;
47 ,t,)
48 - args=
49 -
50 - # Redundancy check in all-into-one case is trivial.
51 - existing=`test -d "$PACKDIR" && cd "$PACKDIR" && \
52 - find . -type f \( -name '*.pack' -o -name '*.idx' \) -print`
48 + if [ -d "$PACKDIR" ]; then
49 + for e in `cd "$PACKDIR" && find . -type f -name '*.pack' \
50 + | sed -e 's/^\.\///' -e 's/\.pack$//'`
51 + do
52 + if [ -e "$PACKDIR/$e.keep" ]; then
53 + : keep
54 + else
55 + args="$args --unpacked=$e.pack"
56 + existing="$existing $e"
57 + fi
58 + done
59 + fi
60 + [ -z "$args" ] && args='--unpacked --incremental'
61 ;;
62 esac
63
@@ -86,17 +94,16 @@ fi
94
95 if test "$remove_redundant" = t
96 then
89 - # We know $existing are all redundant only when
90 - # all-into-one is used.
91 - if test "$all_into_one" != '' && test "$existing" != ''
97 + # We know $existing are all redundant.
98 + if [ -n "$existing" ]
99 then
100 sync
101 ( cd "$PACKDIR" &&
102 for e in $existing
103 do
104 case "$e" in
98 - ./pack-$name.pack | ./pack-$name.idx) ;;
99 - *) rm -f $e ;;
105 + pack-$name) ;;
106 + *) rm -f "$e.pack" "$e.idx" "$e.keep" ;;
107 esac
108 done
109 )