just-git 1.5.13 → 1.6.0

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.
@@ -1,5 +1,5 @@
1
- import { i as ObjectId, X as RawObject, Y as Ref, g as GitRepo, a0 as Rejection, N as NetworkPolicy } from '../hooks-B50z7ycn.js';
2
- import { C as CommitOptions, a as CommitResult } from '../writing-BYrXF-yM.js';
1
+ import { i as ObjectId, X as RawObject, Y as Ref, g as GitRepo, a0 as Rejection, N as NetworkPolicy } from '../hooks-pZgz2y6k.js';
2
+ import { C as CommitOptions, a as CommitResult } from '../writing-O7uuLVT_.js';
3
3
 
4
4
  /** Shallow boundary delta: what to add/remove from `.git/shallow`. */
5
5
  interface ShallowUpdate {
@@ -19,7 +19,7 @@ interface ShallowUpdate {
19
19
  type MaybeAsync<T> = T | Promise<T>;
20
20
  /** Options for creating a new repo via `GitServer.createRepo`. */
21
21
  interface CreateRepoOptions {
22
- /** Name of the default branch (default: `"main"`). Used for HEAD initialization. */
22
+ /** Default branch name for the initial `HEAD -> refs/heads/<branch>` symref. */
23
23
  defaultBranch?: string;
24
24
  }
25
25
  /**
@@ -59,6 +59,8 @@ interface RefOps {
59
59
  * atomic ref operation primitive. All git-aware logic — object hashing,
60
60
  * pack ingestion, symref resolution, compare-and-swap semantics — lives
61
61
  * in the internal adapter and does not need to be implemented by backends.
62
+ * Optional batch helpers (`getObjects`, `hasObjects`) let the adapter reduce
63
+ * round trips during object walks and pack generation, but are not required.
62
64
  *
63
65
  * All methods use {@link MaybeAsync} return types: sync backends (SQLite)
64
66
  * can return values directly, async backends (PostgreSQL) return promises.
@@ -77,20 +79,48 @@ interface Storage {
77
79
  * Returns `null` when the object does not exist.
78
80
  */
79
81
  getObject(repoId: string, hash: string): MaybeAsync<RawObject | null>;
80
- /** Store a single git object. `content` is the uncompressed object body (no git header). */
82
+ /**
83
+ * Batch-read raw git objects by hash.
84
+ * Returns only objects that exist for `repoId`, keyed by full hash.
85
+ * Missing hashes must simply be omitted from the returned map.
86
+ * Backends should keep the singleton case cheap as well — callers may
87
+ * sometimes probe one hash at a time, so avoid batch-only overhead such as
88
+ * per-call query preparation or heavy intermediate allocation.
89
+ */
90
+ getObjects?(repoId: string, hashes: ReadonlyArray<string>): MaybeAsync<Map<string, RawObject>>;
91
+ /**
92
+ * Store a single git object.
93
+ *
94
+ * `content` is the raw object body (no git header / envelope). Because
95
+ * git objects are immutable, duplicate writes may be ignored.
96
+ */
81
97
  putObject(repoId: string, hash: string, type: string, content: Uint8Array): MaybeAsync<void>;
82
98
  /**
83
99
  * Bulk-insert objects. Called during pack ingestion (push, fetch).
84
100
  * Implementations should use their optimal batch strategy (e.g. a
85
101
  * single transaction for SQL backends).
102
+ *
103
+ * Returns the hashes newly inserted for `repoId`. Existing rows must not
104
+ * be reported, even if the same object appears in the incoming batch.
105
+ * The adapter uses this return value for rejected-push rollback, so it
106
+ * must reflect only rows created by this call in this repo partition.
86
107
  */
87
108
  putObjects(repoId: string, objects: ReadonlyArray<{
88
109
  hash: string;
89
110
  type: string;
90
111
  content: Uint8Array;
91
- }>): MaybeAsync<void>;
112
+ }>): MaybeAsync<string[]>;
92
113
  /** Check whether an object exists without reading its content. */
93
114
  hasObject(repoId: string, hash: string): MaybeAsync<boolean>;
