git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Shawn Pearce <spearce@spearce.org>
To: Junio C Hamano <junkio@cox.net>
Cc: Linus Torvalds <torvalds@osdl.org>, git@vger.kernel.org
Subject: Re: fetching packs and storing them as packs
Date: Sat, 28 Oct 2006 04:40:01 -0400	[thread overview]
Message-ID: <20061028084001.GC14607@spearce.org> (raw)
In-Reply-To: <20061028072146.GB14607@spearce.org>

Shawn Pearce <spearce@spearce.org> wrote:
> Why not just use create a new flag file?
> 
> Lets say that a pack X is NOT eligible to be repacked if
> "$GIT_DIR/objects/pack/pack-X.keep" exists.

Here's the `git repack -a -d` portion of that.
Thoughts?

-- >8 --
[PATCH] Only repack active packs by skipping over kept packs.

During `git repack -a -d` only repack objects which are loose or
which reside in an active (a non-kept) pack.  This allows the user
to keep large packs as-is without continuous repacking and can be
very helpful on large repositories.  It should also help us resolve
a race condition between `git repack -a -d` and the new pack store
functionality in `git-receive-pack`.

Kept packs are those which have a corresponding .keep file in
$GIT_OBJECT_DIRECTORY/pack.  That is pack-X.pack will be kept
(not repacked and not deleted) if pack-X.keep exists in the same
directory when `git repack -a -d` starts.

Currently this feature is not documented and there is no user
interface to keep an existing pack.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 git-repack.sh |   48 +++++++++++++++++++++++++++++++-----------------
 1 files changed, 31 insertions(+), 17 deletions(-)

diff --git a/git-repack.sh b/git-repack.sh
index 17e2452..fe1e2ef 100755
--- a/git-repack.sh
+++ b/git-repack.sh
@@ -43,13 +43,30 @@ trap 'rm -f "$PACKTMP"-*' 0 1 2 3 15
 case ",$all_into_one," in
 ,,)
 	args='--unpacked --incremental'
+	active=
 	;;
 ,t,)
-	args=
-
-	# Redundancy check in all-into-one case is trivial.
-	existing=`test -d "$PACKDIR" && cd "$PACKDIR" && \
-	    find . -type f \( -name '*.pack' -o -name '*.idx' \) -print`
+	args=--unpacked
+	active=
+	if test -d "$PACKDIR"
+	then
+		for p in `find "$PACKDIR" -type f -name '*.pack' -print`
+		do
+			n=`basename "$p" .pack`
+			d=`dirname "$p"`
+			if test -e "$d/$n.keep"
+			then
+				: keep
+			else
+				args="$args --unpacked=$p"
+				active="$active $n"
+			fi
+		done
+	fi
+	if test "X$args" = X--unpacked
+	then
+		args='--unpacked --incremental'
+	fi
 	;;
 esac
 
@@ -86,20 +103,17 @@ fi
 
 if test "$remove_redundant" = t
 then
-	# We know $existing are all redundant only when
-	# all-into-one is used.
-	if test "$all_into_one" != '' && test "$existing" != ''
+	# We know $active are all redundant.
+	if test "$active" != ''
 	then
 		sync
-		( cd "$PACKDIR" &&
-		  for e in $existing
-		  do
-			case "$e" in
-			./pack-$name.pack | ./pack-$name.idx) ;;
-			*)	rm -f $e ;;
-			esac
-		  done
-		)
+		for n in $active
+		do
+			if test "$n" != "pack-$name"
+			then
+				rm -f "$PACKDIR/$n.pack" "$PACKDIR/$n.idx"
+			fi
+		done
 	fi
 	git-prune-packed
 fi
-- 
1.4.3.3.g7d63

  reply	other threads:[~2006-10-28  8:40 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-26  3:44 fetching packs and storing them as packs Nicolas Pitre
2006-10-26 14:45 ` Eran Tromer
     [not found]   ` <Pine.LNX.4.64.0610261105200.12418@xanadu.home>
2006-10-26 22:09     ` Eran Tromer
2006-10-27  0:50       ` Nicolas Pitre
2006-10-27  1:42         ` Shawn Pearce
2006-10-27  2:38           ` Sean
2006-10-27  6:57             ` Junio C Hamano
2006-10-27 17:23               ` Nicolas Pitre
2006-10-27  2:41           ` Nicolas Pitre
2006-10-27  2:42           ` Eran Tromer
2006-10-27  3:00             ` Shawn Pearce
2006-10-27  3:13               ` Sean
2006-10-27  3:20                 ` Jakub Narebski
2006-10-27  3:27                   ` Sean
2006-10-27  4:03               ` Eran Tromer
2006-10-27  4:42                 ` Shawn Pearce
2006-10-27  7:42                   ` Alex Riesen
2006-10-27  7:52                     ` Shawn Pearce
2006-10-27  8:08                       ` Alex Riesen
2006-10-27  8:13                         ` Shawn Pearce
2006-10-27 14:27               ` Nicolas Pitre
2006-10-27 14:38                 ` Petr Baudis
2006-10-27 14:48                   ` J. Bruce Fields
2006-10-27 15:03                     ` Petr Baudis
2006-10-27 16:04                       ` J. Bruce Fields
2006-10-27 16:05                         ` J. Bruce Fields
2006-10-27 18:56                   ` Junio C Hamano
2006-10-27 20:22   ` Linus Torvalds
2006-10-27 21:53     ` Junio C Hamano
2006-10-28  3:42       ` Shawn Pearce
2006-10-28  4:09         ` Junio C Hamano
2006-10-28  4:18         ` Linus Torvalds
2006-10-28  5:42           ` Junio C Hamano
2006-10-28  7:21             ` Shawn Pearce
2006-10-28  8:40               ` Shawn Pearce [this message]
2006-10-28 19:15                 ` Junio C Hamano
2006-10-29  3:50                   ` Shawn Pearce
2006-10-29  4:29                     ` Junio C Hamano
2006-10-29  4:38                       ` Shawn Pearce
2006-10-29  5:16                         ` Junio C Hamano
2006-10-29  5:21                           ` Shawn Pearce
2006-10-28 17:59               ` Linus Torvalds
2006-10-28 18:34               ` Junio C Hamano
2006-10-28 22:31               ` Eran Tromer
2006-10-29  3:38                 ` Shawn Pearce
2006-10-29  3:48                   ` Jakub Narebski
2006-10-29  3:52                     ` Shawn Pearce
2006-10-29  7:47 ` [PATCH] send-pack --keep: do not explode into loose objects on the receiving end Junio C Hamano
2006-10-29  7:56   ` Shawn Pearce
2006-10-29  8:05     ` Junio C Hamano
2006-10-30  1:44     ` Nicolas Pitre

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=20061028084001.GC14607@spearce.org \
    --to=spearce@spearce.org \
    --cc=git@vger.kernel.org \
    --cc=junkio@cox.net \
    --cc=torvalds@osdl.org \
    /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).