git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/3] Only repack active packs by skipping over kept packs.

From
Shawn Pearce <spearce@spearce.org>
Date
Oct 29, 2006, 09:37 UTC
Message-ID
<20061029093754.GD3847@spearce.org>

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 |   27 +++++++++++++++++----------
 1 files changed, 17 insertions(+), 10 deletions(-)
diff --git a/git-repack.sh b/git-repack.sh
index 17e2452..f150a55 100755
--- a/git-repack.sh
+++ b/git-repack.sh
@@ -45,11 +45,19 @@ case ",$all_into_one," in
 	args='--unpacked --incremental'
 	;;
 ,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`
+	if [ -d "$PACKDIR" ]; then
+		for e in `cd "$PACKDIR" && find . -type f -name '*.pack' \
+			| sed -e 's/^\.\///' -e 's/\.pack$//'`
+		do
+			if [ -e "$PACKDIR/$e.keep" ]; then
+				: keep
+			else
+				args="$args --unpacked=$e.pack"
+				existing="$existing $e"
+			fi
+		done
+	fi
+	[ -z "$args" ] && args='--unpacked --incremental'
 	;;
 esac
 
@@ -86,17 +94,16 @@ 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 $existing are all redundant.
+	if [ -n "$existing" ]
 	then
 		sync
 		( cd "$PACKDIR" &&
 		  for e in $existing
 		  do
 			case "$e" in
-			./pack-$name.pack | ./pack-$name.idx) ;;
-			*)	rm -f $e ;;
+			pack-$name) ;;
+			*)	rm -f "$e.pack" "$e.idx" "$e.keep" ;;
 			esac
 		  done
 		)
-- 
1.4.3.3.g7d63
Next: Nicolas Pitre
Message 1 of 17 in “Only repack active packs by skipping over kept packs.”
  1. 2/3 Only repack active packs by skipping over kept packs.Shawn Pearce, Oct 29, 2006
  2. WARNING: THIS PATCH CAN BREAK YOUR REPO, was Re: [PATCH 2/3] Only repack active packs by skipping over kept packs.Nicolas Pitre, Oct 30, 2006
  3. Shawn PearceOct 30, 2006
  4. Shawn PearceOct 30, 2006
  5. Jan HarkesOct 30, 2006
  6. Jan HarkesOct 30, 2006
  7. Shawn PearceOct 30, 2006
  8. Junio C HamanoOct 30, 2006
  9. Junio C HamanoOct 30, 2006
  10. Jan HarkesOct 30, 2006
  11. Junio C HamanoOct 30, 2006
  12. Continue traversal when rev-list --unpacked finds a packed commit.Jan Harkes, Oct 31, 2006
  13. Junio C HamanoOct 31, 2006
  14. Jan HarkesOct 31, 2006
  15. Junio C HamanoOct 30, 2006
  16. Shawn PearceOct 30, 2006
  17. Junio C HamanoOct 30, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.