From: Martin Langhoff <martin@catalyst.net.nz>
To: git@vger.kernel.org, junkio@cox.net
Cc: Martin Langhoff <martin@catalyst.net.nz>
Subject: [PATCH] git-repack: create new packs inside $PACKDIR, not cwd
Date: Mon, 4 Sep 2006 17:42:32 +1200 [thread overview]
Message-ID: <11573485523752-git-send-email-martin@catalyst.net.nz> (raw)
Avoid failing when cwd is !writable by writing the
packfiles directly in the $PACKDIR.
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>
---
git-repack.sh | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/git-repack.sh b/git-repack.sh
index 584a732..ccc8e43 100755
--- a/git-repack.sh
+++ b/git-repack.sh
@@ -42,11 +42,13 @@ case ",$all_into_one," in
find . -type f \( -name '*.pack' -o -name '*.idx' \) -print`
;;
esac
+
+mkdir -p "$PACKDIR" || exit
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 "$PACKDIR/.tmp-pack") ||
exit 1
if [ -z "$name" ]; then
echo Nothing new to pack.
@@ -54,7 +56,6 @@ else
if test "$quiet" != '-q'; then
echo "Pack pack-$name created."
fi
- mkdir -p "$PACKDIR" || exit
for sfx in pack idx
do
@@ -64,8 +65,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 "$PACKDIR/.tmp-pack-$name.pack" "$PACKDIR/pack-$name.pack" &&
+ mv -f "$PACKDIR/.tmp-pack-$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."
--
1.4.2.gdfe7
--
VGER BF report: S 1
next reply other threads:[~2006-09-04 8:40 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-09-04 5:42 Martin Langhoff [this message]
2006-09-04 9:08 ` [PATCH] git-repack: create new packs inside $PACKDIR, not cwd Martin Waitz
2006-09-04 9:36 ` Junio C Hamano
2006-09-04 9:50 ` Junio C Hamano
2006-09-04 10:03 ` Martin Langhoff (CatalystIT)
2006-09-04 10:13 ` Junio C Hamano
2006-09-04 10:46 ` Martin Langhoff (CatalystIT)
2006-09-04 20:16 ` Junio C Hamano
[not found] <1157337502104-git-send-email-martin@catalyst.net.nz>
2006-09-04 2:42 ` Martin Langhoff (CatalystIT)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=11573485523752-git-send-email-martin@catalyst.net.nz \
--to=martin@catalyst.net.nz \
--cc=git@vger.kernel.org \
--cc=junkio@cox.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).