{"thread":{"id":"66778","subject":"[BUG] Geometric maintenance prunes commits without updating commit-graph","startedAt":"2026-11-05T06:41:26Z","lastAt":"2026-11-19T12:50:25Z","messageCount":2,"participants":["Christoph Weiss","Patrick Steinhardt"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"557527","messageId":"ba964c70-60ab-4b7a-a0fa-6e028e401a09@wsoptics.de","threadId":"66778","inReplyTo":null,"subject":"[BUG] Geometric maintenance prunes commits without updating commit-graph","fromName":"Christoph Weiss","fromEmail":"weiss@wsoptics.de","sentAt":"2026-11-05T06:41:26Z","receivedAt":"2026-11-05T06:41:26Z","isPatch":false,"sender":{"key":"weiss@wsoptics.de","avatar":null},"body":"Hi,\n\nAfter 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`.\n\nThe following script hopefully reproduces the problem with `geometric`:\n\n\n#!/bin/sh\nset -eu\n\nunset GIT_DIR GIT_COMMON_DIR GIT_WORK_TREE GIT_INDEX_FILE GIT_CONFIG\nunset GIT_OBJECT_DIRECTORY GIT_ALTERNATE_OBJECT_DIRECTORIES GIT_CONFIG_COUNT GIT_CONFIG_PARAMETERS\nexport GIT_CONFIG_NOSYSTEM=1 GIT_CONFIG_GLOBAL=/dev/null\n\nrepro_dir=$(mktemp -d)\nprintf 'Repository: %s/repo.git\\n' \"$repro_dir\"\ngit --version\ngit init --quiet --bare --template= --initial-branch=main \"$repro_dir/repo.git\"\ncd \"$repro_dir/repo.git\"\ngit config user.name Reproducer\ngit config user.email repro@example.invalid\ngit config core.commitGraph true\ngit config gc.writeCommitGraph true\n\n# Use `gc` here and no error occurs.\ngit config maintenance.strategy geometric\n\ntree=$(git mktree </dev/null)\nbase=$(printf 'base\\n' | git commit-tree \"$tree\")\nobsolete=$(printf 'obsolete\\n' | git commit-tree \"$tree\" -p \"$base\")\ngit update-ref refs/heads/main \"$base\"\ngit update-ref refs/heads/obsolete \"$obsolete\"\ngit repack -ad\ngit commit-graph write --reachable --split\ngit update-ref -d refs/heads/obsolete\n\n# Avoid waiting for Git's default two-week pruning grace period.\ntouch -t 200001010000 objects/pack/*\nfirst=$(printf 'first\\n' | git commit-tree \"$tree\" -p \"$base\")\nsecond=$(printf 'second\\n' | git commit-tree \"$tree\" -p \"$first\")\ngit update-ref refs/heads/main \"$second\"\n# Packs with three and two objects force geometric maintenance to consolidate both.\nprintf '%s\\n' \"$first\" \"$second\" | git pack-objects objects/pack/pack >/dev/null\n\nprintf '\\nBefore maintenance:\\n'\ngit fsck --full --no-dangling\n\ngit maintenance run --auto --no-detach\n\nprintf '\\nAfter maintenance:\\n'\ngit fsck --full --no-dangling\n\n\nBest,\nChristoph\n\n"},{"id":"558846","messageId":"av7wkQXxYrzAJInT@pks.im","threadId":"66778","inReplyTo":"ba964c70-60ab-4b7a-a0fa-6e028e401a09@wsoptics.de","subject":"Re: [BUG] Geometric maintenance prunes commits without updating commit-graph","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-11-19T12:50:25Z","receivedAt":"2026-11-19T12:50:25Z","isPatch":false,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Hi,\n\nOn Thu, Nov 05, 2026 at 07:41:26AM +0100, Christoph Weiss wrote:\n> Hi,\n> \n> After updating our internal Forgejo instance from 16 to 17, many of our\n> repositories' health checks started failing.  This appears to be due to the\n> update entailing a switch in Git from 2.52 to 2.54, which in turn changed\n> the default maintenance strategy from `gc` to `geometric`.\n\nthanks for the report, makes sense.\n\nI think the way to fix this is to move generation of commit graphs into\n`odb_optimize()`, which would give us a lot more control over when\nexactly we generate them. And that would allow us to figure out whether\nwe have discarded any objects in the first place, in which case we'd\nrewrite the commit graph.\n\nThat also aligns with my other in-flight patch series that makes commit\ngraphs pluggable in the first place. Once they're an implementation\ndeatil of the object database backend, it's only natural to also write\nthem as part of `odb_optimize()`.\n\nThat means thought that I can only fix this once [1] has landed, as any\nchanges I'd make to fix the reported issue would conflict. But once it\ndid I'll send such a patch series.\n\nThanks!\n\nPatrick\n\n"}]}