Initial code import - #1
Merged
Merged
Conversation
macOS runners use a much longer $TMPDIR than Linux, so the repo root path pushed the error message past Format's line margin before it got sanitized to $CENTRAL_ROOT in expect tests, causing the message to wrap unpredictably (splitting even "Repo" from the quoted path). Wrap the path-bearing sentence in an hbox so it's never auto-wrapped, move "commit or stash them first" into a dedicated hint.
The earlier hbox fix wasn't enough: on macOS CI, the real repo_root path (under a much longer $TMPDIR than Linux) can be wide enough that the whole atomic hbox no longer fits on the line, so Format still breaks - just before "Repo" instead of mid-sentence. No box discipline can make an oversized real path fit. Instead, teach the CLI to print a short, fixed placeholder for repo_root when a CENTRAL_TEST_REPO_ROOT env var is set, and have the test harness set it (to the same "$CENTRAL_ROOT" placeholder it already substitutes post hoc) around the central subprocess it spawns. This keeps the formatted message short and platform-independent before Format ever makes a wrapping decision, so the hbox is no longer needed.
Central_test_harness.redact rewrites every registered revision it finds
in a piece of text by folding replace_all over the progressively
rewritten accumulator, once per registered pattern (full shas and every
abbreviated prefix, longest first). A mock rev is just a 40-hex-char
digest, indistinguishable from a real one, so it can itself contain a
short run that coincidentally matches some other, unrelated commit's
abbreviated real-sha prefix registered later - corrupting an
already-correct mock rev in place once that later pattern is applied.
This is what produced a flaky CI failure: a conflict marker's trailing
revision came out as ">>>>>>> 11855121185612b25613f2e5b473e5231185512b"
instead of the correct
">>>>>>> 1185512b92d612b25613f2e5b473e5231185512b".
Add a deterministic, git-independent regression test that reproduces the
same collision directly against redact/register_rev, as a new page in
the mdexp book, "Deterministic Revisions": it narrates why the test
harness redacts revisions at all (so snapshots stay stable across runs)
and then the substitution-order edge case this test pins down. Wired
into SUMMARY.md and cross-linked from the mock rev already visible in
the Import chapter's conflict example.
This currently fails (red):
-| [%expect {| 1185512b92d612b25613f2e5b473e5231185512b |}]
+| [%expect {| 1185512f452612b25613f2e5b473e5231185512b |}]
confirming the test actually exercises the bug before the next commit
fixes it.
redact rewrote the text once per registered pattern (full shas and every
abbreviated prefix), folding each replace_all pass over the progressively
rewritten accumulator - so a later, shorter pattern could match and
corrupt a mock rev an earlier pass had already substituted in, whenever
that mock rev's hex text coincidentally contained the later pattern.
Fix: scan the original text once, left to right, trying all patterns
(longest first) at each position, instead of re-scanning growing
substituted output once per pattern. Same asymptotic cost, but
already-written output is never re-matched.
Turns the regression test added in the previous commit green:
-| [%expect {| 1185512f452612b25613f2e5b473e5231185512b |}]
+| [%expect {| 1185512b92d612b25613f2e5b473e5231185512b |}]
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.
Initiate the project, go through CI fixes.