summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@g5.osdl.org>2005-07-03 20:38:01 (GMT)
committerLinus Torvalds <torvalds@g5.osdl.org>2005-07-03 20:38:01 (GMT)
commitb2d46199d24856a05f455236031935dd35b3116f (patch)
treea001d1b98463edd11837b2881c0d1ac3616b8cf6
parent1c4a29120240a35b9c02afa636dac3e55ac96cb0 (diff)
downloadgit-b2d46199d24856a05f455236031935dd35b3116f.zip
git-b2d46199d24856a05f455236031935dd35b3116f.tar.gz
git-b2d46199d24856a05f455236031935dd35b3116f.tar.bz2
Add "git repack" command that does an incremental pack
-rw-r--r--Makefile2
-rw-r--r--git-repack-script18
2 files changed, 19 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index e86ba65..2590c81 100644
--- a/Makefile
+++ b/Makefile
@@ -31,7 +31,7 @@ SCRIPTS=git git-apply-patch-script git-merge-one-file-script git-prune-script \
git-fetch-script git-status-script git-commit-script \
git-log-script git-shortlog git-cvsimport-script git-diff-script \
git-reset-script git-add-script git-checkout-script git-clone-script \
- gitk git-cherry git-rebase-script git-relink-script
+ gitk git-cherry git-rebase-script git-relink-script git-repack-script
PROG= git-update-cache git-diff-files git-init-db git-write-tree \
git-read-tree git-commit-tree git-cat-file git-fsck-cache \
diff --git a/git-repack-script b/git-repack-script
new file mode 100644
index 0000000..ce35235
--- /dev/null
+++ b/git-repack-script
@@ -0,0 +1,18 @@
+#!/bin/sh
+: ${GIT_DIR=.git}
+: ${GIT_OBJECT_DIRECTORY="$GIT_DIR/objects"}
+packname=$(date +"pack-%s")
+if [ -f "$GIT_OBJECT_DIRECTORY/pack/$packname.idx" ]; then
+ echo Pack $packname already exists
+ exit 1
+fi
+rm -f $packname.idx $packname.pack
+git-rev-list --unpacked --objects $(git-rev-parse --all) |
+ git-pack-objects --non-empty --incremental $packname ||
+ exit 1
+
+if [ ! -f $packname.idx ]; then
+ echo Nothing new to pack
+ exit 0
+fi
+mv $packname.idx $packname.pack "$GIT_OBJECT_DIRECTORY/pack/"