Replace GNU patch with git apply for atomic diff application#2274
Merged
hiroshinishio merged 1 commit intomainfrom Feb 19, 2026
Merged
Replace GNU patch with git apply for atomic diff application#2274hiroshinishio merged 1 commit intomainfrom
hiroshinishio merged 1 commit intomainfrom
Conversation
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.
Summary
apply_patch.pyfrom GNUpatchtogit apply-git applyis atomic (all-or-nothing), doesn't create.rejfiles, and is stricter about context matching (no--fuzz)PatchResultdataclass to replace ambiguous(str, str)tuple returnswrite_local_fileutility to pair with existingread_local_filedelete_file_by_shatodelete_remote_fileand separated local/remote deletion concerns -delete_remote_fileis now a pure GitHub API call,delete_filehandles both remote and localapply_diff_to_filenow handles deletion diffs end-to-end instead of rejecting thempatchfrom Dockerfile since it's no longer neededTest plan
test_apply_patch.pytests and 4 newtest_write_local_file.pytestsSocial Media Post (GitAuto)
GNU patch has a --fuzz option that silently applies diffs to the wrong location. We were using it. git apply is stricter - it either applies cleanly or fails entirely. No .rej files, no partial edits, no silent misapplication. Switched our diff engine to git apply for more predictable code changes.
Social Media Post (Wes)
Replaced our diff engine from GNU patch to git apply today. patch --fuzz=3 could silently match lines in the wrong place and partially apply changes. git apply is atomic - clean apply or full failure. Also cleaned up a bunch of file deletion logic that had responsibilities split across three functions. Sometimes the best refactor is just making names match what the code actually does.