summaryrefslogtreecommitdiff
path: root/git-repack.sh
diff options
context:
space:
mode:
authorMartin Langhoff <martin@catalyst.net.nz>2006-09-04 05:42:32 (GMT)
committerJunio C Hamano <junkio@cox.net>2006-09-06 07:21:57 (GMT)
commit0ea2582d1cbbacd91eb0f040c4994ecd2bb6cdb9 (patch)
treef0b4715b6dd34e8386cb18616b0d8e2be8c6d67e /git-repack.sh
parent42cabc341c4e6da3c9873db7af1003bd1a72a8fd (diff)
downloadgit-0ea2582d1cbbacd91eb0f040c4994ecd2bb6cdb9.zip
git-0ea2582d1cbbacd91eb0f040c4994ecd2bb6cdb9.tar.gz
git-0ea2582d1cbbacd91eb0f040c4994ecd2bb6cdb9.tar.bz2
git-repack: create new packs inside $GIT_DIR, not cwd
Avoid failing when cwd is !writable by writing the packfiles in $GIT_DIR, which is more in line with other commands. Without this, git-repack was failing when run from crontab by non-root user accounts. For large repositories, this also makes the mv operation a lot cheaper, and avoids leaving temp packfiles around the fs upon failure. Signed-off-by: Martin Langhoff <martin@catalyst.net.nz> Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'git-repack.sh')
-rwxr-xr-xgit-repack.sh11
1 files changed, 7 insertions, 4 deletions
diff --git a/git-repack.sh b/git-repack.sh
index 584a732..b525fc5 100755
--- a/git-repack.sh
+++ b/git-repack.sh
@@ -24,8 +24,10 @@ do
shift
done
-rm -f .tmp-pack-*
PACKDIR="$GIT_OBJECT_DIRECTORY/pack"
+PACKTMP="$GIT_DIR/.tmp-$$-pack"
+rm -f "$PACKTMP"-*
+trap 'rm -f "$PACKTMP"-*' 0 1 2 3 15
# There will be more repacking strategies to come...
case ",$all_into_one," in
@@ -42,11 +44,12 @@ case ",$all_into_one," in
find . -type f \( -name '*.pack' -o -name '*.idx' \) -print`
;;
esac
+
pack_objects="$pack_objects $local $quiet $no_reuse_delta$extra"
name=$( { git-rev-list --objects --all $rev_list ||
echo "git-rev-list died with exit code $?"
} |
- git-pack-objects --non-empty $pack_objects .tmp-pack) ||
+ git-pack-objects --non-empty $pack_objects "$PACKTMP") ||
exit 1
if [ -z "$name" ]; then
echo Nothing new to pack.
@@ -64,8 +67,8 @@ else
"$PACKDIR/old-pack-$name.$sfx"
fi
done &&
- mv -f .tmp-pack-$name.pack "$PACKDIR/pack-$name.pack" &&
- mv -f .tmp-pack-$name.idx "$PACKDIR/pack-$name.idx" &&
+ mv -f "$PACKTMP-$name.pack" "$PACKDIR/pack-$name.pack" &&
+ mv -f "$PACKTMP-$name.idx" "$PACKDIR/pack-$name.idx" &&
test -f "$PACKDIR/pack-$name.pack" &&
test -f "$PACKDIR/pack-$name.idx" || {
echo >&2 "Couldn't replace the existing pack with updated one."