Skip to content

Use nonempty where possible#2433

Merged
Byron merged 5 commits intomainfrom
codex/nonempty-rewrite
Feb 15, 2026
Merged

Use nonempty where possible#2433
Byron merged 5 commits intomainfrom
codex/nonempty-rewrite

Conversation

@Byron
Copy link
Member

@Byron Byron commented Feb 15, 2026

Tasks

  • review breaking change declaration
  • review line by line

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR replaces various Vec<T>/slice usages that are expected to be non-empty with nonempty::NonEmpty<T> to encode invariants in types across gix-* crates, and updates dependent code/tests accordingly.

Changes:

  • Introduce nonempty::NonEmpty in shallow-boundary, merge-base, merge outcomes, commit-graph, and select internal iterators.
  • Adjust algorithms and call sites to use first()/tail() and NonEmpty::from_vec() patterns.
  • Add nonempty dependencies (and serde feature wiring where needed) and update tests to compare against Vec as needed.

Reviewed changes

Copilot reviewed 31 out of 32 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
gix/tests/gix/repository/shallow.rs Update shallow-commit assertions to work with NonEmpty.
gix/tests/gix/remote/fetch.rs Update shallow-commit assertions to work with NonEmpty.
gix/tests/gix/clone.rs Update shallow-commit assertions to work with NonEmpty.
gix/src/shallow.rs Change shallow commit snapshot storage from Vec to NonEmpty.
gix/src/revision/walk.rs Adjust shallow-boundary membership check for NonEmpty storage layout.
gix/src/repository/revision.rs Update merge-base selection to use NonEmpty::first().
gix/src/merge.rs Change merge outcome merge_bases to Option<NonEmpty<_>>.
gix/Cargo.toml Add nonempty dependency.
gix-shallow/src/lib.rs Change shallow read/write APIs to return/take Option<NonEmpty<_>>.
gix-shallow/Cargo.toml Add nonempty dependency and serde feature wiring.
gix-revision/tests/revision/merge_base/mod.rs Adapt tests to compare Option<NonEmpty<_>> via Vec::from.
gix-revision/src/merge_base/mod.rs Update octopus merge-base logic to use NonEmpty::first().
gix-revision/src/merge_base/function.rs Change merge-base return type to Option<NonEmpty<_>>.
gix-revision/Cargo.toml Add nonempty dependency.
gix-protocol/src/fetch/function.rs Plumb shallow commits as Option<NonEmpty<_>> through fetch argument building.
gix-protocol/Cargo.toml Add nonempty dependency.
gix-odb/src/store_impls/dynamic/write.rs Minor refactor using first() + improved expect message.
gix-odb/src/store_impls/dynamic/iter.rs Use NonEmpty for loose ODB list in iterator state.
gix-odb/Cargo.toml Add nonempty dependency.
gix-merge/src/tree/utils.rs Use NonEmpty for TreeNodes internal storage.
gix-merge/src/commit/virtual_merge_base.rs Make virtual_merge_bases non-empty by construction.
gix-merge/src/commit/mod.rs Change commit-merge outcome merge_bases to Option<NonEmpty<_>>.
gix-merge/src/commit/function.rs Adapt merge-base handling to NonEmpty APIs and conversions.
gix-merge/Cargo.toml Add nonempty dependency.
gix-commitgraph/src/verify.rs Adjust base-graph checksum iteration for NonEmpty storage.
gix-commitgraph/src/lib.rs Make Graph.files non-empty.
gix-commitgraph/src/init.rs Validate non-empty file list at Graph::new() construction.
gix-commitgraph/src/access.rs Simplify object_hash() using non-empty invariant.
gix-commitgraph/Cargo.toml Add nonempty dependency.
gitoxide-core/src/hours/mod.rs Pass non-empty commit slices via split_first() to avoid empty handling.
gitoxide-core/src/hours/core.rs Change estimate_hours() signature to accept an explicit first commit + rest.
Cargo.lock Record nonempty crate resolution and propagated deps.

@Byron Byron force-pushed the codex/nonempty-rewrite branch from 0df2b93 to 0337144 Compare February 15, 2026 13:23
…ix-merge`

Adapt `gix` accordingly (even though it's nonbreaking).

Co-authored-by: chatgpt-codex-connector[bot] <199175422+chatgpt-codex-connector[bot]@users.noreply.github.com>
@Byron Byron force-pushed the codex/nonempty-rewrite branch from 0337144 to 76d230e Compare February 15, 2026 13:50
@Byron Byron marked this pull request as ready for review February 15, 2026 14:18
@Byron Byron requested a review from Copilot February 15, 2026 14:18
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 25 out of 26 changed files in this pull request and generated 1 comment.

Byron and others added 4 commits February 15, 2026 15:58
…mpty` in `gix-protocol`

Co-authored-by: chatgpt-codex-connector[bot] <199175422+chatgpt-codex-connector[bot]@users.noreply.github.com>
Co-authored-by: chatgpt-codex-connector[bot] <199175422+chatgpt-codex-connector[bot]@users.noreply.github.com>
Co-authored-by: chatgpt-codex-connector[bot] <199175422+chatgpt-codex-connector[bot]@users.noreply.github.com>
@Byron Byron force-pushed the codex/nonempty-rewrite branch from 83fd4b8 to e033441 Compare February 15, 2026 14:59
@Byron Byron enabled auto-merge February 15, 2026 15:00
@Byron Byron merged commit 29040a8 into main Feb 15, 2026
30 checks passed
@Byron Byron deleted the codex/nonempty-rewrite branch February 15, 2026 15:17
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.

1 participant