Expand incremental relay to branch batches · Entire

Expand incremental relay to branch batches

b88dfb7→main·

Soph·3mo ago·4 files·+86 added/-13 removed

Sessions

03bc9b185ab8View 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-03bc9b185ab8/index.html)

Changes

4

90 unmodified lines

91
92
93
94
94
95
96
97

90 unmodified lines

When `sync` sees that all managed target refs are absent and the run is compatible with bootstrap semantics, it automatically uses the bootstrap relay path instead of the normal decode-and-repack sync path.

`sync` also uses a narrow incremental relay path for a single fast-forward branch update when the target already has the old tip and the target does not advertise `no-thin`. More complex updates still fall back to the normal local decode-and-repack path.
`sync` also uses a narrow incremental relay path for fast-forward branch updates when all planned updates are branch-only, there are no mappings, no tags, no prune/delete, no force, and the target does not advertise `no-thin`. More complex updates still fall back to the normal local decode-and-repack path.

Sync specific branches:

MREADME.md+1/-1

163 unmodified lines

164
165
166
167
168
167
168

163 unmodified lines

Progress:

- there is now a narrow incremental relay path in `sync`
- it is limited to a single fast-forward branch update
- tags, deletes, force, prune, mapped refs, and multi-ref updates still use the normal path
- it now covers multi-branch fast-forward branch-only updates
- tags, deletes, force, prune, and mapped refs still use the normal path

Mdocs/bootstrap.md+2/-2

147 unmodified lines

148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225

147 unmodified lines

}
}

func TestRun_GitHTTPBackendSyncMultiBranchFastForward(t *testing.T) {
    if os.Getenv(gitHTTPBackendEnv) == "" {
        t.Skip("set GITSYNC_E2E_GIT_HTTP_BACKEND=1 to run git-http-backend integration test")
    }

if _, err := exec.LookPath("git"); err != nil {
        t.Skipf("git not available: %v", err)
    }

root := t.TempDir()
    sourceBare := filepath.Join(root, "source.git")
    targetBare := filepath.Join(root, "target.git")
    worktree := filepath.Join(root, "work")

runGit(t, root, "init", "--bare", sourceBare)
    runGit(t, root, "init", "--bare", targetBare)
    runGit(t, targetBare, "config", "http.receivepack", "true")
    runGit(t, root, "init", "-b", testBranch, worktree)
    runGit(t, worktree, "config", "user.name", "git-sync test")
    runGit(t, worktree, "config", "user.email", "git-sync@example.com")

writeFile(t, filepath.Join(worktree, "README.md"), "base\n")
    runGit(t, worktree, "add", "README.md")
    runGit(t, worktree, "commit", "-m", "initial")
    runGit(t, worktree, "branch", "release")
    runGit(t, worktree, "remote", "add", "origin", sourceBare)
    runGit(t, worktree, "push", "origin", "HEAD:refs/heads/"+testBranch)
    runGit(t, worktree, "push", "origin", "release:refs/heads/release")

server := newGitHTTPBackendServer(t, root)
    defer server.Close()

sourceURL := server.RepoURL("source.git")
    targetURL := server.RepoURL("target.git")

if _, err := Run(context.Background(), Config{
        Source: Endpoint{URL: sourceURL},
        Target: Endpoint{URL: targetURL},
    }); err != nil {
        t.Fatalf("initial sync failed: %v", err)
    }

runGit(t, worktree, "checkout", testBranch)
    writeFile(t, filepath.Join(worktree, "main.txt"), "main update\n")
    runGit(t, worktree, "add", "main.txt")
    runGit(t, worktree, "commit", "-m", "main update")
    runGit(t, worktree, "push", "origin", "HEAD:refs/heads/"+testBranch)

runGit(t, worktree, "checkout", "release")
    writeFile(t, filepath.Join(worktree, "release.txt"), "release update\n")
    runGit(t, worktree, "add", "release.txt")
    runGit(t, worktree, "commit", "-m", "release update")
    runGit(t, worktree, "push", "origin", "HEAD:refs/heads/release")

result, err := Run(context.Background(), Config{
        Source: Endpoint{URL: sourceURL},
        Target: Endpoint{URL: targetURL},
    })
    if err != nil {
        t.Fatalf("multi-branch incremental sync failed: %v", err)
    }
    if result.Pushed != 2 || result.Blocked != 0 {
        t.Fatalf("unexpected multi-branch result: %+v", result)
    }
    if !result.Relay || result.RelayMode != "incremental" {
        t.Fatalf("expected multi-branch fast-forward sync to use incremental relay, got %+v", result)
    }

assertGitRefEqual(t, sourceBare, targetBare, plumbing.NewBranchReferenceName(testBranch))
    assertGitRefEqual(t, sourceBare, targetBare, plumbing.NewBranchReferenceName("release"))
}

func TestBootstrap_GitHTTPBackendSync(t *testing.T) {
    if os.Getenv(gitHTTPBackendEnv) == "" {
        t.Skip("set GITSYNC_E2E_GIT_HTTP_BACKEND=1 to run git-http-backend integration test")
    }