Skip to content

Conversation

gerhardol
Copy link
Member

Proposed changes

Read() from a stream could obtain fewer characters than requested, the number of chars read was never checked.

This is a warning with .net9 and a potential issue in current master.
With this change all bytes reported to be in the stream are read, which should be the case anyway.

ReadExactly () was added in .net7. (I considered using that when optimizing the read of revisions for 4.x (that was for .net6, just testing an update.) If Git reported number of bytes for a commit the handling was slower than the current handling that searches for \0 in the stream).

Alternatives to this change:

  • Suppress the warning in .net9
  • Assign Read() to _ to ack that the value is not used (there will likely be an exception below instead)
  • Return with error if no of bytes are not read.

Test methodology

code review - cannot provoke the error

Merge strategy

I agree that the maintainer squash merge this PR (if the commit message is clear).


✒️ I contribute this code under The Developer Certificate of Origin.

Read() from a stream could obtain fewer characters than requested,
the number of chars read was never checked.
Copy link
Member

@mstv mstv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks sensible, have not run

@gerhardol gerhardol force-pushed the feature/readexactly-from-stream branch from 782b730 to 3956e03 Compare November 24, 2024 17:33
@gerhardol gerhardol mentioned this pull request Nov 24, 2024
@gerhardol gerhardol merged commit 0de964e into gitextensions:master Dec 2, 2024
5 checks passed
@gerhardol gerhardol deleted the feature/readexactly-from-stream branch December 2, 2024 21:22
@mstv mstv added this to the v5.2 milestone Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants