fix(diff-parser): handle empty files and mode-only changes in git-style diffs#215
Merged
martintrojer merged 1 commit intoagavra:mainfrom Mar 19, 2026
Merged
Conversation
…le diffs When jj (or git patches) produce diffs for empty new files or mode-only changes, the unified diff output contains no ---/+++ lines. The diff parser relied exclusively on those lines to extract file paths, leaving both old_path and new_path as None. This caused a panic in DiffFile::display_path() which expects at least one path to be present. Add parse_diff_git_header() to extract paths from the "diff --git a/X b/X" header line as a fallback when parse_file_header() doesn't find ---/+++ or rename/copy metadata. Reproducer: run tuicr in a jj repo that contains an empty newly-added file (e.g. an empty config.toml).
907b8e5 to
c822a7e
Compare
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.
When jj (or git patches) produce diffs for empty new files or mode-only changes, the unified diff output contains no ---/+++ lines. The diff parser relied exclusively on those lines to extract file paths, leaving both old_path and new_path as None. This caused a panic in DiffFile::display_path() which expects at least one path to be present.
Add parse_diff_git_header() to extract paths from the "diff --git a/X b/X" header line as a fallback when parse_file_header() doesn't find ---/+++ or rename/copy metadata.
Reproducer: run tuicr in a jj repo that contains an empty newly-added file (e.g. an empty config.toml).