-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
utils.git: Handle output with embedded '\r' (CR) character
In the diff output, be it from `git format-patch`, `git log -p`, or `git diff`, there can be '\r' (CR) characters embedded. The same is true for configuration variables values. Turning on `text` aka. `universal_newlines` translates '\r' into '\n', which might lead to unidiff.UnidiffParseError, as the fragment of the line after '\r' (aka. CR, sometimes shown as ^M) may not start with '+' for the added line, '-' for the removed line, or ' ' for the context line. UnidiffParseError: Hunk diff line expected For cases where we can expect for '\r' characters to be possible in the Git command output, use binary mode with subprocess, and then decode it. However, unidiff and _parse_commit_text() expects '\n' as newline, and wouldn't work correctly with '\r\n' (for example unidiff would mis-detect changed file names, and _parse_commit_text() wouldn't be able to extract authorship info), so there was a need to replace '\r\n' in a few places by '\n'. . Additionally, this commit fixes an intermittent Heisen-BUG, that sometimes happened when running tests, namely unexpected end of patch. When parsing `git log -p` output (in .log_p() method), don't stop processing output if the subprocess finished - there can still be something in the buffer.
- Loading branch information
Showing
5 changed files
with
249 additions
and
19 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# do not perform any end-of-line conversions; | ||
# *.diff files here need to keep LF as end of line, but have embedded CR | ||
*.diff -text |
175 changes: 175 additions & 0 deletions
175
tests/test_dataset/qtile/4424a39ba5d6374cc18b98297f6de8a82c37ab6a.diff
This file contains 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
This file contains 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