Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error with redundant line breaks #1129

Merged
merged 1 commit into from May 5, 2020

Conversation

pfeuffer
Copy link
Member

@pfeuffer pfeuffer commented May 4, 2020

Proposed changes

This fixes an error with a repository, where an added file has \r\r\n
as line breaks. This interesting combination is handled as a single
line break by the diff operation, while Java's Scanner implementation
handles this as two lines (the first one delimited by the first \r,
the second one delimited by \r\n. This led to empty lines inside the
diff, where we only expect lines that contain at least one character
(' ', '+' or '-'), and this in turn led to an index out of bounds
exception.

Now we handle each combination of any kind of new line delimiter
characters as a single delimiter. This should be safe, because, as
mentioned earlier, we always expect at least one character in a line
for a diff output.

Your checklist for this pull request

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • PR is well described
  • Target branch is not master (in most cases develop should bet the target of choice)
  • Code does not conflict with target branch
  • New code is covered with unit tests
  • CHANGELOG.md updated
  • Documentation updated (only necessary for new features or changed behaviour)

Checklist for branch merge request (not required for forks)

This fixes an error with a repository, where an added file has \r\r\n
as line breaks. This interesting combination is handled as a single
line break by the diff operation, while Java's Scanner implementation
handles this as two lines (the first one delimited by the first \r,
the second one delimited by \r\n. This led to empty lines inside the
diff, where we only expect lines that contain at least one character
(' ', '+' or '-'), and this in turn led to an index out of bounds
exception.

Now we handle each combination of any kind of new line delimiter
characters as a single delimiter. This should be safe, because, as
mentioned earlier, we always expect at least one character in a line
for a diff output.
@pfeuffer pfeuffer force-pushed the bugfix/handle_multiple_line_breaks_in_diff branch from 17b67f3 to 52a09a9 Compare May 4, 2020 13:23
@sdorra sdorra added the bug Something isn't working label May 4, 2020
@sdorra sdorra assigned sdorra and unassigned sdorra May 4, 2020
@sdorra sdorra merged commit 082e68b into develop May 5, 2020
@sdorra sdorra deleted the bugfix/handle_multiple_line_breaks_in_diff branch May 5, 2020 05:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants