chore(justfile): repack multi-pack source clones in _load-repo

Single-pack card prep is now enforced, not remembered: each pack's
whole .idx (plus any midx) is mmap'd outside the device's window
budget, and a multi-pack marking walk lost the HTTP keep-alive (run 8:
31s vs 3.5s repacked). Skipped when the clone is already one pack.
This commit is contained in:
Julien Calixte
2026-07-13 22:07:26 +02:00
parent 8d5bd1903d
commit 5d623151a8

View File

@@ -206,8 +206,10 @@ init repo_src sd_volume="":
just _eject "$vol"
# (Re)copy just the notes repo to /sd/repo: fast-forward the source clone from
# its remote first, then rsync it across (full clone, gitignored paths excluded)
# and eject — e.g. to refresh the card after the device pushed new notes.
# its remote first, repack it to a single pack if it has grown several (the
# device's push needs the one-pack layout — see _load-repo), then rsync it
# across (full clone, gitignored paths excluded) and eject — e.g. to refresh
# the card after the device pushed new notes.
# Refuses if the card's .typoena-dirty journal lists unpublished device edits
# (:sync from the device first, or TW_DISCARD_UNPUBLISHED=1 to back up+discard).
# --force wipes the card's repo/ + dirty journal first for a from-scratch copy
@@ -372,6 +374,21 @@ _load-repo repo_src vol wipe="":
;;
esac
# Single-pack card prep (kaizen: real-repo-sync). Each pack's whole .idx —
# plus any multi-pack-index — is mmap'd OUTSIDE libgit2's window budget on
# the device, and a multi-pack layout scatters the push's boundary-marking
# walk across packs: run 8 (2026-07-13) spent 31 s marking and lost the
# HTTP keep-alive; the same repo repacked to one pack marked in 3.5 s.
# Repack the SOURCE clone (the card copy just mirrors it) only when the
# layout needs it; best-effort like the pull — a failure warns, because a
# multi-pack card usually still syncs, just slower and riskier.
packs=$(find "$src/.git/objects/pack" -name '*.pack' 2>/dev/null | wc -l | tr -d ' ')
if [ "$packs" -gt 1 ] || [ -e "$src/.git/objects/pack/multi-pack-index" ]; then
echo "source clone has $packs packs — repacking to one for the device (git repack -ad)"
git -C "$src" repack -ad \
|| echo "warning: repack failed — card will carry $packs packs; on-device push may hit the keep-alive race" >&2
fi
dest="{{vol}}/{{sd_repo_dir}}"
# --force: delete the card's repo/ outright so rsync copies from scratch —
# unlike the mirror, this also clears paths the exclude list protects from