Repository navigation
fix: write a file truncated to empty instead of deleting it - #94
Merged
2 commits merged intoSep 27, 2026
Merged
2 commits merged into
2 commits merged into
Conversation
unidiff's is_removed_file is true for any single hunk whose target length is 0, which also matches a file emptied on the dev branch. The sub-PR then deleted the file, its tree differed from dev, and merging it conflicted (modify/delete). Treat only a /dev/null target as a deletion.
|
Warning Review limit reachedNext included review available in 51 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015rnEEjXWDBdePRhKMmZr1w
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.
Problem
materialize_group_filesused unidiff'sis_removed_fileto decide whether to delete a path. That property is a heuristic: it is also true for any single hunk whose target length is 0 — i.e. a file thatdevtruncated to empty (@@ -1,20 +0,0 @@, target stillb/a.txt). The sub-PR therefore deleted the file: its tree differed fromdev(a.txt | 0) and merging the sub-PR back conflicted (modify/delete). Found by the end-to-end hunt.Fix
Treat a path as deleted only when
patch_file.target_file == "/dev/null"(the first clause of unidiff's own check). Verified in a real repo with a file emptied, a file deleted, an empty file filled, and an ordinary edit: the sub-PRgit ls-tree -rnow equalsdev; on base the emptied file is missing.Tests
Emptied file materialises as
""(fails on base); real/dev/nulldeletion still yieldsNone.Local review: 5/5. 452 tests pass, ruff clean. Stacked on #68 (same function). Follow-up: #90's
target_file_modesuses the same heuristic and will get the same one-line change.