GitIdentifiers: order tree entries by UTF-8 bytes as Git does - #443
Open
lenamonj wants to merge 1 commit into
Open
GitIdentifiers: order tree entries by UTF-8 bytes as Git does#443lenamonj wants to merge 1 commit into
lenamonj wants to merge 1 commit into
Conversation
DirectoryEntry.compareTo used String.compareTo, which orders UTF-16 code units; Git orders the raw UTF-8 bytes, and the two disagree for names outside the Basic Multilingual Plane, so treeId returned an id git write-tree does not. The sort key is now the name's UTF-8 bytes, compared unsigned. A test pins the id git write-tree produces for a two-entry tree and fails on the old comparator. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BzeiNYQSD3LEBxsHTKRxQt
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.
DirectoryEntry.compareTousedString.compareTo, which orders UTF-16 code units. Git orders raw UTF-8 bytes; outside the Basic Multilingual Plane the two differ, sotreeIddisagreed withgit write-treefor a tree holding U+FF21 and U+1F600.The sort key is now the name's UTF-8 bytes, compared unsigned. Names below U+D800 keep their order, so the existing constants are unchanged. The new test pins the id
git write-treeproduces and fails on the old comparator.Checklist: guidelines and the ASF generative-tooling guidance read. AI was used: Claude (Anthropic) found the defect and drafted the fix and test in an audit loop I run; I reviewed it, reproduced the id with
git write-tree, and ran the default Maven goal, which passes. changes.xml updated.