Fix silent git am failure on CRLF repositories in safe_outputs patch application#18029
Fix silent git am failure on CRLF repositories in safe_outputs patch application#18029
Conversation
|
@copilot update smoke-pr agentic workflow to create a file with mixed newline endings and add it to the repo |
…ion steps Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
📰 BREAKING: Smoke Copilot is now investigating this pull request. Sources say the story is developing... |
|
🎬 THE END — Smoke Claude MISSION: ACCOMPLISHED! The hero saves the day! ✨ |
|
✨ The prophecy is fulfilled... Smoke Codex has completed its mystical journey. The stars align. 🌟 |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Updated
|
|
Commit pushed:
|
|
Smoke test results for PR #18029
|
Smoke Test Results - Run §22334817339
Overall: PASS ✅ PR by
|
There was a problem hiding this comment.
This PR adds git config --global am.keepcr true consistently across all compiled lock files, preserving carriage returns when applying patches. Good cross-platform defensive fix. Source markdown files should also be updated to avoid regression on recompile.
📰 BREAKING: Report filed by Smoke Copilot
| run: | | ||
| git config --global user.email "github-actions[bot]@users.noreply.github.com" | ||
| git config --global user.name "github-actions[bot]" | ||
| git config --global am.keepcr true |
There was a problem hiding this comment.
Consistent application of am.keepcr true across all lock files ensures uniform behavior. Since these are compiled from .md sources, this change should also be reflected in the source markdown to avoid regression when recompiling.
|
📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤 |
There was a problem hiding this comment.
Pull request overview
This pull request fixes a critical bug where git am silently fails when applying patches in repositories with CRLF line endings. The issue occurs because git-mailsplit strips \r during patch parsing, creating an LF diff that cannot match CRLF working tree files. The fix adds git config --global am.keepcr true to preserve carriage returns during patch application.
Changes:
- Added
am.keepcrconfiguration to all git setup steps in the workflow compiler - Updated tests to verify the new configuration is present
- Enhanced smoke-multi-pr workflow to test CRLF line ending handling
- Regenerated all 158 workflow lock files to reflect the new configuration
Reviewed changes
Copilot reviewed 167 out of 167 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/workflow/git_configuration_steps.go | Added am.keepcr true configuration to standard git setup |
| pkg/workflow/compiler_safe_outputs_steps.go | Added am.keepcr true configuration to safe outputs git setup |
| pkg/workflow/git_config_test.go | Updated test assertions for new configuration line (11→12 lines) |
| .github/workflows/smoke-multi-pr.md | Added CRLF regression test with printf tool and verification |
| .changeset/patch-preserve-crlf-in-safe-outputs.md | Added changeset documenting the patch fix |
| .github/workflows/*.lock.yml (158 files) | Regenerated lock files with new git configuration |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
💥 Automated smoke test review - all systems nominal!
💥 [THE END] — Illustrated by Smoke Claude
Repositories with CRLF line endings (e.g.,
.gitattributes: * -crlf) causegit amto silently fail when applyinggit format-patchoutput —git-mailsplitstrips\rduring parsing, producing an LF diff that can't match the CRLF working tree. The workflow run appears green but no PR is created.Changes
pkg/workflow/git_configuration_steps.goandcompiler_safe_outputs_steps.go: Addgit config --global am.keepcr trueto the "Configure Git credentials" step, preserving\rin patch content duringgit amapplication. Safe for LF-only repos — no behavioral change when\ris absent.git_config_test.go: Updated step-count assertion (11→12) and added assertion for the newam.keepcrline.smoke-multi-pr.md: Updated PR 2 to create a file with CRLF line endings (printf "...\r\n...") as a regression test for this fix. Addedprintf *to the allowed bash tools. The agent verifies CRLF endings viacat -Abefore submitting the PR.The fix mirrors the workaround described in the issue: setting
am.keepcr=trueglobally before any patch application step.Original prompt
This section details on the original issue you should resolve
<issue_title>Code Simplification agent silently fails to create PRs when the repo stores line endings as CRLF</issue_title>
<issue_description>The agentic-workflows agent was able to diagnose why no PR was generated despite the workflow run being green and supplied a workaround. Here is its summary:
Summary
When a repository uses CRLF line endings (e.g., via
* -crlfin.gitattributes), thesafe_outputshandler'sgit amcall silently fails toapply patches generated by
git format-patch. The agent successfully identifies changes and callssafeoutputs-create_pull_request, but no PR orissue is ever created. The only evidence of failure is in the job logs.
Root Cause
git format-patchcorrectly preserves CRLF in diff content lines (context and change lines). However,git amusesgit-mailsplitto parse themailbox-format patch, which strips
\rfrom all lines during parsing. This produces a diff with LF line endings that cannot match the CRLF contentin the working tree.
The failure cascade:
am.threeWay=true): The LF-stripped diff can't apply to the pre-image blob either (which also has CRLFcontent), so git can't construct the
theirsside of the mergegit amexits with code 128, handler reportsFailed to apply patchReproduction
Any repository with these characteristics will hit this bug:
.gitattributescontains* -crlfor* -text(disabling line ending normalization)create_pull_requestsafe outputError Output