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

[RFC/PATCH] git-repack: shortcut in case of just one pack, and no loose objects

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Feb 25, 2007, 00:49 UTC
Message-ID
<Pine.LNX.4.63.0702250144530.22628@wbgn013.biozentrum.uni-wuerzburg.de>

When there is at most one pack, and there are no loose objects, the result should be one pack _and_ reuse of deltas is allowed, there is no need to repack, really.

The code does not check for *.keep files; they are either sign of an ongoing repack, or of packs which do not matter for repacking purposes.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
	I _think_ this is correct, but I might have missed something 
	obvious...
 git-repack.sh |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/git-repack.sh b/git-repack.sh
index ddfa8b4..15094b3 100755
--- a/git-repack.sh
+++ b/git-repack.sh
@@ -25,6 +25,16 @@ do
 	shift
 done
 
+if test "z$all_into_one" = zt -a "z$no_reuse_delta" = z; then
+	# check if no loose objects are around, and only up to one pack
+	objdirs="$(ls "$GIT_DIR"/objects/?? 2>/dev/null)"
+	packs="$(cd "$GIT_DIR/objects/pack/"; ls *.pack 2>/dev/null)"
+	case "$objdirs,$packs" in
+	*.pack*.pack*) ;;
+	,*) echo "No need to repack" >&2; exit 0
+	esac
+fi
+
 # Later we will default repack.UseDeltaBaseOffset to true
 default_dbo=false
 
-- 
1.5.0.1.2390.g7757
Message 1 of 1 in “git-repack: shortcut in case of just one pack, and no loose objects”
  1. git-repack: shortcut in case of just one pack, and no loose objectsJohannes Schindelin, Feb 25, 2007

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.