Since `pack-objects` will write a `.bitmap` file next to the `.pack` and
`.idx` files, this commit teaches `git-repack` to consider the new
bitmap indexes (if they exist) when performing repack operations.

This implies moving old bitmap indexes out of the way if we are
repacking a repository that already has them, and moving the newly
generated bitmap indexes into the `objects/pack` directory, next to
their corresponding packfiles.

Since `git repack` is now capable of handling these `.bitmap` files,
a normal `git gc` run on a repository that has `pack.usebitmaps` set
to true in its config file will generate bitmap indexes as part of the
garbage collection process.
---
 git-repack.sh |   10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/git-repack.sh b/git-repack.sh
index 7579331..d5355ae 100755
--- a/git-repack.sh
+++ b/git-repack.sh
@@ -108,7 +108,7 @@ rollback=
 failed=
 for name in $names
 do
-       for sfx in pack idx
+       for sfx in pack idx bitmap
        do
                file=pack-$name.$sfx
                test -f "$PACKDIR/$file" || continue
@@ -156,6 +156,11 @@ do
        fullbases="$fullbases pack-$name"
        chmod a-w "$PACKTMP-$name.pack"
        chmod a-w "$PACKTMP-$name.idx"
+
+       test -f "$PACKTMP-$name.bitmap" &&
+       chmod a-w "$PACKTMP-$name.bitmap" &&
+       mv -f "$PACKTMP-$name.bitmap" "$PACKDIR/pack-$name.bitmap"
+
        mv -f "$PACKTMP-$name.pack" "$PACKDIR/pack-$name.pack" &&
        mv -f "$PACKTMP-$name.idx"  "$PACKDIR/pack-$name.idx" ||
        exit
@@ -166,6 +171,7 @@ for name in $names
 do
        rm -f "$PACKDIR/old-pack-$name.idx"
        rm -f "$PACKDIR/old-pack-$name.pack"
+       rm -f "$PACKDIR/old-pack-$name.bitmap"
 done
 
 # End of pack replacement.
@@ -180,7 +186,7 @@ then
                  do
                        case " $fullbases " in
                        *" $e "*) ;;
-                       *)      rm -f "$e.pack" "$e.idx" "$e.keep" ;;
+                       *)      rm -f "$e.pack" "$e.idx" "$e.keep" "$e.bitmap" 
;;
                        esac
                  done
                )
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to