Skip to content

fix: allow merge-base with an absent objects/info directory - #2979

Merged
Sebastian Thiel (Byron) merged 1 commit into
mainfrom
absent-objects-info-dir-fix
Sep 8, 2026
Merged

fix: allow merge-base with an absent objects/info directory#2979
Sebastian Thiel (Byron) merged 1 commit into
mainfrom
absent-objects-info-dir-fix

Conversation

@Byron

@Byron Sebastian Thiel (Byron) commented Sep 8, 2026

Copy link
Copy Markdown
Member

Tasks

This section is for Byron only. Models continuing this PR must not add, remove, check, uncheck, rename, or reorder checkboxes here.

  • refackiew

Everything below this line was generated by Codex GPT-6.

Created by Codex on behalf of Byron. Byron will review before this is ready to merge.

Fixes #2978.

Repository::merge_base() now succeeds when the optional .git/objects/info directory is absent. The shared gix-commitgraph loader reads path metadata once and preserves its filesystem error, allowing the existing optional-cache fallback to recognize NotFound. Other metadata failures retain their underlying cause.

Regression tests cover the missing-path error source, empty and absent objects/info directories, and merge-base lookup for both identical commits and a commit with its parent.

Validation

  • Both new regressions failed before the fix and pass afterward. The repository regression also passes with --no-default-features --features sha1,revision.
  • cargo nextest run --locked -p gix -p gix-commitgraph --no-fail-fast, with GIX_TEST_IGNORE_ARCHIVES=1 and separate SHA-1/SHA-256 fixture runs: 457 tests passed in each run.
  • cargo clippy --locked -p gix -p gix-commitgraph --all-targets -- -D warnings -A unknown-lints --no-deps
  • cargo fmt --all -- --check
  • One post-commit Codex review of c9508418eb completed with no findings.

Git 2.50.1 (Apple Git-155) returns the expected merge bases for HEAD HEAD and HEAD HEAD^ with either an empty or absent objects/info. Git's commit-graph.c at 1630431f326e15fcde608827b5ff38422528eb59 likewise falls back when no commit-graph can be opened.

)

<!-- agent -->
An absent `.git/objects/info` directory made `Graph::at()` return an
error without its filesystem cause. The optional-cache fallback in
`Repository::commit_graph_if_enabled()` could not recognize `NotFound`,
so operations such as `merge_base(HEAD, HEAD)` failed despite having all
required commit objects.

Inspect the path with one fallible metadata read and preserve its I/O
error in the chain. Missing paths now reach the existing fallback, while
other metadata failures remain distinguishable. Cover the error source
and merge-base behavior with an empty and then absent `objects/info`.
Both regression tests failed before the fix.

Git reference: `commit-graph.c` at `1630431f326e15fcde608827b5ff38422528eb59`
uses `open_commit_graph()`, `load_commit_graph_one()`, and
`prepare_commit_graph()` to fall back when no graph can be opened.
With Git 2.50.1 (Apple Git-155), `git -c core.commitGraph=true merge-base`
returns the expected commits for `HEAD HEAD` and `HEAD HEAD^` with either
an empty or an absent `objects/info` directory.

Assisted-by: GPT 6.0
Co-authored-by: GPT 6.0 <codex@openai.com>
@Byron
Sebastian Thiel (Byron) marked this pull request as ready for review September 8, 2026 10:20
@Byron
Sebastian Thiel (Byron) merged commit dfc8e8c into main Sep 8, 2026
32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

commit-graph: merge_base() fails when the optional .git/objects/info directory is absent

1 participant