Skip to content

fix: support empty pushes #1249

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

iainjreid
Copy link

@iainjreid iainjreid commented Dec 16, 2024

This PR aims to fix #1014 by returning a new ErrFlushPacketRecieved error when an empty recieve-pack request is sent by an up-to-date git client. This error can then be gracefully handled in upstream code as required.

I've also included a fix to the reader closing errors reported in #234, but this might be over eager, because the original code appears to have been deliberately structured to only use the io.NopCloser utility in a specific case?

I can split up the commit into the respective fixes with the ticket numbers if required. Looking forward to any and all feedback.

Copy link
Member

@pjbgf pjbgf left a comment

Choose a reason for hiding this comment

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

Added some comments. For the empty push change can you please add some tests to confirm the new behaviour?

Comment on lines +165 to +167
if bytes.Equal(b, pktline.Flush) {
return ErrFlushPacketRecieved
}
Copy link
Member

Choose a reason for hiding this comment

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

This would also represent an empty update-request message, and due to that I am thinking we are better off reusing the existing ErrEmpty.

}

d := &updReqDecoder{r: rc, s: pktline.NewScanner(r)}
d := &updReqDecoder{r: io.NopCloser(r), s: pktline.NewScanner(r)}
Copy link
Member

Choose a reason for hiding this comment

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

This is trickier, as in the existing behaviour the callee is responsible for closing the reader r, with this change this swifts to the caller. For breaking changes such as this, the commit/PR would have to target v6-exp instead.

Copy link

Choose a reason for hiding this comment

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

I think this can be revert, right? So the fix for up-to-date git client could be fixed.

@scabala
Copy link

scabala commented Jan 3, 2025

As for test: simple operation of git pull && git pull is able to trigger this bug. Dunno how it could be implemented in tests but at least it's a starting point

@github-actions github-actions bot added the stale Issues/PRs that are marked for closure due to inactivity label Jul 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Issues/PRs that are marked for closure due to inactivity
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot handle empty ReferenceUpdateRequest
3 participants