OverviewFilesCommitsIssuesDocsReleasesPeers

pear-git commits / 833f829

Auto-create repos on ref-update, not just full-sync
handleRefUpdate silently skipped repos that didn't exist locally (ENOENT → return). New repos created after the initial full-sync exchange were never picked up by mirror peers. Now uses _initBareRepo (same as handleFullSyncManifest) to create the bare repo on first ref-update, then fetches into it. Fixes pear-git#80 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
833f8298314f0209ef3582114714885dc193ad7c
by plankatron <fleeky@gmail.com> · 2026-04-07T01:48:12.000Z

Changed files (1) +14 -4

lib/p2p/sync/git-sync-client-manager.js +14 -4
……@@ -78,10 +78,20 @@ export class GitSyncClientManager {
7878 try {
7979 localRefs = await this._readRefs(repoPath)
8080 } catch (err) {
81 // Repo doesn't exist locally — nothing to sync
82 if (err.code === 'ENOENT') return
83 console.error(`[GitSyncClient] Error reading refs for ${repoName}: ${err.message}`)
84 return
81 if (err.code === 'ENOENT') {
82 // Repo exists on remote but not locally — create it and sync
83 try {
84 await this._initBareRepo(repoPath)
85 console.log(`[GitSyncClient] Created missing repo: ${repoName}`)
86 localRefs = {}
87 } catch (initErr) {
88 console.error(`[GitSyncClient] Failed to create repo ${repoName}: ${initErr.message}`)
89 return
90 }
91 } else {
92 console.error(`[GitSyncClient] Error reading refs for ${repoName}: ${err.message}`)
93 return
94 }
8595 }
8696
8797 // Compare local vs remote