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

[BUG] Geometric maintenance prunes commits without updating commit-graph

From
CWChristoph Weiss <weiss@wsoptics.de>
Date
Nov 5, 2026, 06:41 UTC
Message-ID
<ba964c70-60ab-4b7a-a0fa-6e028e401a09@wsoptics.de>
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

Next: Patrick Steinhardt
Message 1 of 2 in “[BUG] Geometric maintenance prunes commits without updating commit-graph”
  1. Christoph WeissNov 5, 2026
  2. Patrick SteinhardtNov 19, 2026

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.