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 <redacted>
---
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