gip-remote 1.2.5 → 1.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +16 -2
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -241,7 +241,21 @@ class Remote extends ReadyResource {
|
|
|
241
241
|
objects: [...objects.keys()]
|
|
242
242
|
})
|
|
243
243
|
} else {
|
|
244
|
-
// 5b. Insert branch record
|
|
244
|
+
// 5b. Insert/update branch record.
|
|
245
|
+
//
|
|
246
|
+
// `objects` is the denormalized "everything reachable from this branch"
|
|
247
|
+
// set used by getRefObjects() at fetch time. CRITICAL: we must MERGE
|
|
248
|
+
// with the prior record's objects, not overwrite. A real git client
|
|
249
|
+
// sends a thin pack on follow-up pushes (only the new objects), so
|
|
250
|
+
// `objects.keys()` here would be e.g. just {commit B, new tree} —
|
|
251
|
+
// commit A and its tree from the previous push would be dropped from
|
|
252
|
+
// the list, and a fresh clone calling getRefObjects(headOfB) would be
|
|
253
|
+
// missing every parent commit. That's the "I cloned and lost a
|
|
254
|
+
// commit" symptom.
|
|
255
|
+
const prev = await this._db.get('@gip/branches', { name: refName })
|
|
256
|
+
const merged = new Set(prev ? prev.objects : [])
|
|
257
|
+
for (const k of objects.keys()) merged.add(k)
|
|
258
|
+
|
|
245
259
|
await this._db.insert('@gip/branches', {
|
|
246
260
|
name: refName,
|
|
247
261
|
commitOid: oid,
|
|
@@ -249,7 +263,7 @@ class Remote extends ReadyResource {
|
|
|
249
263
|
author: commit.author,
|
|
250
264
|
message: commit.message,
|
|
251
265
|
timestamp: commit.timestamp,
|
|
252
|
-
objects: [...
|
|
266
|
+
objects: [...merged]
|
|
253
267
|
})
|
|
254
268
|
|
|
255
269
|
// 6. Set HEAD to first branch pushed (like git init)
|