115
+ /**
116
+ * Batch existence check for objects.
117
+ * Returns the subset of `hashes` that exist for `repoId`.
118
+ * Missing hashes must simply be omitted from the returned set.
119
+ * As with `getObjects`, implementations should preserve a fast path for
120
+ * single-hash probes and prefer reusable query plans / statement caches when
121
+ * the backend benefits from them.
122
+ */
123
+ hasObjects?(repoId: string, hashes: ReadonlyArray<string>): MaybeAsync<Set<string>>;
94
124
  /**
95
125
  * Find all object hashes starting with `prefix` (for short-hash resolution).
96
126
  * `prefix` is at least 4 hex characters.
@@ -100,7 +130,9 @@ interface Storage {
100
130
  listObjectHashes(repoId: string): MaybeAsync<string[]>;
101
131
  /**
102
132
  * Delete specific objects by hash.
103
- * Returns the number of objects actually deleted.
133
+ * Returns the number of objects actually deleted from this repo's own
134
+ * object partition. Fork-aware backends must not treat this as a request
135
+ * to delete from a parent/shared object partition.
104
136
  */
105
137
  deleteObjects(repoId: string, hashes: ReadonlyArray<string>): MaybeAsync<number>;
106
138
  /**
@@ -123,21 +155,25 @@ interface Storage {
123
155
  *
124
156
  * The storage backend wraps the callback in whatever isolation
125
157
  * mechanism it supports (SQL transaction, in-memory lock, etc.).
126
- * The adapter uses this for compare-and-swap with symref resolution.
158
+ * The adapter uses this for compare-and-swap with symref resolution and
159
+ * expects all reads/writes inside `fn` to observe the same transaction or
160
+ * lock scope.
127
161
  */
128
162
  atomicRefUpdate<T>(repoId: string, fn: (ops: RefOps) => MaybeAsync<T>): MaybeAsync<T>;
129
163
  /**
130
164
  * Record a fork relationship. `targetId` becomes a fork of `sourceId`.
131
- * The adapter layer handles ref copying and root resolution.
165
+ * The adapter layer handles ref copying and root resolution; this method
166
+ * only needs to persist the parent relationship.
132
167
  */
133
168
  forkRepo?(sourceId: string, targetId: string): MaybeAsync<void>;
134
169
  /**
135
- * Get the parent (root) repo ID for a fork, or `null` if the repo
136
- * is not a fork.
170
+ * Get the root parent repo ID for a fork, or `null` if the repo is not
171
+ * a fork.
137
172
  */
138
173
  getForkParent?(repoId: string): MaybeAsync<string | null>;
139
174
  /**
140
- * List all direct fork IDs of a repo.
175
+ * List all direct fork IDs of a repo. Used to block deletion of a root
176
+ * repo while active forks still exist.
141
177
  */
142
178
  listForks?(repoId: string): MaybeAsync<string[]>;
143
179
  }
@@ -629,9 +665,13 @@ interface ServerHooks<A = Auth> {
629
665
  */
630
666
  postReceive?: (event: PostReceiveEvent<A>) => void | Promise<void>;
631
667
  /**
632
- * Called when a client wants to fetch or push (during ref advertisement).
633
- * Return a filtered ref list to hide branches, a Rejection to deny
634
- * access entirely, or void to advertise all refs.
668
+ * Called during upload-pack / receive-pack ref advertisement.
669
+ * Return a filtered ref list to hide refs, a Rejection to deny
670
+ * access to that service entirely, or void to advertise all refs.
671
+ *
672
+ * This hook is primarily for ref visibility and coarse service access.
673
+ * Use `preReceive` / `update` for push authorization and per-ref write
674
+ * policy.
635
675
  */
636
676
  advertiseRefs?: (event: AdvertiseRefsEvent<A>) => RefAdvertisement[] | void | Rejection | Promise<RefAdvertisement[] | void | Rejection>;
637
677
  }
@@ -989,7 +1029,10 @@ interface ReceivePackResult {
989
1029
  capabilities: string[];
990
1030
  /** Whether the request body contained a valid pkt-line flush packet. */
991
1031
  sawFlush: boolean;
992
- /** Hashes of objects ingested from the pack (for rollback on hook rejection). Only populated when the object store supports deferred ingestion (server-backed stores). Undefined for VFS-backed stores. */
1032
+ /**
1033
+ * Hashes newly inserted for this repo while ingesting the pack.
1034
+ * Used for rollback when the push is rejected before any refs apply.
1035
+ */
993
1036
  ingestedHashes?: string[];
994
1037
  }
995
1038
  /**
@@ -998,8 +1041,8 @@ interface ReceivePackResult {
998
1041
  * call `applyReceivePack` to run hooks and apply refs.
999
1042
  *
1000
1043
  * Objects are persisted immediately (needed by `buildRefUpdates` for
1001
- * ancestry checks). If hooks later reject the push, `applyReceivePack`
1002
- * rolls back the ingested objects.
1044
+ * ancestry checks). `applyReceivePack` rolls back newly inserted objects
1045
+ * if the push is rejected before any refs apply.
1003
1046
  */
1004
1047
  declare function ingestReceivePack(repo: GitRepo, requestBody: Uint8Array, limits?: ReceivePackLimitOptions): Promise<ReceivePackResult>;
1005
1048
  /**
@@ -1082,13 +1125,15 @@ declare class MemoryStorage implements Storage {
1082
1125
  insertRepo(repoId: string): void;
1083
1126
  deleteRepo(repoId: string): void;
1084
1127
  getObject(repoId: string, hash: string): RawObject | null;
1128
+ getObjects(repoId: string, hashes: ReadonlyArray<string>): Map<string, RawObject>;
1085
1129
  putObject(repoId: string, hash: string, type: string, content: Uint8Array): void;
1086
1130
  putObjects(repoId: string, objects: ReadonlyArray<{
1087
1131
  hash: string;
1088
1132
  type: string;
1089
1133
  content: Uint8Array;
1090
- }>): void;
1134
+ }>): string[];
1091
1135
  hasObject(repoId: string, hash: string): boolean;
1136
+ hasObjects(repoId: string, hashes: ReadonlyArray<string>): Set<string>;
1092
1137
  findObjectsByPrefix(repoId: string, prefix: string): string[];
1093
1138
  listObjectHashes(repoId: string): string[];
1094
1139
  deleteObjects(repoId: string, hashes: ReadonlyArray<string>): number;
@@ -1129,6 +1174,8 @@ interface BunSqliteDatabase {
1129
1174
  declare class BunSqliteStorage implements Storage {
1130
1175
  private db;
1131
1176
  private stmts;
1177
+ private objectReadManyStatements;
1178
+ private objectExistsManyStatements;
1132
1179
  private batchInsertTx;
1133
1180
  private batchDeleteTx;
1134
1181
  constructor(db: BunSqliteDatabase);
@@ -1136,16 +1183,21 @@ declare class BunSqliteStorage implements Storage {
1136
1183
  insertRepo(repoId: string): void;
1137
1184
  deleteRepo(repoId: string): void;
1138
1185
  getObject(repoId: string, hash: string): RawObject | null;
1186
+ getObjects(repoId: string, hashes: ReadonlyArray<string>): Map<string, RawObject>;
1139
1187
  putObject(repoId: string, hash: string, type: string, content: Uint8Array): void;
1140
1188
  putObjects(repoId: string, objects: ReadonlyArray<{
1141
1189
  hash: string;
1142
1190
  type: string;
1143
1191
  content: Uint8Array;
1144
- }>): void;
1192
+ }>): string[];
1145
1193
  hasObject(repoId: string, hash: string): boolean;
1194
+ hasObjects(repoId: string, hashes: ReadonlyArray<string>): Set<string>;
1146
1195
  findObjectsByPrefix(repoId: string, prefix: string): string[];
1147
1196
  listObjectHashes(repoId: string): string[];
1148
1197
  deleteObjects(repoId: string, hashes: ReadonlyArray<string>): number;
1198
+ private getObjectReadManyStatement;
1199
+ private getObjectExistsManyStatement;
1200
+ private getCachedStatement;
1149
1201
  getRef(repoId: string, name: string): Ref | null;
1150
1202
  putRef(repoId: string, name: string, ref: Ref): void;
1151
1203
  removeRef(repoId: string, name: string): void;
@@ -1179,6 +1231,8 @@ interface BetterSqlite3Database {
1179
1231
  declare class BetterSqlite3Storage implements Storage {
1180
1232
  private db;
1181
1233
  private stmts;
1234
+ private objectReadManyStatements;
1235
+ private objectExistsManyStatements;
1182
1236
  private batchInsertTx;
1183
1237
  private batchDeleteTx;
1184
1238
  constructor(db: BetterSqlite3Database);
@@ -1186,16 +1240,21 @@ declare class BetterSqlite3Storage implements Storage {
1186
1240
  insertRepo(repoId: string): void;
1187
1241
  deleteRepo(repoId: string): void;
1188
1242
  getObject(repoId: string, hash: string): RawObject | null;
1243
+ getObjects(repoId: string, hashes: ReadonlyArray<string>): Map<string, RawObject>;
1189
1244
  putObject(repoId: string, hash: string, type: string, content: Uint8Array): void;
1190
1245
  putObjects(repoId: string, objects: ReadonlyArray<{
1191
1246
  hash: string;
1192
1247
  type: string;
1193
1248
  content: Uint8Array;
1194
- }>): void;
1249
+ }>): string[];
1195
1250
  hasObject(repoId: string, hash: string): boolean;
1251
+ hasObjects(repoId: string, hashes: ReadonlyArray<string>): Set<string>;
1196
1252
  findObjectsByPrefix(repoId: string, prefix: string): string[];
1197
1253
  listObjectHashes(repoId: string): string[];
1198
1254
  deleteObjects(repoId: string, hashes: ReadonlyArray<string>): number;
1255
+ private getObjectReadManyStatement;
1256
+ private getObjectExistsManyStatement;
1257
+ private getCachedStatement;
1199
1258
  getRef(repoId: string, name: string): Ref | null;
1200
1259
  putRef(repoId: string, name: string, ref: Ref): void;
1201
1260
  removeRef(repoId: string, name: string): void;
@@ -1239,13 +1298,15 @@ declare class PgStorage implements Storage {
1239
1298
  insertRepo(repoId: string): Promise<void>;
1240
1299
  deleteRepo(repoId: string): Promise<void>;
1241
1300
  getObject(repoId: string, hash: string): Promise<RawObject | null>;
1301
+ getObjects(repoId: string, hashes: ReadonlyArray<string>): Promise<Map<string, RawObject>>;
1242
1302
  putObject(repoId: string, hash: string, type: string, content: Uint8Array): Promise<void>;
1243
1303
  putObjects(repoId: string, objects: ReadonlyArray<{
1244
1304
  hash: string;
1245
1305
  type: string;
1246
1306
  content: Uint8Array;
1247
- }>): Promise<void>;
1307
+ }>): Promise<string[]>;
1248
1308
  hasObject(repoId: string, hash: string): Promise<boolean>;
1309
+ hasObjects(repoId: string, hashes: ReadonlyArray<string>): Promise<Set<string>>;
1249
1310
  findObjectsByPrefix(repoId: string, prefix: string): Promise<string[]>;
1250
1311
  listObjectHashes(repoId: string): Promise<string[]>;
1251
1312
  deleteObjects(repoId: string, hashes: ReadonlyArray<string>): Promise<number>;
@@ -1312,13 +1373,15 @@ declare class DurableObjectSqliteStorage implements Storage {
1312
1373
  insertRepo(repoId: string): void;
1313
1374
  deleteRepo(repoId: string): void;
1314
1375
  getObject(repoId: string, hash: string): RawObject | null;
1376
+ getObjects(repoId: string, hashes: ReadonlyArray<string>): Map<string, RawObject>;
1315
1377
  putObject(repoId: string, hash: string, type: string, content: Uint8Array): void;
1316
1378
  putObjects(repoId: string, objects: ReadonlyArray<{
1317
1379
  hash: string;
1318
1380
  type: string;
1319
1381
  content: Uint8Array;
1320
- }>): void;
1382
+ }>): string[];
1321
1383
  hasObject(repoId: string, hash: string): boolean;
1384
+ hasObjects(repoId: string, hashes: ReadonlyArray<string>): Set<string>;
1322
1385
  findObjectsByPrefix(repoId: string, prefix: string): string[];
1323
1386
  listObjectHashes(repoId: string): string[];
1324
1387
  deleteObjects(repoId: string, hashes: ReadonlyArray<string>): number;