fix(strategy): keep non-ASCII staged paths literal so commit linking matches - #2399
Open
wangzhengzhuo05 wants to merge 1 commit into
Open
fix(strategy): keep non-ASCII staged paths literal so commit linking matches#2399wangzhengzhuo05 wants to merge 1 commit into
wangzhengzhuo05 wants to merge 1 commit into
Conversation
…matches git quotes and C-escapes unusual paths in `--name-only` output by default (core.quotePath=true), so getStagedFiles returned `café.go` as the display string `"caf\303\251.go"`. The exact comparison against the literal entry in SessionState.FilesTouched then failed, the session was treated as having no overlap with the commit, and the Entire-Checkpoint trailer was omitted. Parse the `-z` NUL-delimited output instead, as priorAICommitFiles in this package already does, and drop the CRLF normalization that only existed to unwrap the newline framing. Fixes entireio#2398.
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No unresolved issues remain, and regression coverage validates the fix.
Pull request overview
Fixes commit-to-session linking for non-ASCII staged paths by preserving literal Git filenames.
Changes:
- Parses staged paths using Git’s NUL-delimited output.
- Adds regression coverage for non-ASCII filenames.
File summaries
| File | Description |
|---|---|
cmd/entire/cli/strategy/staged_files_quoting_test.go |
Verifies literal non-ASCII and ASCII paths. |
cmd/entire/cli/strategy/manual_commit_hooks.go |
Uses NUL-delimited staged-path parsing. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
What
getStagedFilesincmd/entire/cli/strategy/manual_commit_hooks.gonow parsesgit diff --cached --name-only -zand splits the output on NUL, so staged paths are returned literally instead of as git's quoted/C-escaped display form.Why
With git's default
core.quotePath=true, the newline-delimited--name-onlyoutput quotes and C-escapes unusual pathnames —café.gocomes back as the display string"caf\303\251.go". That string was exact-compared against the literal path stored inSessionState.FilesTouched, so a session that touched only a non-ASCII file was classified as contributing no content to the commit: the commit was still created, but it received noEntire-Checkpointtrailer and its provenance (entire explainattribution) was incomplete. Reported with a focused control/canary reproduction in #2398: an ASCII control file got its trailer, an otherwise equivalent UTF-8 canary did not.How
-zto the git invocation and iterate the NUL-delimited fields, keepingfilepath.ToSlashon every entry.\r\n→\nnormalization: it only existed to unwrap the newline framing, and-zemits NUL-terminated, unquoted names.(non-nil empty slice, nil)when nothing is staged,(nil, err)only when git itself fails, and the same error wrapping.priorAICommitFilesincmd/entire/cli/strategy/telemetry_signals.gouses-zfor the same reason, so paths match theirFilesTouchedform.Tests
New
cmd/entire/cli/strategy/staged_files_quoting_test.go,TestGetStagedFiles_PreservesNonASCIIPaths: setscore.quotePath trueexplicitly, stages a literalcafé.goplus an ASCIIcontrol.go, and asserts both come back literal and that no returned entry is git-quoted or C-escaped.Mutation check
Reverting only the fix (removing
-z, i.e. the previous behaviour) makes the new test fail with exactly the string from the report — the assertion output is the single staged entry"\"caf\\303\\251.go\"\ncontrol.go\n", which contains neither literal filename. Restoring-zreturns the package suite to green, so the test guards the defect rather than the implementation.Fixes #2398.