stacked_table: skip non-segment file names in heads/ - #10062
Open
petejm wants to merge 1 commit into
Open
Conversation
Foreign files like AppleDouble `._*` (which appear when a macOS-created archive is extracted on another system) or `.DS_Store` landing in store/extra/heads made every metadata read fail until removed by hand; a non-UTF8 name panicked outright. gc() already tolerates foreign names in the table directory, and SimpleOpHeadsStore::get_op_heads tolerates non-hex UTF-8 names in its own heads directory (though it still errors on non-UTF8 ones). Apply the same idea to get_head_tables(): ignore any entry whose name isn't exactly SEGMENT_FILE_NAME_LENGTH ASCII hex characters, logging each skip at warn level (visible under --debug/JJ_LOG), and never touch the foreign file itself. If every entry in heads/ turns out to be invalid, return the new TableStoreError::NoValidHeads instead of silently manufacturing a fresh empty table, which would otherwise mask lost head metadata. A genuinely empty heads/ (no entries at all) keeps its existing behavior. Fixes jj-vcs#9775 Assisted-by: Claude:claude-fable-5
petejm
force-pushed
the
stacked-table-skip-foreign-head-files
branch
from
August 26, 2026 01:22
5839942 to
bd270bb
Compare
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.
Fixes #9775.
get_head_tablesloaded every directory entry ofstore/extra/headsas a table segment, so a foreign file (an AppleDouble._*file left bytar,.DS_Store, anything) made every command that reads commit metadata fail until the file was removed by hand, and a non-UTF8 file name panicked. Entries whose names are not exactly 128 ASCII hex characters are now skipped with a warning, combining the two neighboring idioms:TableStore::gcalready filters by segment-name length andSimpleOpHeadsStore::get_op_headsalready validates withhex_util::decode_hex. Foreign files are left in place. Head markers are written only fromhex_util::encode_hexoutput, so no legitimate marker can be affected.If every entry in
heads/turns out to be invalid,get_head_tablesnow returns the newTableStoreError::NoValidHeadsinstead of silently manufacturing a fresh empty table, which would otherwise mask lost head metadata. A genuinely emptyheads/(no entries at all) keeps its existing behavior.Checklist
If applicable:
CHANGELOG.mdhow it works, how it's organized), including any code drafted by an LLM.
an eye towards deleting anything that is irrelevant, clarifying anything
that is confusing, and adding details that are relevant. This includes,
for example, commit descriptions, PR descriptions, and code comments.