git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] git-repack: create new packs inside $PACKDIR, not cwd
@ 2006-09-04  5:42 Martin Langhoff
  2006-09-04  9:08 ` Martin Waitz
  0 siblings, 1 reply; 9+ messages in thread
From: Martin Langhoff @ 2006-09-04  5:42 UTC (permalink / raw)
  To: git, junkio; +Cc: Martin Langhoff

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

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2006-09-04 20:16 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <1157337502104-git-send-email-martin@catalyst.net.nz>
2006-09-04  2:42 ` [PATCH] git-repack: create new packs inside $PACKDIR, not cwd Martin Langhoff (CatalystIT)
2006-09-04  5:42 Martin Langhoff
2006-09-04  9:08 ` 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

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).