* [BUG] Geometric maintenance prunes commits without updating commit-graph
@ 2026-11-05 6:41 Christoph Weiss
2026-11-19 12:50 ` Patrick Steinhardt
0 siblings, 1 reply; 2+ messages in thread
From: Christoph Weiss @ 2026-11-05 6:41 UTC (permalink / raw)
To: git
Hi,
After updating our internal Forgejo instance from 16 to 17, many of our
repositories' health checks started failing. This appears to be due to
the update entailing a switch in Git from 2.52 to 2.54, which in turn
changed the default maintenance strategy from `gc` to `geometric`.
The following script hopefully reproduces the problem with `geometric`:
#!/bin/sh
set -eu
unset GIT_DIR GIT_COMMON_DIR GIT_WORK_TREE GIT_INDEX_FILE GIT_CONFIG
unset GIT_OBJECT_DIRECTORY GIT_ALTERNATE_OBJECT_DIRECTORIES
GIT_CONFIG_COUNT GIT_CONFIG_PARAMETERS
export GIT_CONFIG_NOSYSTEM=1 GIT_CONFIG_GLOBAL=/dev/null
repro_dir=$(mktemp -d)
printf 'Repository: %s/repo.git\n' "$repro_dir"
git --version
git init --quiet --bare --template= --initial-branch=main
"$repro_dir/repo.git"
cd "$repro_dir/repo.git"
git config user.name Reproducer
git config user.email repro@example.invalid
git config core.commitGraph true
git config gc.writeCommitGraph true
# Use `gc` here and no error occurs.
git config maintenance.strategy geometric
tree=$(git mktree </dev/null)
base=$(printf 'base\n' | git commit-tree "$tree")
obsolete=$(printf 'obsolete\n' | git commit-tree "$tree" -p "$base")
git update-ref refs/heads/main "$base"
git update-ref refs/heads/obsolete "$obsolete"
git repack -ad
git commit-graph write --reachable --split
git update-ref -d refs/heads/obsolete
# Avoid waiting for Git's default two-week pruning grace period.
touch -t 200001010000 objects/pack/*
first=$(printf 'first\n' | git commit-tree "$tree" -p "$base")
second=$(printf 'second\n' | git commit-tree "$tree" -p "$first")
git update-ref refs/heads/main "$second"
# Packs with three and two objects force geometric maintenance to
consolidate both.
printf '%s\n' "$first" "$second" | git pack-objects objects/pack/pack
>/dev/null
printf '\nBefore maintenance:\n'
git fsck --full --no-dangling
git maintenance run --auto --no-detach
printf '\nAfter maintenance:\n'
git fsck --full --no-dangling
Best,
Christoph
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [BUG] Geometric maintenance prunes commits without updating commit-graph
2026-11-05 6:41 [BUG] Geometric maintenance prunes commits without updating commit-graph Christoph Weiss
@ 2026-11-19 12:50 ` Patrick Steinhardt
0 siblings, 0 replies; 2+ messages in thread
From: Patrick Steinhardt @ 2026-11-19 12:50 UTC (permalink / raw)
To: Christoph Weiss; +Cc: git
Hi,
On Thu, Nov 05, 2026 at 07:41:26AM +0100, Christoph Weiss wrote:
> Hi,
>
> After updating our internal Forgejo instance from 16 to 17, many of our
> repositories' health checks started failing. This appears to be due to the
> update entailing a switch in Git from 2.52 to 2.54, which in turn changed
> the default maintenance strategy from `gc` to `geometric`.
thanks for the report, makes sense.
I think the way to fix this is to move generation of commit graphs into
`odb_optimize()`, which would give us a lot more control over when
exactly we generate them. And that would allow us to figure out whether
we have discarded any objects in the first place, in which case we'd
rewrite the commit graph.
That also aligns with my other in-flight patch series that makes commit
graphs pluggable in the first place. Once they're an implementation
deatil of the object database backend, it's only natural to also write
them as part of `odb_optimize()`.
That means thought that I can only fix this once [1] has landed, as any
changes I'd make to fix the reported issue would conflict. But once it
did I'll send such a patch series.
Thanks!
Patrick
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-19 12:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-05 6:41 [BUG] Geometric maintenance prunes commits without updating commit-graph Christoph Weiss
2026-11-19 12:50 ` Patrick Steinhardt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox