Cover v2 fetch body closure on decode errors · Entire

Cover v2 fetch body closure on decode errors

5ca5f37→main

Soph·3mo ago·2 files·+37 added/-0 removed

Sessions

8e6efde358b4View transcript

[?
Can you take a look at the go code (wasm) in /Users/soph/Work/entire/devenv/entire-io-worktree1 based a bit on that I wonder if something like this can be build:Codex·GPT-5.4·1 step](/content/gh/entireio/git-sync/session/019d6d29-8cf7-7fe3-adc9-8c3e4d9d5603#timeline-8e6efde358b4/index.html)

Changes

2

159 unmodified lines

160
161
162
163
164
165
166

159 unmodified lines

- Direct strategy-level error-path tests now verify that relay bootstrap and incremental paths close source pack streams when pushes fail.
- Batched integration coverage now also exercises a failed checkpoint pack push followed by a resume-from-temp-ref retry.
- Lower-level `gitproto.PushPack` rejection paths now also close the provided pack stream instead of leaking it on preflight command errors.
- `gitproto` fetch tests now verify response-body closure symmetry for both v1 and v2 decode-failure paths.
- This still wants a fuller close-audit around lower-level transport interruption paths before it should be considered fully done.

### 6. Protocol v2 tag fetches request `include-tag` without capability gating

Mdocs/rewrite-issue-list.md+1

335 unmodified lines

336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377

335 unmodified lines

}
}

func TestFetchPackV2ClosesBodyOnDecodeError(t *testing.T) {
    ep, err := transport.NewEndpoint("https://example.com/repo.git")
    if err != nil {
        
t.Fatalf("parse endpoint: %v", err)
    }
    body := &trackingReadCloser{ReadCloser: io.NopCloser(bytes.NewBufferString("0000"))}
    conn := NewConn(ep, "source", nil, roundTripperFunc(func(req *http.Request) (*http.Response, error) {
        return &http.Response{
            StatusCode: http.StatusOK,
            Request:    req,
            Body:       body,
        }, nil
    }))

caps := &V2Capabilities{
        Caps: map[string]string{
            "fetch": "",
        },
    }
    desired := map[plumbing.ReferenceName]DesiredRef{
        plumbing.NewBranchReferenceName("main"): {
            SourceRef:  plumbing.NewBranchReferenceName("main"),
            TargetRef:  plumbing.NewBranchReferenceName("main"),
            SourceHash: plumbing.NewHash("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"),
        },
    }

_, err = fetchPackV2(context.Background(), conn, caps, desired, nil)
    if err == nil {
        
t.Fatal("expected decode error")
    }
    if !body.closed {
        
t.Fatal("expected response body to be closed on decode error")
    }
}

func TestBuildV1UploadPackBodyEmptyWantSet(t *testing.T) {
    adv := packp.NewAdvRefs()
    _, _, err := buildV1UploadPackBody(adv, nil, nil, false)