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

Re: fetching packs and storing them as packs

From
Shawn Pearce <spearce@spearce.org>
Date
Oct 28, 2006, 08:40 UTC
Message-ID
<20061028084001.GC14607@spearce.org>
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
Previous: Shawn PearceNext: Junio C Hamano
Message 10 of 51 in “fetching packs and storing them as packs”
  1. Nicolas PitreOct 26, 2006
  2. Eran TromerOct 26, 2006
  3. Linus TorvaldsOct 27, 2006
  4. Junio C HamanoOct 27, 2006
  5. Shawn PearceOct 28, 2006
  6. Junio C HamanoOct 28, 2006
  7. Linus TorvaldsOct 28, 2006
  8. Junio C HamanoOct 28, 2006
  9. Shawn PearceOct 28, 2006
  10. Shawn PearceOct 28, 2006
  11. Junio C HamanoOct 28, 2006
  12. Shawn PearceOct 29, 2006
  13. Junio C HamanoOct 29, 2006
  14. Shawn PearceOct 29, 2006
  15. Junio C HamanoOct 29, 2006
  16. Shawn PearceOct 29, 2006
  17. Linus TorvaldsOct 28, 2006
  18. Junio C HamanoOct 28, 2006
  19. Eran TromerOct 28, 2006
  20. Shawn PearceOct 29, 2006
  21. Jakub NarebskiOct 29, 2006
  22. Shawn PearceOct 29, 2006
  23. send-pack --keep: do not explode into loose objects on the receiving end.Junio C Hamano, Oct 29, 2006
  24. Shawn PearceOct 29, 2006
  25. Junio C HamanoOct 29, 2006
  26. Nicolas PitreOct 30, 2006
  27. Eran TromerOct 26, 2006
  28. Nicolas PitreOct 27, 2006
  29. Shawn PearceOct 27, 2006
  30. SeanOct 27, 2006
  31. Junio C HamanoOct 27, 2006
  32. Nicolas PitreOct 27, 2006
  33. Nicolas PitreOct 27, 2006
  34. Eran TromerOct 27, 2006
  35. Shawn PearceOct 27, 2006
  36. SeanOct 27, 2006
  37. Jakub NarebskiOct 27, 2006
  38. SeanOct 27, 2006
  39. Eran TromerOct 27, 2006
  40. Shawn PearceOct 27, 2006
  41. Alex RiesenOct 27, 2006
  42. Shawn PearceOct 27, 2006
  43. Alex RiesenOct 27, 2006
  44. Shawn PearceOct 27, 2006
  45. Nicolas PitreOct 27, 2006
  46. Petr BaudisOct 27, 2006
  47. J. Bruce FieldsOct 27, 2006
  48. Petr BaudisOct 27, 2006
  49. J. Bruce FieldsOct 27, 2006
  50. J. Bruce FieldsOct 27, 2006
  51. Junio C HamanoOct 27, 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.