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

Error when deleting a branch or a tag #1064

Open
luckjay opened this issue Apr 1, 2024 · 1 comment
Open

Error when deleting a branch or a tag #1064

luckjay opened this issue Apr 1, 2024 · 1 comment

Comments

@luckjay
Copy link

luckjay commented Apr 1, 2024

Implemented a git server with go-git, everything goes well but deleting. It always returns the error empty packfile from rpSession.ReceivePack().

The server-side pseudo-code is following:

req := packp.NewReferenceUpdateRequest()
_ = req.Decode(r.Body)

session, _ := server.NewReceivePackSession(nil, nil) // transport is ignored here
defer session.Close()

status, err := session.ReceivePack(ctx, req) // <- returns error here
_ = status.Encode(w)

I have looked into this issue and the reason is:

  1. It sets req.Packfile = r.Body when decoding the r.Body
  2. In session.ReceivePack() function, it tries to write Packfile but fails to read HEAD, as shown below:
// plumbing/transport/server/server.go
if req.Packfile != nil {
    r := ioutil.NewContextReadCloser(ctx, req.Packfile)
    if err := s.writePackfile(r); err != nil {
        s.unpackErr = err
        s.firstErr = err
        return s.reportStatus(), err
    }
}
@luckjay
Copy link
Author

luckjay commented Apr 1, 2024

There should be no packfile in a deleting request.

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

No branches or pull requests

1 participant