feat: compare fundamental types with textual representations - #2932
Draft
Sebastian Thiel (Byron) wants to merge 6 commits into
Draft
feat: compare fundamental types with textual representations#2932Sebastian Thiel (Byron) wants to merge 6 commits into
Sebastian Thiel (Byron) wants to merge 6 commits into
Conversation
Allow ObjectId, oid, ChangeId, Prefix, and their display helpers to compare directly and symmetrically with str and String values. Comparisons reuse the existing stack encoders and accept parser-supported uppercase without allocating. Regression coverage first demonstrated the missing PartialEq implementations as compile errors, then covered SHA-1, SHA-256, normal hex, reverse hex, prefixes, invalid text, and both operand orders. Validation: - cargo test -p gix-hash --all-features --test hash - cargo clippy -p gix-hash --all-features --tests -- -D warnings - cargo check -p gix-hash --no-default-features --features sha1 - cargo check -p gix-hash --no-default-features --features sha256 - cargo fmt --all -- --check
Allow owned and borrowed reference-name types, namespaces, and raw, loose, and packed references to compare directly with text and byte strings. Reference comparisons project their stored full name, while same-type equality remains structural.\n\nAdd regression coverage for symmetric owned, borrowed, UTF-8, and non-UTF-8 comparisons.\n\nValidation: cargo test -p gix-ref --test refs equality --all-features; cargo fmt --all -- --check
Keep name-only comparisons directional with references on the left. This preserves direct test-friendly comparisons without allowing two structurally distinct references to compare transitively through the same textual or FullName value.\n\nValidation: cargo test -p gix-ref --test refs equality --all-features; cargo fmt --all -- --check
Compare full object and change IDs only with their canonical lowercase text. Keep Prefix, HexDisplay, and ReverseHexDisplay comparisons directional because their displayed text does not uniquely identify their structural value.\n\nThis prevents non-transitive equality chains through differently-cased strings, truncated displays, and cross-kind prefixes.\n\nValidation: cargo test -p gix-hash --test hash comparisons --all-features; cargo clippy -p gix-hash --all-targets --all-features -- -D warnings; SHA-1 and SHA-256 library checks; cargo fmt --all -- --check
Delegate attached Id textual equality to ObjectId, preserving symmetric canonical comparisons. Let attached references compare directly with text, byte strings, and full names by delegating to their stored plumbing reference.\n\nReference comparisons remain directional because same-name references may have different targets.\n\nValidation: GIX_TEST_IGNORE_ARCHIVES=1 cargo test -p gix --test gix compares_with_; cargo clippy -p gix --test gix -- -D warnings; cargo fmt --all -- --check
Replace test-only parsing, formatting, and name projections with direct comparisons against natural textual representations. This exercises hash IDs, ref names, plumbing references, and repository-attached IDs and references through the new equality implementations. Validated with the gix-ref and gix integration suites, focused hash migration tests, cargo fmt, and diff checks.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Tasks
This section is for Byron only. Models continuing this PR must not add, remove, check, uncheck, rename, or reorder checkboxes here.
Everything below this line was generated by
Codex GPT-5.Created by Codex on behalf of Byron. Byron will review before this is ready to merge.
Reported issue
Initial report
Follow-up
Summary
gix::Idandgix::Referencecomparisons.PartialEqsymmetry and transitivity by limiting prefix, truncated, and reference comparisons to law-preserving directions.Commits
77f28a89d9feat(gix-hash): compare hash types with text24b200e878feat(gix-ref): compare names and references with natural counterpartsa3c1c8d355Preserve PartialEq transitivity for reference comparisons60aa0c806bPreserve PartialEq laws for hash text comparisons5e83f39167feat(gix): compare attached IDs and references with textd1c3e249d7Use fundamental-type comparisons throughout testsValidation
gix-ref,gix, hash-crate, andgix-objecttag-target tests.cargo deny --workspace --all-features check bans licenses sources.env GIX_TEST_IGNORE_ARCHIVES=1 just ci-test.just doc-tests.env GIX_TEST_CREATE_ARCHIVES_EVEN_ON_CI=1 cargo nextest run --workspace --no-fail-fast --exclude gix-error(3,710 passed, one existing leaky annotation, five configured skips).just ci-journey-tests.