fix: stage/discard/unstage hunk #1996
Merged
+14
−1
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.
There is a regression bug regarding staging, discarding, and unstaging hunks. Depending on the data, these actions may be ignored or only partially executed.
The following script generates a repository in the current directory (named after the current directory) with four examples. Save the script as
create-hunk-regression.sh, make it executable withchmod +x create-hunk-regression.sh, and start it with./create-hunk-regression.sh. (Tested on Linux, should also work on Windows.)For the examples to fully work you should configure Git/SourceGit the following way:
core.autocrlftofalse--ignore-cr-at-eolin diffThis regression was introduced in commit 5c9d96, where breaking up the diff into lines was changed from explicitly doing it to using the stream function
ReadLineAsync. Whereas the explicit code handled CR and LF correctly, the stream function handles CR, CR/LF and LF the same way, so that for Windows newlines (CR/LF) the CR will be lost.The fix for this regression is going back to the explicit code and ignoring
ReadLineAsyncfor reading diffs.This should fix at least partially issues #1950 and #1995.