Skip to content

GitIdentifiers: order tree entries by UTF-8 bytes as Git does - #443

Open
lenamonj wants to merge 1 commit into
apache:masterfrom
lenamonj:git-identifiers-utf8-order
Open

GitIdentifiers: order tree entries by UTF-8 bytes as Git does#443
lenamonj wants to merge 1 commit into
apache:masterfrom
lenamonj:git-identifiers-utf8-order

Conversation

@lenamonj

@lenamonj lenamonj commented Sep 6, 2026

Copy link
Copy Markdown

DirectoryEntry.compareTo used String.compareTo, which orders UTF-16 code units. Git orders raw UTF-8 bytes; outside the Basic Multilingual Plane the two differ, so treeId disagreed with git write-tree for 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-tree produces 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.

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
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