@statewalker/vcs-commands 0.13.0 → 0.14.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.
- package/dist/commands/archive/archive-command.d.ts +6 -2
- package/dist/commands/archive/archive-command.d.ts.map +1 -1
- package/dist/commands/archive/remote-archive-command.d.ts +23 -1
- package/dist/commands/archive/remote-archive-command.d.ts.map +1 -1
- package/dist/commands/archive/upload-archive-writer.d.ts +11 -5
- package/dist/commands/archive/upload-archive-writer.d.ts.map +1 -1
- package/dist/commands/bundle/bundle-format.d.ts +6 -1
- package/dist/commands/bundle/bundle-format.d.ts.map +1 -1
- package/dist/commands/bundle/bundle-uri-host.d.ts +12 -1
- package/dist/commands/bundle/bundle-uri-host.d.ts.map +1 -1
- package/dist/commands/bundle/bundle-uri.d.ts +7 -1
- package/dist/commands/bundle/bundle-uri.d.ts.map +1 -1
- package/dist/commands/bundle/bundle-verify.d.ts +4 -1
- package/dist/commands/bundle/bundle-verify.d.ts.map +1 -1
- package/dist/commands/cat-file/cat-file-command.d.ts.map +1 -1
- package/dist/commands/check-ignore-command.d.ts.map +1 -1
- package/dist/commands/clone-command.d.ts +15 -0
- package/dist/commands/clone-command.d.ts.map +1 -1
- package/dist/commands/commit-command.d.ts +10 -1
- package/dist/commands/commit-command.d.ts.map +1 -1
- package/dist/commands/default-branch.d.ts +17 -3
- package/dist/commands/default-branch.d.ts.map +1 -1
- package/dist/commands/fetch-command.d.ts +2 -1
- package/dist/commands/fetch-command.d.ts.map +1 -1
- package/dist/commands/fsck/fsck-object-checks.d.ts.map +1 -1
- package/dist/commands/git-hooks.d.ts +3 -3
- package/dist/commands/git-hooks.d.ts.map +1 -1
- package/dist/commands/index.js +6 -6
- package/dist/commands/init-command.d.ts.map +1 -1
- package/dist/commands/local-transport.d.ts +11 -1
- package/dist/commands/local-transport.d.ts.map +1 -1
- package/dist/commands/ls-tree-command.d.ts +10 -0
- package/dist/commands/ls-tree-command.d.ts.map +1 -1
- package/dist/commands/merge-command.d.ts +11 -1
- package/dist/commands/merge-command.d.ts.map +1 -1
- package/dist/commands/merge-support.d.ts +19 -2
- package/dist/commands/merge-support.d.ts.map +1 -1
- package/dist/commands/plumbing-input.d.ts.map +1 -1
- package/dist/commands/promisor-remote-reply.d.ts +31 -4
- package/dist/commands/promisor-remote-reply.d.ts.map +1 -1
- package/dist/commands/promisor-remote.d.ts +8 -1
- package/dist/commands/promisor-remote.d.ts.map +1 -1
- package/dist/commands/push-command.d.ts.map +1 -1
- package/dist/commands/ref-filter/index.d.ts +1 -0
- package/dist/commands/ref-filter/index.d.ts.map +1 -1
- package/dist/commands/ref-filter/peel-limit.d.ts +8 -0
- package/dist/commands/ref-filter/peel-limit.d.ts.map +1 -0
- package/dist/commands/ref-filter/ref-filter.d.ts.map +1 -1
- package/dist/commands/ref-filter/ref-format.d.ts.map +1 -1
- package/dist/commands/serve-repository.d.ts +4 -3
- package/dist/commands/serve-repository.d.ts.map +1 -1
- package/dist/commands/signing.d.ts +29 -2
- package/dist/commands/signing.d.ts.map +1 -1
- package/dist/commands/split-cmdline.d.ts +6 -0
- package/dist/commands/split-cmdline.d.ts.map +1 -0
- package/dist/{commands-CPceUCP2.js → commands-C9M78Chn.js} +1186 -1036
- package/dist/errors/commit-errors.d.ts +17 -1
- package/dist/errors/commit-errors.d.ts.map +1 -1
- package/dist/errors/index.js +18 -3
- package/dist/{fsck-tbrPZX2q.js → fsck-C4US3l0B.js} +2 -2
- package/dist/index.js +7 -7
- package/dist/{maintenance-run-command-UiSIaeP8.js → maintenance-run-command-CoJFKr2p.js} +84 -32
- package/dist/{remote-transport-C0OSJtor.js → remote-transport-C43eykfK.js} +51 -16
- package/dist/results/index.js +1 -1
- package/dist/{results-CkS1p1CH.js → results-B0CWLCAp.js} +371 -53
- package/dist/transport-command.d.ts +3 -0
- package/dist/transport-command.d.ts.map +1 -1
- package/package.json +21 -13
- package/src/commands/archive/archive-command.ts +7 -3
- package/src/commands/archive/remote-archive-command.ts +37 -3
- package/src/commands/archive/upload-archive-writer.ts +34 -22
- package/src/commands/bundle/bundle-format.ts +10 -2
- package/src/commands/bundle/bundle-uri-host.ts +71 -11
- package/src/commands/bundle/bundle-uri.ts +11 -4
- package/src/commands/bundle/bundle-verify.ts +4 -1
- package/src/commands/cat-file/cat-file-command.ts +1 -33
- package/src/commands/check-ignore-command.ts +60 -15
- package/src/commands/clone-command.ts +89 -11
- package/src/commands/commit-command.ts +42 -7
- package/src/commands/default-branch.ts +19 -5
- package/src/commands/fetch-command.ts +13 -2
- package/src/commands/fsck/fsck-object-checks.ts +3 -1
- package/src/commands/git-hooks.ts +11 -5
- package/src/commands/init-command.ts +24 -4
- package/src/commands/local-transport.ts +53 -9
- package/src/commands/ls-tree-command.ts +20 -12
- package/src/commands/merge-command.ts +32 -8
- package/src/commands/merge-support.ts +42 -4
- package/src/commands/plumbing-input.ts +3 -1
- package/src/commands/promisor-remote-reply.ts +338 -56
- package/src/commands/promisor-remote.ts +25 -3
- package/src/commands/push-command.ts +5 -1
- package/src/commands/read-tree-command.ts +2 -2
- package/src/commands/ref-filter/index.ts +1 -0
- package/src/commands/ref-filter/peel-limit.ts +7 -0
- package/src/commands/ref-filter/ref-filter.ts +9 -3
- package/src/commands/ref-filter/ref-format.ts +2 -1
- package/src/commands/serve-repository.ts +8 -3
- package/src/commands/signing.ts +93 -10
- package/src/commands/split-cmdline.ts +32 -0
- package/src/errors/commit-errors.ts +24 -2
- package/src/transport-command.ts +31 -1
|
@@ -16,8 +16,10 @@ import { GitCommand } from "../git-command.js";
|
|
|
16
16
|
import { quotePath } from "../results/quote-path.js";
|
|
17
17
|
import type { PlumbingTextOutput } from "./check-ref-format-command.js";
|
|
18
18
|
import { hostEnvironmentOf } from "./git-ident.js";
|
|
19
|
+
import { parseElementMagic, unsupportedPathspecMagic } from "./ls-tree-command.js";
|
|
19
20
|
import { configBool, configValue } from "./merge-config.js";
|
|
20
21
|
import { DO_MATCH_DIRECTORY, matchPathspec, parsePathspecItem } from "./pathspec.js";
|
|
22
|
+
import { PlumbingError } from "./plumbing-command.js";
|
|
21
23
|
import { directoryPrefix, inputRecords, prefixPath } from "./plumbing-input.js";
|
|
22
24
|
import { worktreeHostPath } from "./submodule-model.js";
|
|
23
25
|
|
|
@@ -133,28 +135,56 @@ export class CheckIgnoreCommand extends GitCommand<PlumbingTextOutput> {
|
|
|
133
135
|
let ignored = 0;
|
|
134
136
|
|
|
135
137
|
const top = await worktreeHostPath(this._workingCopy);
|
|
136
|
-
const
|
|
137
|
-
|
|
138
|
+
const EMPTY =
|
|
139
|
+
"empty string is not a valid pathspec. please use . instead if you meant to match all paths";
|
|
140
|
+
/**
|
|
141
|
+
* parse_pathspec of one element with check-ignore's mask (every magic but `:/`
|
|
142
|
+
* refused), PATHSPEC_SYMLINK_LEADING_PATH, then die_path_inside_submodule: the path
|
|
143
|
+
* from the top, or git's death.
|
|
144
|
+
*/
|
|
145
|
+
const parse = async (original: string): Promise<{ path: string } | { death: string }> => {
|
|
146
|
+
if (original === "") return { death: EMPTY };
|
|
147
|
+
let parsed: { magic: Set<string>; rest: string };
|
|
148
|
+
try {
|
|
149
|
+
parsed = parseElementMagic(original);
|
|
150
|
+
} catch (error) {
|
|
151
|
+
if (error instanceof PlumbingError) return { death: error.message.replace(/^fatal: /, "") };
|
|
152
|
+
throw error;
|
|
153
|
+
}
|
|
154
|
+
const { magic, rest } = parsed;
|
|
155
|
+
if (magic.has("literal") && magic.has("glob")) {
|
|
156
|
+
return { death: `${original}: 'literal' and 'glob' are incompatible` };
|
|
157
|
+
}
|
|
158
|
+
const full = prefixPath(magic.has("top") ? "" : this.prefix, rest, top);
|
|
138
159
|
if (full === undefined) {
|
|
139
|
-
return `${original}: '${
|
|
160
|
+
return { death: `${original}: '${rest}' is outside repository at '${top ?? ""}'` };
|
|
140
161
|
}
|
|
162
|
+
const unsupported = unsupportedPathspecMagic(original, magic, ["top"]);
|
|
163
|
+
if (unsupported) return { death: unsupported };
|
|
141
164
|
const path = full.replace(/\/+$/, "");
|
|
142
165
|
// PATHSPEC_SYMLINK_LEADING_PATH
|
|
143
166
|
const parts = path.split("/");
|
|
144
167
|
for (let k = 1; k < parts.length; k++) {
|
|
145
168
|
const entry = await worktree.getEntry(parts.slice(0, k).join("/")).catch(() => undefined);
|
|
146
169
|
if (entry && (entry.mode & S_IFMT) === S_IFLNK) {
|
|
147
|
-
return `pathspec '${original}' is beyond a symbolic link
|
|
170
|
+
return { death: `pathspec '${original}' is beyond a symbolic link` };
|
|
148
171
|
}
|
|
149
172
|
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
173
|
+
return { path: full };
|
|
174
|
+
};
|
|
175
|
+
const insideSubmodule = (original: string, full: string): string | undefined => {
|
|
176
|
+
if (!staging) return undefined;
|
|
177
|
+
// die_path_inside_submodule
|
|
178
|
+
const path = full.replace(/\/+$/, "");
|
|
179
|
+
for (const e of index) {
|
|
180
|
+
if ((e.mode & S_IFMT) === S_IFGITLINK && path.startsWith(`${e.path}/`)) {
|
|
181
|
+
return `Pathspec '${original}' is in submodule '${e.path}'`;
|
|
156
182
|
}
|
|
157
183
|
}
|
|
184
|
+
return undefined;
|
|
185
|
+
};
|
|
186
|
+
const checkOne = async (original: string, full: string): Promise<void> => {
|
|
187
|
+
const path = full.replace(/\/+$/, "");
|
|
158
188
|
let match: IgnoreMatch | undefined;
|
|
159
189
|
if (!staging || !this.seenInIndex(full, index)) {
|
|
160
190
|
match = await worktree.ignoreMatch?.(path);
|
|
@@ -163,19 +193,34 @@ export class CheckIgnoreCommand extends GitCommand<PlumbingTextOutput> {
|
|
|
163
193
|
if (!this.quiet && (match || this.nonMatching))
|
|
164
194
|
stdout += this.line(original, match, sources, quoteFully);
|
|
165
195
|
if (match) ignored++;
|
|
196
|
+
};
|
|
197
|
+
/** check_ignore of the paths of one call: every element parsed before any output. */
|
|
198
|
+
const checkAll = async (originals: string[]): Promise<string | undefined> => {
|
|
199
|
+
if (originals.includes("")) return EMPTY;
|
|
200
|
+
const paths: string[] = [];
|
|
201
|
+
for (const original of originals) {
|
|
202
|
+
const parsed = await parse(original);
|
|
203
|
+
if ("death" in parsed) return parsed.death;
|
|
204
|
+
paths.push(parsed.path);
|
|
205
|
+
}
|
|
206
|
+
for (let i = 0; i < originals.length; i++) {
|
|
207
|
+
const death = insideSubmodule(originals[i] as string, paths[i] as string);
|
|
208
|
+
if (death) return death;
|
|
209
|
+
}
|
|
210
|
+
for (let i = 0; i < originals.length; i++)
|
|
211
|
+
await checkOne(originals[i] as string, paths[i] as string);
|
|
166
212
|
return undefined;
|
|
167
213
|
};
|
|
168
214
|
|
|
169
215
|
const run = async () => {
|
|
170
216
|
if (this.stdin === undefined) {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
if (death) return die(death);
|
|
174
|
-
}
|
|
217
|
+
const death = await checkAll(this.paths);
|
|
218
|
+
if (death) return die(death);
|
|
175
219
|
} else {
|
|
220
|
+
// one check_ignore per record: what came before a death stays on stdout
|
|
176
221
|
const { records, badlyQuoted } = inputRecords(this.stdin, this.nul);
|
|
177
222
|
for (const path of records) {
|
|
178
|
-
const death = await
|
|
223
|
+
const death = await checkAll([path]);
|
|
179
224
|
if (death) return die(death);
|
|
180
225
|
}
|
|
181
226
|
if (badlyQuoted) return die("line is badly quoted");
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
historyWithoutLazyFetch,
|
|
5
5
|
isSymbolicRef,
|
|
6
6
|
isValidRefName,
|
|
7
|
+
ObjectFilterError,
|
|
7
8
|
type ObjectId,
|
|
8
9
|
parseObjectFilter,
|
|
9
10
|
} from "@statewalker/vcs-core";
|
|
@@ -58,7 +59,9 @@ import {
|
|
|
58
59
|
} from "./bundle/index.js";
|
|
59
60
|
import { coreBool, worktreeModeTrust } from "./core-config.js";
|
|
60
61
|
import {
|
|
62
|
+
type DefaultBranch,
|
|
61
63
|
defaultInitialBranch,
|
|
64
|
+
type NewRepositoryConfig,
|
|
62
65
|
UnsupportedObjectStorageError,
|
|
63
66
|
unknownObjectStorageFormat,
|
|
64
67
|
} from "./default-branch.js";
|
|
@@ -68,7 +71,11 @@ import { runPostCheckoutHook } from "./git-hooks.js";
|
|
|
68
71
|
import { hostEnvironmentOf } from "./git-ident.js";
|
|
69
72
|
import { copyLocalObjects } from "./local-clone.js";
|
|
70
73
|
import { promisorOf } from "./promisor-remote.js";
|
|
71
|
-
import {
|
|
74
|
+
import {
|
|
75
|
+
promisorAutoFilter,
|
|
76
|
+
promisorRemoteReplyOf,
|
|
77
|
+
resetPromisorAcceptance,
|
|
78
|
+
} from "./promisor-remote-reply.js";
|
|
72
79
|
import { reflogMessages } from "./reflog-messages.js";
|
|
73
80
|
import { isValidRemoteName } from "./remote-command.js";
|
|
74
81
|
import { withRemoteUploadPack } from "./remote-transport.js";
|
|
@@ -98,6 +105,7 @@ const CLONE_SETTINGS = [
|
|
|
98
105
|
"rejectShallow",
|
|
99
106
|
"serverOptions",
|
|
100
107
|
"compatibility",
|
|
108
|
+
"bundleUri",
|
|
101
109
|
"cloneAllBranches",
|
|
102
110
|
"mirror",
|
|
103
111
|
"singleBranch",
|
|
@@ -222,6 +230,11 @@ export class CloneCommand extends TransportCommand<CloneResult> {
|
|
|
222
230
|
/** The git version reproduced; default the hooks' */
|
|
223
231
|
private compatibility?: "2.43" | "2.56";
|
|
224
232
|
private bundleUri?: string;
|
|
233
|
+
/**
|
|
234
|
+
* The hash `--bundle-uri`'s bundles are read in: git 2.43 fetches them before it learns the
|
|
235
|
+
* remote's hash, in the destination's first one (set on a clone reopened under 2.43)
|
|
236
|
+
*/
|
|
237
|
+
private bundleObjectFormat?: ObjectFormat;
|
|
225
238
|
private cloneAllBranches = true;
|
|
226
239
|
private mirror = false;
|
|
227
240
|
private singleBranch?: boolean;
|
|
@@ -338,11 +351,21 @@ export class CloneCommand extends TransportCommand<CloneResult> {
|
|
|
338
351
|
* Objects left out are fetched lazily from the remote when read (the checkout fetches the
|
|
339
352
|
* blobs it writes in one batch, as git's).
|
|
340
353
|
*
|
|
354
|
+
* `auto` (git 2.54) takes the filter the promisor remotes accepted from the server's
|
|
355
|
+
* `promisor-remote` capability advertise (none: no filter) and is recorded as `auto`, so
|
|
356
|
+
* later fetches resolve it again.
|
|
357
|
+
*
|
|
341
358
|
* @param spec The filter spec; `blob:limit=1k` is recorded and sent as `blob:limit=1024`
|
|
342
359
|
* @throws ObjectFilterError with git's message for a spec git refuses
|
|
343
360
|
*/
|
|
344
361
|
setFilter(spec: string): this {
|
|
345
362
|
this.checkCallable();
|
|
363
|
+
// `auto` (git 2.54): the filter the promisor remotes the server advertises and this
|
|
364
|
+
// clone accepts propose (promisor_remote_construct_filter), recorded as `auto`
|
|
365
|
+
if (spec === "auto") {
|
|
366
|
+
this.filterSpec = spec;
|
|
367
|
+
return this;
|
|
368
|
+
}
|
|
346
369
|
const filter = parseObjectFilter(spec);
|
|
347
370
|
// expand_list_objects_filter_spec: a blob limit in bytes
|
|
348
371
|
this.filterSpec = filter.choice === "blob:limit" ? `blob:limit=${filter.limit}` : spec;
|
|
@@ -852,6 +875,12 @@ export class CloneCommand extends TransportCommand<CloneResult> {
|
|
|
852
875
|
const self = this as unknown as Record<string, unknown>;
|
|
853
876
|
const other = next as unknown as Record<string, unknown>;
|
|
854
877
|
for (const key of CLONE_SETTINGS) if (key in self) other[key] = self[key];
|
|
878
|
+
// 2.43's clone ran fetch_bundle_uri in the repository GIT_DEFAULT_HASH had initialized,
|
|
879
|
+
// before transport_get_remote_refs: its bundles were read in that hash (a SHA-1 bundle in a
|
|
880
|
+
// SHA-256 destination is no bundle there); 2.5x reads them in the remote's
|
|
881
|
+
if ((this.compatibility ?? this.hooks.compatibility) === "2.43") {
|
|
882
|
+
other.bundleObjectFormat = this.bundleObjectFormat ?? this.objectFormat;
|
|
883
|
+
}
|
|
855
884
|
next.shareHooksOf(this);
|
|
856
885
|
const result = await next.call();
|
|
857
886
|
this.reopenedListener?.(workingCopy);
|
|
@@ -906,6 +935,10 @@ export class CloneCommand extends TransportCommand<CloneResult> {
|
|
|
906
935
|
);
|
|
907
936
|
}
|
|
908
937
|
const compatibility = this.compatibility ?? this.hooks.compatibility;
|
|
938
|
+
// git 2.43 has no `auto` filter
|
|
939
|
+
if (this.filterSpec === "auto" && compatibility === "2.43") {
|
|
940
|
+
throw new ObjectFilterError("invalid filter-spec 'auto'");
|
|
941
|
+
}
|
|
909
942
|
// parse_options: --revision is unknown to 2.43
|
|
910
943
|
if (this.revision !== undefined && compatibility === "2.43") {
|
|
911
944
|
throw new GitApiError(`error: unknown option \`revision=${this.revision}'`, {
|
|
@@ -1013,6 +1046,14 @@ export class CloneCommand extends TransportCommand<CloneResult> {
|
|
|
1013
1046
|
}
|
|
1014
1047
|
|
|
1015
1048
|
this.repoUrl = repo;
|
|
1049
|
+
// clone.c writes remote.<name>.url (and tagOpt) before it asks for the refs: what the
|
|
1050
|
+
// server's promisor-remote capability makes the fetch write (an auto-created remote)
|
|
1051
|
+
// comes after that section
|
|
1052
|
+
store.setValue(`remote.${this.remoteName}.url`, repo);
|
|
1053
|
+
if (this.tagOption === TagOption.NO_TAGS || this.mirror) {
|
|
1054
|
+
store.setValue(`remote.${this.remoteName}.tagOpt`, "--no-tags");
|
|
1055
|
+
}
|
|
1056
|
+
await store.save();
|
|
1016
1057
|
const sourceUrl = store.aliasUrl(repo) ?? repo;
|
|
1017
1058
|
const remote = await this.prepareRemote(bundleFile ?? sourceUrl);
|
|
1018
1059
|
if (remote.kind === "bundle" && remote.remote.bundle.header.filter !== undefined) {
|
|
@@ -1221,6 +1262,8 @@ export class CloneCommand extends TransportCommand<CloneResult> {
|
|
|
1221
1262
|
});
|
|
1222
1263
|
|
|
1223
1264
|
const sessionId = clientSessionIdOf(this.workingCopy);
|
|
1265
|
+
// a new git process: no promisor remote accepted yet (--filter=auto, lazy-fetch order)
|
|
1266
|
+
resetPromisorAcceptance(this.workingCopy);
|
|
1224
1267
|
const fetchOptions: TransportFetchOptions = {
|
|
1225
1268
|
...(sessionId !== undefined ? { sessionId } : {}),
|
|
1226
1269
|
// fetch.uriProtocols: the packs a v2 server offloads to packfile URIs
|
|
@@ -1233,6 +1276,9 @@ export class CloneCommand extends TransportCommand<CloneResult> {
|
|
|
1233
1276
|
repository: createRepositoryFacade({ history: historyWithoutLazyFetch(history) }),
|
|
1234
1277
|
refStore: createTransportRefStore(history.refs),
|
|
1235
1278
|
refspecs,
|
|
1279
|
+
// clone maps what wanted_peer_refs finds: its own refspecs never die on a source the
|
|
1280
|
+
// remote lacks (an unborn HEAD's branch); the configured ones are checked above
|
|
1281
|
+
missingRefsOk: true,
|
|
1236
1282
|
tags,
|
|
1237
1283
|
depth,
|
|
1238
1284
|
deepenSince: shallowSince,
|
|
@@ -1254,6 +1300,8 @@ export class CloneCommand extends TransportCommand<CloneResult> {
|
|
|
1254
1300
|
onWarning: (line: string) => messages.push(`${line}\n`),
|
|
1255
1301
|
// the server's promisor-remote capability (promisor.acceptFromServer, storeFields)
|
|
1256
1302
|
promisorRemote: promisorRemoteReplyOf(this.workingCopy, (line) => messages.push(`${line}\n`)),
|
|
1303
|
+
// --filter=auto: the accepted promisor remotes' advertised filter
|
|
1304
|
+
autoFilter: () => promisorAutoFilter(this.workingCopy, (line) => messages.push(`${line}\n`)),
|
|
1257
1305
|
...(fsck ? { fsckObjects: fsck } : {}),
|
|
1258
1306
|
...(serverOptions.length > 0 ? { serverOptions } : {}),
|
|
1259
1307
|
...(rejectShallow ? { rejectShallow: true } : {}),
|
|
@@ -1341,7 +1389,7 @@ export class CloneCommand extends TransportCommand<CloneResult> {
|
|
|
1341
1389
|
(r) =>
|
|
1342
1390
|
r.name.startsWith("refs/heads/") && cloned.has(r.name) && r.oid === remoteHeadRef.oid,
|
|
1343
1391
|
);
|
|
1344
|
-
const preferred = (await defaultInitialBranch(
|
|
1392
|
+
const preferred = (await this.defaultInitialBranch()).name;
|
|
1345
1393
|
advertisedDefaultBranch = (
|
|
1346
1394
|
branches.find((r) => r.name === `refs/heads/${preferred}`) ??
|
|
1347
1395
|
branches.find((r) => r.name === "refs/heads/master") ??
|
|
@@ -1349,15 +1397,18 @@ export class CloneCommand extends TransportCommand<CloneResult> {
|
|
|
1349
1397
|
)?.name;
|
|
1350
1398
|
}
|
|
1351
1399
|
let defaultBranch = branchToClone ?? toBranchName(advertisedDefaultBranch);
|
|
1400
|
+
// the remote HEAD names a branch it does not have (ls-refs' `unborn`)
|
|
1401
|
+
const unbornHead =
|
|
1402
|
+
remoteHeadRef !== undefined &&
|
|
1403
|
+
remoteHeadRef.oid === undefined &&
|
|
1404
|
+
remoteHeadRef.symref !== undefined;
|
|
1352
1405
|
let headCommit: ObjectId | undefined;
|
|
1353
1406
|
let checkedOutBranch: string | undefined;
|
|
1354
1407
|
// the commit to check out once refs and configuration are in place (git: last)
|
|
1355
1408
|
let checkoutId: ObjectId | undefined;
|
|
1356
1409
|
// an empty remote without unborn HEAD: git's default branch (the one init named)
|
|
1357
1410
|
if (!detachedTag && !this.bare && defaultBranch === undefined && result.isEmpty) {
|
|
1358
|
-
defaultBranch =
|
|
1359
|
-
(await this.localHeadBranch()) ??
|
|
1360
|
-
(await defaultInitialBranch(hostEnvironmentOf(this._workingCopy))).name;
|
|
1411
|
+
defaultBranch = (await this.localHeadBranch()) ?? (await this.defaultInitialBranch()).name;
|
|
1361
1412
|
}
|
|
1362
1413
|
|
|
1363
1414
|
// git's update_remote_refs (before update_head): refs/remotes/<name>/HEAD names the tracking ref of the
|
|
@@ -1428,8 +1479,9 @@ export class CloneCommand extends TransportCommand<CloneResult> {
|
|
|
1428
1479
|
headCommit = tip.objectId;
|
|
1429
1480
|
if (!this.noCheckout) checkoutId = tip.objectId;
|
|
1430
1481
|
}
|
|
1431
|
-
// git's install_branch_config: the branch tracks its remote counterpart
|
|
1432
|
-
|
|
1482
|
+
// git's install_branch_config: the branch tracks its remote counterpart, also when the
|
|
1483
|
+
// remote's HEAD is unborn (v2's unborn_head_target), refs or not
|
|
1484
|
+
if (tip?.objectId || result.isEmpty || unbornHead) checkedOutBranch = defaultBranch;
|
|
1433
1485
|
} else if (this.bare || this.mirror) {
|
|
1434
1486
|
// For bare/mirror repos, HEAD points to default branch
|
|
1435
1487
|
if (defaultBranch) {
|
|
@@ -1445,7 +1497,9 @@ export class CloneCommand extends TransportCommand<CloneResult> {
|
|
|
1445
1497
|
detachedTag,
|
|
1446
1498
|
remoteHead,
|
|
1447
1499
|
checkedOutBranch,
|
|
1448
|
-
|
|
1500
|
+
// a single-branch clone of an unborn HEAD maps no ref (wanted_peer_refs): git's empty
|
|
1501
|
+
// clone, without a fetch refspec
|
|
1502
|
+
isEmpty: result.isEmpty || (singleBranch && unbornHead && branchToClone === undefined),
|
|
1449
1503
|
revision: this.revision !== undefined,
|
|
1450
1504
|
});
|
|
1451
1505
|
|
|
@@ -1469,9 +1523,7 @@ export class CloneCommand extends TransportCommand<CloneResult> {
|
|
|
1469
1523
|
fetchResult,
|
|
1470
1524
|
// as the empty-remote case above: the local HEAD's branch, else git's default
|
|
1471
1525
|
defaultBranch:
|
|
1472
|
-
defaultBranch ??
|
|
1473
|
-
(await this.localHeadBranch()) ??
|
|
1474
|
-
(await defaultInitialBranch(hostEnvironmentOf(this._workingCopy))).name,
|
|
1526
|
+
defaultBranch ?? (await this.localHeadBranch()) ?? (await this.defaultInitialBranch()).name,
|
|
1475
1527
|
remoteName: this.remoteName,
|
|
1476
1528
|
bare: this.bare,
|
|
1477
1529
|
headCommit,
|
|
@@ -1496,11 +1548,20 @@ export class CloneCommand extends TransportCommand<CloneResult> {
|
|
|
1496
1548
|
if (this.dissociate) await history.objects?.alternates?.dissociate?.();
|
|
1497
1549
|
|
|
1498
1550
|
if (checkoutId) {
|
|
1551
|
+
// what the checkout's lazy fetches print (git's child `git fetch` shares its stderr)
|
|
1552
|
+
const promisorWarnings = promisorOf(this._workingCopy)?.warnings;
|
|
1553
|
+
const warned = promisorWarnings?.length ?? 0;
|
|
1499
1554
|
try {
|
|
1500
1555
|
const collided = await this.checkoutHead(checkoutId);
|
|
1501
1556
|
if (collided.length > 0) cloneResult.collidedPaths = collided;
|
|
1502
1557
|
} catch (error) {
|
|
1503
1558
|
throw new CloneCheckoutError(cloneResult, error);
|
|
1559
|
+
} finally {
|
|
1560
|
+
const lines = promisorWarnings?.slice(warned) ?? [];
|
|
1561
|
+
if (lines.length > 0) {
|
|
1562
|
+
messages.push(...lines.map((line) => `${line}\n`));
|
|
1563
|
+
if (cloneResult.messages === undefined) cloneResult.messages = messages;
|
|
1564
|
+
}
|
|
1504
1565
|
}
|
|
1505
1566
|
// checkout()'s post-checkout hook: from no commit to the one checked out, a branch
|
|
1506
1567
|
// switch; its exit code becomes the clone's exit status
|
|
@@ -1547,6 +1608,9 @@ export class CloneCommand extends TransportCommand<CloneResult> {
|
|
|
1547
1608
|
remoteUrl,
|
|
1548
1609
|
compatibility,
|
|
1549
1610
|
message,
|
|
1611
|
+
...(this.bundleUri !== undefined && this.bundleObjectFormat
|
|
1612
|
+
? { objectFormat: this.bundleObjectFormat }
|
|
1613
|
+
: {}),
|
|
1550
1614
|
setConfigValue: (key, value) => this.writeConfigValue(key, value, "add"),
|
|
1551
1615
|
// odb_mkstemp's `<objects>/bundles/tmp_uri_XXXXXX`, as git's errors name the list
|
|
1552
1616
|
tempFileName: () =>
|
|
@@ -1960,6 +2024,20 @@ export class CloneCommand extends TransportCommand<CloneResult> {
|
|
|
1960
2024
|
if (this.filterSpec !== undefined) promisorOf(this._workingCopy)?.fetcher?.invalidate?.();
|
|
1961
2025
|
}
|
|
1962
2026
|
|
|
2027
|
+
/**
|
|
2028
|
+
* git's `repo_default_branch_name` in the new repository: its whole configuration
|
|
2029
|
+
* (`includeIf "gitdir:"` matching its git directory), as the working copy's config reads it
|
|
2030
|
+
* when that is the user's chain (it has the environment); else the protected configuration.
|
|
2031
|
+
*/
|
|
2032
|
+
private defaultInitialBranch(): Promise<DefaultBranch> {
|
|
2033
|
+
const config = this._workingCopy.config as Partial<NewRepositoryConfig> | undefined;
|
|
2034
|
+
const environment = hostEnvironmentOf(this._workingCopy);
|
|
2035
|
+
return defaultInitialBranch(
|
|
2036
|
+
environment,
|
|
2037
|
+
environment && config?.listWithOrigin ? (config as NewRepositoryConfig) : undefined,
|
|
2038
|
+
);
|
|
2039
|
+
}
|
|
2040
|
+
|
|
1963
2041
|
/** The branch the local HEAD names (`init.defaultBranch` of the new repository), if any. */
|
|
1964
2042
|
private async localHeadBranch(): Promise<string | undefined> {
|
|
1965
2043
|
const head = await this.refsStore.get("HEAD");
|
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
type WorktreeEntry,
|
|
19
19
|
} from "@statewalker/vcs-working-tree";
|
|
20
20
|
import {
|
|
21
|
+
EMPTY_AMEND_ADVICE,
|
|
21
22
|
EmptyCommitError,
|
|
22
23
|
GitApiError,
|
|
23
24
|
HookFailedError,
|
|
@@ -66,6 +67,7 @@ import { reencodedCommitParts } from "./log-output.js";
|
|
|
66
67
|
import {
|
|
67
68
|
flatTree,
|
|
68
69
|
OperationState,
|
|
70
|
+
peelMergeHeads,
|
|
69
71
|
rewriteIndex,
|
|
70
72
|
updateIndexCacheTree,
|
|
71
73
|
writeIndexAsTree,
|
|
@@ -1076,7 +1078,7 @@ export class CommitCommand extends GitCommand<CommitResult> {
|
|
|
1076
1078
|
template = await this.withTrailers(template, state, comment);
|
|
1077
1079
|
const isMerge = (ctx.previousCommit?.parents.length ?? 0) > 1;
|
|
1078
1080
|
if (!committable && whence !== "merge" && !this.allowEmpty && !(this.amend && isMerge)) {
|
|
1079
|
-
throw
|
|
1081
|
+
throw await this.emptyCommitError(ctx.partialTree, whence);
|
|
1080
1082
|
}
|
|
1081
1083
|
// prepare-commit-msg, the editor over what it left, then commit-msg
|
|
1082
1084
|
let text = "";
|
|
@@ -2147,7 +2149,7 @@ export class CommitCommand extends GitCommand<CommitResult> {
|
|
|
2147
2149
|
await state.write("COMMIT_EDITMSG", sb);
|
|
2148
2150
|
// amend_file_with_trailers over COMMIT_EDITMSG
|
|
2149
2151
|
sb = await this.withTrailers(sb, state, undefined);
|
|
2150
|
-
await this.refuseNothingToCommit(treeId, parents, mergeHeads, previousCommit);
|
|
2152
|
+
await this.refuseNothingToCommit(treeId, parents, mergeHeads, previousCommit, partialTree);
|
|
2151
2153
|
// prepare-commit-msg and commit-msg, which may rewrite COMMIT_EDITMSG: the commit
|
|
2152
2154
|
// takes the file's text (cmd_commit reads it back)
|
|
2153
2155
|
// (git's hook arguments: read only when hooks can run)
|
|
@@ -2218,18 +2220,47 @@ export class CommitCommand extends GitCommand<CommitResult> {
|
|
|
2218
2220
|
parents: ObjectId[],
|
|
2219
2221
|
mergeHeads: ObjectId[],
|
|
2220
2222
|
previousCommit: Commit | undefined,
|
|
2223
|
+
partialTree: ObjectId | undefined,
|
|
2221
2224
|
): Promise<void> {
|
|
2222
2225
|
if (this.allowEmpty || mergeHeads.length > 0) return;
|
|
2223
2226
|
if (parents.length === 0) {
|
|
2224
2227
|
// no first parent (an initial commit, or --amend of a root commit): git counts the
|
|
2225
2228
|
// index, `cache_nr - ita_nr > 0`; only intent-to-add entries (or none) leave the tree
|
|
2226
2229
|
// empty
|
|
2227
|
-
if (treeId === this.objectFormat.emptyTreeId) throw
|
|
2230
|
+
if (treeId === this.objectFormat.emptyTreeId) throw await this.emptyCommitError(partialTree);
|
|
2228
2231
|
return;
|
|
2229
2232
|
}
|
|
2230
2233
|
if (this.amend && (previousCommit?.parents.length ?? 0) > 1) return;
|
|
2231
2234
|
const parentCommit = await this.commits.load(parents[0] as ObjectId);
|
|
2232
|
-
if (parentCommit && parentCommit.tree === treeId)
|
|
2235
|
+
if (parentCommit && parentCommit.tree === treeId) {
|
|
2236
|
+
throw await this.emptyCommitError(partialTree);
|
|
2237
|
+
}
|
|
2238
|
+
}
|
|
2239
|
+
|
|
2240
|
+
/**
|
|
2241
|
+
* prepare_to_commit's refusal of an empty commit: run_status on stdout (the status of the
|
|
2242
|
+
* index the commit would record, against HEAD^1 when amending: `git commit --dry-run`'s
|
|
2243
|
+
* text), then `empty_amend_advice` on stderr when amending; exit status 1, nothing written.
|
|
2244
|
+
*/
|
|
2245
|
+
private async emptyCommitError(
|
|
2246
|
+
partialTree: ObjectId | undefined,
|
|
2247
|
+
whence?: CommitWhence,
|
|
2248
|
+
): Promise<EmptyCommitError> {
|
|
2249
|
+
const run = () =>
|
|
2250
|
+
this.commitStatus({
|
|
2251
|
+
format: "long",
|
|
2252
|
+
...(this.showBranch !== undefined ? { branch: this.showBranch } : {}),
|
|
2253
|
+
...(this.aheadBehind !== undefined ? { aheadBehind: this.aheadBehind } : {}),
|
|
2254
|
+
verbose: this.verboseLevel(),
|
|
2255
|
+
commitTemplate: true,
|
|
2256
|
+
amend: this.amend,
|
|
2257
|
+
...(whence ? { whence } : {}),
|
|
2258
|
+
});
|
|
2259
|
+
const status = partialTree ? await this.withIndexOfTree(partialTree, run) : await run();
|
|
2260
|
+
return new EmptyCommitError(undefined, {
|
|
2261
|
+
stdout: status.text,
|
|
2262
|
+
stderr: this.amend ? EMPTY_AMEND_ADVICE : "",
|
|
2263
|
+
});
|
|
2233
2264
|
}
|
|
2234
2265
|
|
|
2235
2266
|
/** The commit of `treeId` made, HEAD moved to it, and what was in progress ended. */
|
|
@@ -2426,17 +2457,21 @@ export class CommitCommand extends GitCommand<CommitResult> {
|
|
|
2426
2457
|
return ran;
|
|
2427
2458
|
}
|
|
2428
2459
|
|
|
2429
|
-
/**
|
|
2460
|
+
/**
|
|
2461
|
+
* The commits MERGE_HEAD names (one per line, a merged tag peeled as git's
|
|
2462
|
+
* `lookup_commit_reference`), none without a merge in progress.
|
|
2463
|
+
*/
|
|
2430
2464
|
private async mergeHeads(state: OperationState): Promise<ObjectId[]> {
|
|
2431
2465
|
const text = await state.read("MERGE_HEAD");
|
|
2432
2466
|
if (text !== undefined) {
|
|
2433
|
-
|
|
2467
|
+
const ids = text
|
|
2434
2468
|
.split("\n")
|
|
2435
2469
|
.map((l) => l.trim())
|
|
2436
2470
|
.filter((l) => /^[0-9a-f]{40,64}$/.test(l));
|
|
2471
|
+
return peelMergeHeads(this.revisionResolver(), ids);
|
|
2437
2472
|
}
|
|
2438
2473
|
const id = await state.ref("MERGE_HEAD");
|
|
2439
|
-
return id ? [id] : [];
|
|
2474
|
+
return id ? peelMergeHeads(this.revisionResolver(), [id]) : [];
|
|
2440
2475
|
}
|
|
2441
2476
|
|
|
2442
2477
|
/** The heads none of the others reaches (git's reduce_heads), in their order. */
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The initial branch of a new repository, as git's `repo_default_branch_name` (refs.c) picks
|
|
3
|
-
* it: `init.defaultBranch` from the configuration
|
|
4
|
-
*
|
|
3
|
+
* it: `init.defaultBranch` from the configuration the new repository sees (system, global, its
|
|
4
|
+
* own config with what a template brought in, the command line; `includeIf "gitdir:..."`
|
|
5
|
+
* matched against the new repository's git directory), else `master`, or `main` in a git built with `WITH_BREAKING_CHANGES`
|
|
5
6
|
* (`GitHostEnvironment.breakingChanges`, git 3.0). With no name configured, git explains the
|
|
6
7
|
* default in an `advice.defaultBranchName` hint, which {@link DefaultBranch.hint} holds.
|
|
7
8
|
*
|
|
@@ -68,16 +69,29 @@ export function isValidBranchName(name: string): boolean {
|
|
|
68
69
|
}
|
|
69
70
|
|
|
70
71
|
/**
|
|
71
|
-
* The
|
|
72
|
-
*
|
|
72
|
+
* The configuration of the new repository, as git's `repo_config_get_string` reads it once
|
|
73
|
+
* `create_repository` made it: a loaded `GitWorkingCopyConfig` of its git directory (its
|
|
74
|
+
* values with their origins, in git's order).
|
|
75
|
+
*/
|
|
76
|
+
export interface NewRepositoryConfig {
|
|
77
|
+
listWithOrigin(): { key: string; text: string | undefined; file?: string; line?: number }[];
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* The initial branch of a repository created now, from `config` (the new repository's, see
|
|
82
|
+
* {@link NewRepositoryConfig}); without one, from the protected configuration (system,
|
|
83
|
+
* global, command line, `gitdir:` conditions false). Without either, nothing is configured.
|
|
73
84
|
*
|
|
74
85
|
* @throws InvalidDefaultBranchError when `init.defaultBranch` names no valid branch (empty too)
|
|
75
86
|
* @throws MissingDefaultBranchValueError when `init.defaultBranch` has no value
|
|
76
87
|
*/
|
|
77
88
|
export async function defaultInitialBranch(
|
|
78
89
|
environment: GitHostEnvironment | undefined,
|
|
90
|
+
repositoryConfig?: NewRepositoryConfig,
|
|
79
91
|
): Promise<DefaultBranch> {
|
|
80
|
-
const config =
|
|
92
|
+
const config = repositoryConfig
|
|
93
|
+
? repositoryConfig.listWithOrigin().map((e) => ({ ...e, value: e.text }))
|
|
94
|
+
: await readProtectedConfig(environment);
|
|
81
95
|
const last = (key: string) => config.filter((e) => e.key === key).at(-1);
|
|
82
96
|
const configured = last("init.defaultbranch");
|
|
83
97
|
if (configured && configured.value === undefined) {
|
|
@@ -65,7 +65,11 @@ import {
|
|
|
65
65
|
promisorRemotes,
|
|
66
66
|
registerPartialClone,
|
|
67
67
|
} from "./promisor-remote.js";
|
|
68
|
-
import {
|
|
68
|
+
import {
|
|
69
|
+
promisorAutoFilter,
|
|
70
|
+
promisorRemoteReplyOf,
|
|
71
|
+
resetPromisorAcceptance,
|
|
72
|
+
} from "./promisor-remote-reply.js";
|
|
69
73
|
import { withRemoteUploadPack } from "./remote-transport.js";
|
|
70
74
|
import { clientSessionIdOf } from "./session-id.js";
|
|
71
75
|
import {
|
|
@@ -441,7 +445,8 @@ export class FetchCommand extends TransportCommand<FetchResult> {
|
|
|
441
445
|
* (git's fetch_one_setup_partial); a filter given registers the remote as a promisor remote
|
|
442
446
|
* first when it is not one with a filter (partial_clone_register:
|
|
443
447
|
* `core.repositoryformatversion = 1`, `remote.<name>.promisor`, `.partialclonefilter`). A
|
|
444
|
-
* pack fetched under a filter is kept as a promisor pack.
|
|
448
|
+
* pack fetched under a filter is kept as a promisor pack. `auto` (git 2.54) is the filter
|
|
449
|
+
* the promisor remotes accepted from the server's `promisor-remote` capability advertise.
|
|
445
450
|
*/
|
|
446
451
|
setFilter(spec: string | false): this {
|
|
447
452
|
this.checkCallable();
|
|
@@ -1023,6 +1028,8 @@ export class FetchCommand extends TransportCommand<FetchResult> {
|
|
|
1023
1028
|
const negotiationTips =
|
|
1024
1029
|
tipsGiven.length > 0 ? await this.resolveNegotiationTips(messages, tipsGiven) : undefined;
|
|
1025
1030
|
const unpackLimit = unpackLimitOf({ getAll: (key) => store.values(key) }, "fetch");
|
|
1031
|
+
// a new git process: no promisor remote accepted yet (--filter=auto, lazy-fetch order)
|
|
1032
|
+
resetPromisorAcceptance(this.workingCopy);
|
|
1026
1033
|
const fetchOptions: TransportFetchOptions = {
|
|
1027
1034
|
...(sessionId !== undefined ? { sessionId } : {}),
|
|
1028
1035
|
// fetch.uriProtocols: the packs a v2 server offloads to packfile URIs
|
|
@@ -1070,6 +1077,8 @@ export class FetchCommand extends TransportCommand<FetchResult> {
|
|
|
1070
1077
|
atomic: this.atomic || undefined,
|
|
1071
1078
|
// git 2.5x writes a fetch's refs in one transaction that refuses each on its own
|
|
1072
1079
|
...(compatibility !== "2.43" ? { batchNonAtomic: true } : {}),
|
|
1080
|
+
// do_fetch commits its transaction even with no update: 2.5x always, 2.43 with --atomic
|
|
1081
|
+
...(compatibility !== "2.43" || this.atomic ? { emptyTransaction: true } : {}),
|
|
1073
1082
|
dryRun: this.dryRun,
|
|
1074
1083
|
onProgress: this.progressMessageCallback,
|
|
1075
1084
|
// index-pack's "Receiving objects" and "Resolving deltas"
|
|
@@ -1110,6 +1119,8 @@ export class FetchCommand extends TransportCommand<FetchResult> {
|
|
|
1110
1119
|
onWarning: (line: string) => messages.push(line),
|
|
1111
1120
|
// the server's promisor-remote capability (promisor.acceptFromServer, storeFields)
|
|
1112
1121
|
promisorRemote: promisorRemoteReplyOf(this.workingCopy, (line) => messages.push(line)),
|
|
1122
|
+
// --filter=auto (or a recorded `auto`): the accepted promisor remotes' advertised filter
|
|
1123
|
+
autoFilter: () => promisorAutoFilter(this.workingCopy, (line) => messages.push(line)),
|
|
1113
1124
|
};
|
|
1114
1125
|
// --upload-pack, else remote.<name>.uploadpack (transport_get)
|
|
1115
1126
|
const uploadPack = this.uploadPack ?? this.remoteProgram(this.remote, "uploadpack");
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
isNtfsGitWorktreeFile,
|
|
16
16
|
isValidRefName,
|
|
17
17
|
} from "@statewalker/vcs-core";
|
|
18
|
+
import { decodeGitPath } from "@statewalker/vcs-utils/encoding";
|
|
18
19
|
import { bytesToHex } from "@statewalker/vcs-utils/hash/utils";
|
|
19
20
|
|
|
20
21
|
import type { FsckMessageTypes, FsckMsgId } from "./fsck-msg-ids.js";
|
|
@@ -648,7 +649,8 @@ export function fsckTree(
|
|
|
648
649
|
}
|
|
649
650
|
if (!plain) {
|
|
650
651
|
const entryId = () => bytesToHex(buf.subarray(idAt, idAt + raw));
|
|
651
|
-
|
|
652
|
+
// git's bytes: a byte outside valid UTF-8 kept as an escape (is_hfs_dotgit reads it)
|
|
653
|
+
const text = decodeGitPath(buf.subarray(start, end));
|
|
652
654
|
hasDot ||= text === ".";
|
|
653
655
|
hasDotdot ||= text === "..";
|
|
654
656
|
hasDotgit ||= isDotGitComponent(text);
|
|
@@ -22,7 +22,12 @@
|
|
|
22
22
|
|
|
23
23
|
import type { RefTransactionHook } from "@statewalker/vcs-core";
|
|
24
24
|
import { parseGitBool } from "@statewalker/vcs-utils";
|
|
25
|
-
import {
|
|
25
|
+
import {
|
|
26
|
+
type FilesApi,
|
|
27
|
+
sharedRepositoryOf,
|
|
28
|
+
withReadOnlyObjectFiles,
|
|
29
|
+
withSharedPerm,
|
|
30
|
+
} from "@statewalker/vcs-utils/files";
|
|
26
31
|
import {
|
|
27
32
|
expandUserPath,
|
|
28
33
|
type GitHostEnvironment,
|
|
@@ -989,9 +994,9 @@ export class HookSession {
|
|
|
989
994
|
}
|
|
990
995
|
|
|
991
996
|
/**
|
|
992
|
-
* The repository's FilesApi for writes in its git directories
|
|
993
|
-
*
|
|
994
|
-
*
|
|
997
|
+
* The repository's FilesApi for writes in its git directories, wrapped as the files
|
|
998
|
+
* backend's own FilesApi is: under `core.sharedRepository` what is created there gets git's
|
|
999
|
+
* modes (`adjust_shared_perm`), otherwise the object files git keeps read-only are 0444.
|
|
995
1000
|
*/
|
|
996
1001
|
private async repositoryFiles(layout: HookLayout): Promise<FilesApi> {
|
|
997
1002
|
let shared = 0;
|
|
@@ -1000,8 +1005,9 @@ export class HookSession {
|
|
|
1000
1005
|
} catch {
|
|
1001
1006
|
shared = 0;
|
|
1002
1007
|
}
|
|
1003
|
-
if (!shared) return layout.files;
|
|
1004
1008
|
const common = await commonDirOf(layout.files, layout.gitDir);
|
|
1009
|
+
// unshared, git still creates loose objects and pack-family files 0444 (umask applied)
|
|
1010
|
+
if (!shared) return withReadOnlyObjectFiles(layout.files, joinFilesPath(common, "objects"));
|
|
1005
1011
|
return withSharedPerm(layout.files, () => shared, common);
|
|
1006
1012
|
}
|
|
1007
1013
|
|