tinyrelaycommit

Commit f424095cdafd

browse files at this commit | history

1diff --git a/internal/gitrelay/gitrelay.go b/internal/gitrelay/gitrelay.go
2index 4420c85..b6f2d5e 100644
3--- a/internal/gitrelay/gitrelay.go
4+++ b/internal/gitrelay/gitrelay.go
5@@ -1893,7 +1893,10 @@ func (g *GitRelay) cgi(req *http.Request, w http.ResponseWriter, r Repository, s
6 pathInfo := prefix + "/" + r.Owner + "/" + r.Identifier + ".git" + suffix
7 ctx, cancel := context.WithCancel(req.Context())
8 defer cancel()
9- cmd := exec.CommandContext(ctx, "git", "http-backend")
10+ // Browser clients such as gitworkshop.dev fetch one commit at a time with
11+ // a filter, and refuse servers that do not advertise filter and
12+ // sha1-in-want. The -c settings reach upload-pack through the environment.
13+ cmd := exec.CommandContext(ctx, "git", "-c", "uploadpack.allowFilter=true", "-c", "uploadpack.allowAnySHA1InWant=true", "http-backend")
14 cmd.Dir = g.root
15 cmd.WaitDelay = 5 * time.Second
16 stdin, contentLength, cleanup, err := cgiInput(req)
17diff --git a/internal/gitrelay/gitrelay_test.go b/internal/gitrelay/gitrelay_test.go
18index f19ce3d..5c112ec 100644
19--- a/internal/gitrelay/gitrelay_test.go
20+++ b/internal/gitrelay/gitrelay_test.go
21@@ -710,9 +710,16 @@ func TestSmartHTTPServesBareRepository(t *testing.T) {
22 if res.Code != http.StatusOK {
23 t.Fatalf("smart HTTP status = %d: %s", res.Code, res.Body.String())
24 }
25- if body, _ := io.ReadAll(res.Result().Body); len(body) == 0 {
26+ body, _ := io.ReadAll(res.Result().Body)
27+ if len(body) == 0 {
28 t.Fatal("smart HTTP returned an empty advertisement")
29 }
30+ // gitworkshop.dev and other browser clients require these capabilities.
31+ for _, capability := range []string{" filter", " allow-tip-sha1-in-want", " allow-reachable-sha1-in-want", " object-format=sha1"} {
32+ if !strings.Contains(string(body), capability) {
33+ t.Errorf("advertisement lacks %q: %s", strings.TrimSpace(capability), body)
34+ }
35+ }
36 }
37
38 func TestPendingStatePromotesAfterAuthorizedGitPush(t *testing.T) {

About

ownerc01503e8035f
visibilitypublic
headf424095cdafd

Maintainers

  • c01503e8035f owner
  • ba1b5beed5b5 agent hermes

Clone

  • https://012.run/npub1cq2s86qrtadf36eqq3epm38wmhdynrrcwxf84eldk3f94dkv7ttsrulrz5/tinyrelay.git

Refs