@statewalker/vcs-commands 0.6.0 → 0.7.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/apply/apply-command.d.ts.map +1 -1
- package/dist/commands/apply/apply-engine.d.ts.map +1 -1
- package/dist/commands/apply/apply-parse.d.ts.map +1 -1
- package/dist/commands/bisect/bisect-engine.d.ts.map +1 -1
- package/dist/commands/clone-command.d.ts +17 -0
- package/dist/commands/clone-command.d.ts.map +1 -1
- package/dist/commands/comment-char-config.d.ts +35 -0
- package/dist/commands/comment-char-config.d.ts.map +1 -0
- package/dist/commands/commit-command.d.ts.map +1 -1
- package/dist/commands/core-config.d.ts.map +1 -1
- package/dist/commands/default-branch.d.ts +70 -0
- package/dist/commands/default-branch.d.ts.map +1 -0
- package/dist/commands/diff-command.d.ts.map +1 -1
- package/dist/commands/fetch-command.d.ts.map +1 -1
- package/dist/commands/format-patch-command.d.ts.map +1 -1
- package/dist/commands/fsck/fsck-command.d.ts +2 -0
- package/dist/commands/fsck/fsck-command.d.ts.map +1 -1
- package/dist/commands/fsck/fsck-loose.d.ts +3 -0
- package/dist/commands/fsck/fsck-loose.d.ts.map +1 -1
- package/dist/commands/fsck/fsck-object-checks.d.ts +25 -14
- package/dist/commands/fsck/fsck-object-checks.d.ts.map +1 -1
- package/dist/commands/fsck/fsck-object-table.d.ts +15 -7
- package/dist/commands/fsck/fsck-object-table.d.ts.map +1 -1
- package/dist/commands/fsck/fsck-pack.d.ts +11 -4
- package/dist/commands/fsck/fsck-pack.d.ts.map +1 -1
- package/dist/commands/fsck/verify-pack-command.d.ts.map +1 -1
- package/dist/commands/gc-command.d.ts +72 -48
- package/dist/commands/gc-command.d.ts.map +1 -1
- package/dist/commands/git-date.d.ts +1 -65
- package/dist/commands/git-date.d.ts.map +1 -1
- package/dist/commands/git-hooks.d.ts +8 -0
- package/dist/commands/git-hooks.d.ts.map +1 -1
- package/dist/commands/index-adder.d.ts +2 -0
- package/dist/commands/index-adder.d.ts.map +1 -1
- package/dist/commands/index.d.ts +2 -0
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +3 -3
- package/dist/commands/init-command.d.ts +50 -3
- package/dist/commands/init-command.d.ts.map +1 -1
- package/dist/commands/legacy-remotes.d.ts +55 -0
- package/dist/commands/legacy-remotes.d.ts.map +1 -0
- package/dist/commands/log-command.d.ts.map +1 -1
- package/dist/commands/ls-remote-command.d.ts.map +1 -1
- package/dist/commands/merge-command.d.ts +12 -0
- package/dist/commands/merge-command.d.ts.map +1 -1
- package/dist/commands/merge-support.d.ts +11 -3
- package/dist/commands/merge-support.d.ts.map +1 -1
- package/dist/commands/notes-merge-command.d.ts.map +1 -1
- package/dist/commands/notes-tree.d.ts +11 -1
- package/dist/commands/notes-tree.d.ts.map +1 -1
- package/dist/commands/patch-id.d.ts +3 -0
- package/dist/commands/patch-id.d.ts.map +1 -1
- package/dist/commands/pretty-format.d.ts.map +1 -1
- package/dist/commands/pull-command.d.ts +18 -0
- package/dist/commands/pull-command.d.ts.map +1 -1
- package/dist/commands/push-command.d.ts.map +1 -1
- package/dist/commands/read-tree-command.d.ts.map +1 -1
- package/dist/commands/rebase-command.d.ts.map +1 -1
- package/dist/commands/remote-command.d.ts.map +1 -1
- package/dist/commands/reset-command.d.ts.map +1 -1
- package/dist/commands/rev-parse-command.d.ts +9 -0
- package/dist/commands/rev-parse-command.d.ts.map +1 -1
- package/dist/commands/revision-resolver.d.ts +6 -2
- package/dist/commands/revision-resolver.d.ts.map +1 -1
- package/dist/commands/sequencer-pick.d.ts +1 -1
- package/dist/commands/sequencer-pick.d.ts.map +1 -1
- package/dist/commands/sequencer-support.d.ts.map +1 -1
- package/dist/commands/stash-create-command.d.ts +1 -1
- package/dist/commands/stash-create-command.d.ts.map +1 -1
- package/dist/commands/status-command.d.ts.map +1 -1
- package/dist/commands/submodule-summary-command.d.ts.map +1 -1
- package/dist/commands/untracked-cache-support.d.ts +2 -1
- package/dist/commands/untracked-cache-support.d.ts.map +1 -1
- package/dist/commands/worktree-list-command.d.ts.map +1 -1
- package/dist/{commands-DnmlfwGV.js → commands-DIJ91NnD.js} +1111 -506
- package/dist/{git-command-DxvwPrPB.js → git-command-BGiOJ8Zk.js} +630 -996
- package/dist/git-command.d.ts +16 -1
- package/dist/git-command.d.ts.map +1 -1
- package/dist/git.d.ts +9 -2
- package/dist/git.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/remote-config/index.d.ts +1 -1
- package/dist/remote-config/index.d.ts.map +1 -1
- package/dist/remote-config/remote-config-store.d.ts +62 -3
- package/dist/remote-config/remote-config-store.d.ts.map +1 -1
- package/dist/rename/detect-renames.d.ts.map +1 -1
- package/dist/results/clone-result.d.ts +8 -0
- package/dist/results/clone-result.d.ts.map +1 -1
- package/dist/results/diff-output.d.ts.map +1 -1
- package/dist/results/index.js +1 -1
- package/dist/results/init-result.d.ts +7 -0
- package/dist/results/init-result.d.ts.map +1 -1
- package/dist/results/pull-result.d.ts +5 -0
- package/dist/results/pull-result.d.ts.map +1 -1
- package/dist/results/push-result.d.ts +5 -0
- package/dist/results/push-result.d.ts.map +1 -1
- package/dist/results/status-result.d.ts.map +1 -1
- package/dist/{results-BZGa2Z3I.js → results-WVlBhVb1.js} +11 -10
- package/package.json +12 -12
- package/src/commands/add-patch/add-interactive.ts +3 -3
- package/src/commands/am/am-command.ts +1 -1
- package/src/commands/apply/apply-command.ts +12 -2
- package/src/commands/apply/apply-engine.ts +5 -6
- package/src/commands/apply/apply-parse.ts +3 -2
- package/src/commands/attributes-source.ts +1 -1
- package/src/commands/bisect/bisect-engine.ts +2 -1
- package/src/commands/checkout-command.ts +1 -1
- package/src/commands/clone-command.ts +116 -4
- package/src/commands/comment-char-config.ts +160 -0
- package/src/commands/commit-command.ts +8 -7
- package/src/commands/core-config.ts +7 -2
- package/src/commands/default-branch.ts +196 -0
- package/src/commands/diff-command.ts +45 -27
- package/src/commands/fetch-command.ts +19 -5
- package/src/commands/format-patch-command.ts +7 -2
- package/src/commands/fsck/fsck-command.ts +183 -66
- package/src/commands/fsck/fsck-loose.ts +14 -4
- package/src/commands/fsck/fsck-object-checks.ts +87 -46
- package/src/commands/fsck/fsck-object-table.ts +52 -42
- package/src/commands/fsck/fsck-pack.ts +64 -34
- package/src/commands/fsck/verify-pack-command.ts +5 -2
- package/src/commands/gc-command.ts +208 -107
- package/src/commands/git-date.ts +9 -895
- package/src/commands/git-hooks.ts +11 -0
- package/src/commands/index-adder.ts +8 -3
- package/src/commands/index.ts +2 -0
- package/src/commands/init-command.ts +167 -11
- package/src/commands/legacy-remotes.ts +224 -0
- package/src/commands/log-command.ts +37 -22
- package/src/commands/ls-remote-command.ts +4 -0
- package/src/commands/merge-command.ts +31 -1
- package/src/commands/merge-support.ts +29 -8
- package/src/commands/notes-merge-command.ts +23 -14
- package/src/commands/notes-tree.ts +28 -13
- package/src/commands/octopus-merge.ts +3 -2
- package/src/commands/patch-id.ts +16 -8
- package/src/commands/pretty-format.ts +2 -1
- package/src/commands/pull-command.ts +128 -20
- package/src/commands/push-command.ts +23 -8
- package/src/commands/read-tree-command.ts +6 -2
- package/src/commands/rebase-command.ts +24 -13
- package/src/commands/remote-command.ts +35 -5
- package/src/commands/reset-command.ts +4 -11
- package/src/commands/rev-parse-command.ts +22 -0
- package/src/commands/revision-resolver.ts +32 -14
- package/src/commands/sequencer-pick.ts +7 -2
- package/src/commands/sequencer-support.ts +10 -3
- package/src/commands/stash-apply-command.ts +1 -1
- package/src/commands/stash-create-command.ts +2 -2
- package/src/commands/status-command.ts +2 -4
- package/src/commands/status-header.ts +3 -1
- package/src/commands/submodule-summary-command.ts +6 -7
- package/src/commands/untracked-cache-support.ts +16 -12
- package/src/commands/worktree-list-command.ts +3 -5
- package/src/core-commands/add.command.impl.ts +1 -1
- package/src/git-command.ts +32 -2
- package/src/git.ts +16 -3
- package/src/remote-config/index.ts +2 -0
- package/src/remote-config/remote-config-store.ts +137 -11
- package/src/rename/detect-renames.ts +5 -1
- package/src/results/clone-result.ts +9 -0
- package/src/results/diff-output.ts +9 -7
- package/src/results/init-result.ts +9 -0
- package/src/results/pull-result.ts +5 -0
- package/src/results/push-result.ts +5 -0
- package/src/results/status-result.ts +5 -2
|
@@ -34,6 +34,52 @@ export function defaultFetchRefspec(name: string): string {
|
|
|
34
34
|
return `+refs/heads/*:refs/remotes/${name}/*`;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
/* ------------------------------------------------------- legacy remotes */
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* A remote read from `$GIT_COMMON_DIR/remotes/<name>` or `$GIT_COMMON_DIR/branches/<name>`,
|
|
41
|
+
* as git 2.x's remote.c `read_remotes_file` and `read_branches_file` read them (git 3.0 reads
|
|
42
|
+
* neither). Loaded by `loadLegacyRemote` (vcs-commands `legacy-remotes.ts`) and seen by every
|
|
43
|
+
* {@link RemoteConfigStore} of the working copy while the remote has no `remote.<name>.url`.
|
|
44
|
+
*/
|
|
45
|
+
export interface LegacyRemote {
|
|
46
|
+
/** The file that defined it last (remote.c's `REMOTE_REMOTES` or `REMOTE_BRANCHES`) */
|
|
47
|
+
origin: "remotes" | "branches";
|
|
48
|
+
/** Its URLs as written (`URL:` lines, or the branches file's URL), before `insteadOf` */
|
|
49
|
+
urls: string[];
|
|
50
|
+
/** `Pull:` lines, or the branches file's `refs/heads/<branch>:refs/heads/<name>` */
|
|
51
|
+
fetchRefspecs: string[];
|
|
52
|
+
/** `Push:` lines, or the branches file's `HEAD:refs/heads/<branch>` */
|
|
53
|
+
pushRefspecs: string[];
|
|
54
|
+
/** A branches file's remote follows tags whatever its refspecs (remote.c: `fetch_tags = 1`) */
|
|
55
|
+
followTags: boolean;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** The legacy remotes loaded for each working copy, by name. */
|
|
59
|
+
const legacyRemotes = new WeakMap<object, Map<string, LegacyRemote>>();
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Records (or, with undefined, forgets) the legacy remote `name` of a working copy, for
|
|
63
|
+
* every {@link RemoteConfigStore} of it. `loadLegacyRemote` calls it each time it reads the
|
|
64
|
+
* files, so what the stores see is what the files held at the last load.
|
|
65
|
+
*/
|
|
66
|
+
export function setLegacyRemote(
|
|
67
|
+
workingCopy: WorkingCopy,
|
|
68
|
+
name: string,
|
|
69
|
+
remote: LegacyRemote | undefined,
|
|
70
|
+
): void {
|
|
71
|
+
let byName = legacyRemotes.get(workingCopy);
|
|
72
|
+
if (remote === undefined) {
|
|
73
|
+
byName?.delete(name);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
if (!byName) {
|
|
77
|
+
byName = new Map();
|
|
78
|
+
legacyRemotes.set(workingCopy, byName);
|
|
79
|
+
}
|
|
80
|
+
byName.set(name, remote);
|
|
81
|
+
}
|
|
82
|
+
|
|
37
83
|
/* ------------------------------------------------------- config plumbing */
|
|
38
84
|
|
|
39
85
|
/**
|
|
@@ -215,7 +261,11 @@ class PlainObjectConfig implements GitConfigLike {
|
|
|
215
261
|
* a real remote to `git remote`, and so it is here — it simply has no URL.
|
|
216
262
|
*/
|
|
217
263
|
export class RemoteConfigStore {
|
|
218
|
-
private constructor(
|
|
264
|
+
private constructor(
|
|
265
|
+
private readonly config: GitConfigLike,
|
|
266
|
+
/** The working copy whose legacy remotes ({@link setLegacyRemote}) this store sees */
|
|
267
|
+
private readonly owner?: WorkingCopy,
|
|
268
|
+
) {}
|
|
219
269
|
|
|
220
270
|
/**
|
|
221
271
|
* Wrap a working copy's configuration.
|
|
@@ -225,20 +275,56 @@ export class RemoteConfigStore {
|
|
|
225
275
|
*/
|
|
226
276
|
static from(workingCopy: WorkingCopy): RemoteConfigStore {
|
|
227
277
|
const config = workingCopy.config;
|
|
228
|
-
if (isGitConfigLike(config)) return new RemoteConfigStore(config);
|
|
229
|
-
return new RemoteConfigStore(
|
|
278
|
+
if (isGitConfigLike(config)) return new RemoteConfigStore(config, workingCopy);
|
|
279
|
+
return new RemoteConfigStore(
|
|
280
|
+
new PlainObjectConfig((config ?? {}) as Record<string, unknown>),
|
|
281
|
+
workingCopy,
|
|
282
|
+
);
|
|
230
283
|
}
|
|
231
284
|
|
|
232
|
-
/** Remote names that have a config section. */
|
|
285
|
+
/** Remote names that have a config section (git's `for_each_remote`: no legacy remotes). */
|
|
233
286
|
configuredNames(): string[] {
|
|
234
287
|
return this.config.subsections("remote");
|
|
235
288
|
}
|
|
236
289
|
|
|
237
|
-
/**
|
|
290
|
+
/**
|
|
291
|
+
* Whether the remote is configured (git's `remote_is_configured`): it has a config section,
|
|
292
|
+
* or a legacy remote file loaded for it defines it ({@link legacyOrigin}).
|
|
293
|
+
*/
|
|
238
294
|
isConfigured(name: string): boolean {
|
|
295
|
+
return this.hasSection(name) || this.legacy(name) !== undefined;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/** Whether the remote has a `[remote "<name>"]` config section. */
|
|
299
|
+
hasSection(name: string): boolean {
|
|
239
300
|
return this.configuredNames().includes(name);
|
|
240
301
|
}
|
|
241
302
|
|
|
303
|
+
/**
|
|
304
|
+
* The file a remote was read from when a legacy remote file defines it (`remotes` or
|
|
305
|
+
* `branches`, see {@link LegacyRemote}); undefined for a remote of the configuration.
|
|
306
|
+
*/
|
|
307
|
+
legacyOrigin(name: string): "remotes" | "branches" | undefined {
|
|
308
|
+
return this.legacy(name)?.origin;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/** Whether a fetch from the remote follows tags whatever its refspecs (a branches file). */
|
|
312
|
+
followsTagsAlways(name: string): boolean {
|
|
313
|
+
return this.legacy(name)?.followTags ?? false;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* The legacy remote `name`, while it applies: git reads the files only for a remote the
|
|
318
|
+
* configuration gives no URL (remote.c `remotes_remote_get_1`'s `valid_remote`), and then
|
|
319
|
+
* adds what they say to what the configuration says.
|
|
320
|
+
*/
|
|
321
|
+
private legacy(name: string): LegacyRemote | undefined {
|
|
322
|
+
if (!this.owner) return undefined;
|
|
323
|
+
const remote = legacyRemotes.get(this.owner)?.get(name);
|
|
324
|
+
if (!remote || this.urlList(name, "url").length > 0) return undefined;
|
|
325
|
+
return remote;
|
|
326
|
+
}
|
|
327
|
+
|
|
242
328
|
/**
|
|
243
329
|
* Read a remote, filling in the default fetch refspec when none is
|
|
244
330
|
* configured, exactly as `git remote -v` reports one: its URLs as remote.c's
|
|
@@ -248,22 +334,30 @@ export class RemoteConfigStore {
|
|
|
248
334
|
* when none applies: the fetch URLs are pushed to).
|
|
249
335
|
*/
|
|
250
336
|
read(name: string): RemoteConfig {
|
|
251
|
-
const fetchRefspecs = this.
|
|
337
|
+
const fetchRefspecs = this.configuredFetchRefspecs(name);
|
|
338
|
+
// a legacy remote has no default: remote.c reads only what its file says
|
|
339
|
+
const fallback = this.legacy(name) ? [] : [defaultFetchRefspec(name)];
|
|
252
340
|
return {
|
|
253
341
|
name,
|
|
254
342
|
urls: this.remoteUrls(name),
|
|
255
343
|
pushUrls: this.aliasedPushUrls(name),
|
|
256
|
-
fetchRefspecs: fetchRefspecs.length > 0 ? fetchRefspecs :
|
|
257
|
-
pushRefspecs: this.
|
|
344
|
+
fetchRefspecs: fetchRefspecs.length > 0 ? fetchRefspecs : fallback,
|
|
345
|
+
pushRefspecs: this.pushRefspecs(name),
|
|
258
346
|
};
|
|
259
347
|
}
|
|
260
348
|
|
|
261
349
|
/**
|
|
262
350
|
* The `remote.<name>.fetch` lines as configured, without the default {@link read} fills
|
|
263
|
-
* in: a remote without any fetches only its HEAD, as `git fetch <name>` does.
|
|
351
|
+
* in: a remote without any fetches only its HEAD, as `git fetch <name>` does. A legacy
|
|
352
|
+
* remote's refspecs ({@link LegacyRemote}) follow the configuration's.
|
|
264
353
|
*/
|
|
265
354
|
configuredFetchRefspecs(name: string): string[] {
|
|
266
|
-
return this.strings(name, "fetch");
|
|
355
|
+
return [...this.strings(name, "fetch"), ...(this.legacy(name)?.fetchRefspecs ?? [])];
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
/** The `remote.<name>.push` lines, then a legacy remote's push refspecs. */
|
|
359
|
+
pushRefspecs(name: string): string[] {
|
|
360
|
+
return [...this.strings(name, "push"), ...(this.legacy(name)?.pushRefspecs ?? [])];
|
|
267
361
|
}
|
|
268
362
|
|
|
269
363
|
/** Write every field of a remote, replacing whatever was there. */
|
|
@@ -423,7 +517,13 @@ export class RemoteConfigStore {
|
|
|
423
517
|
* clears those before it: git's `add_url`), each rewritten by `url.<base>.insteadOf`.
|
|
424
518
|
*/
|
|
425
519
|
remoteUrls(name: string): string[] {
|
|
426
|
-
return this.
|
|
520
|
+
return this.rawUrls(name).map((url) => this.aliasUrl(url) ?? url);
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
/** The `remote.<name>.url` lines (see {@link urlList}), else a legacy remote's URLs. */
|
|
524
|
+
private rawUrls(name: string): string[] {
|
|
525
|
+
const configured = this.urlList(name, "url");
|
|
526
|
+
return configured.length > 0 ? configured : (this.legacy(name)?.urls ?? []);
|
|
427
527
|
}
|
|
428
528
|
|
|
429
529
|
/**
|
|
@@ -444,6 +544,16 @@ export class RemoteConfigStore {
|
|
|
444
544
|
*/
|
|
445
545
|
private aliasedPushUrls(name: string): string[] {
|
|
446
546
|
const pushUrls = this.urlList(name, "pushurl").map((url) => this.aliasUrl(url) ?? url);
|
|
547
|
+
const legacy = this.legacy(name);
|
|
548
|
+
if (legacy) {
|
|
549
|
+
// add_url_alias: each URL a legacy file gives adds its pushInsteadOf rewrite, whatever
|
|
550
|
+
// pushurl lines the configuration has
|
|
551
|
+
for (const url of legacy.urls) {
|
|
552
|
+
const alias = this.aliasUrl(url, { push: true });
|
|
553
|
+
if (alias !== undefined) pushUrls.push(alias);
|
|
554
|
+
}
|
|
555
|
+
return pushUrls;
|
|
556
|
+
}
|
|
447
557
|
if (pushUrls.length > 0) return pushUrls;
|
|
448
558
|
const aliased: string[] = [];
|
|
449
559
|
for (const url of this.urlList(name, "url")) {
|
|
@@ -543,6 +653,17 @@ export class RemoteConfigStore {
|
|
|
543
653
|
.map((e) => ({ key: e.key, value: e.text }));
|
|
544
654
|
}
|
|
545
655
|
|
|
656
|
+
/**
|
|
657
|
+
* Every value of the variables `keys` (canonical, lower case) in the configuration's order,
|
|
658
|
+
* with where each was read (file, scope; none for the command line); undefined when the
|
|
659
|
+
* config cannot list its variables.
|
|
660
|
+
*/
|
|
661
|
+
entriesWithOriginFor(keys: string[]): (ConfigValueWhere & { key: string })[] | undefined {
|
|
662
|
+
if (!this.config.listWithOrigin) return undefined;
|
|
663
|
+
const wanted = new Set(keys.map((k) => k.toLowerCase()));
|
|
664
|
+
return this.config.listWithOrigin().filter((e) => wanted.has(e.key));
|
|
665
|
+
}
|
|
666
|
+
|
|
546
667
|
/** Every value of a config variable (`branch.main.merge` may repeat). */
|
|
547
668
|
values(key: string): string[] {
|
|
548
669
|
return this.config
|
|
@@ -556,6 +677,11 @@ export class RemoteConfigStore {
|
|
|
556
677
|
this.config.set(key, value);
|
|
557
678
|
}
|
|
558
679
|
|
|
680
|
+
/** Adds a value to a config variable after the ones it has (`git config --add`). */
|
|
681
|
+
addValue(key: string, value: string): void {
|
|
682
|
+
this.config.add(key, value);
|
|
683
|
+
}
|
|
684
|
+
|
|
559
685
|
/** Sets every value of a config variable, in order (none: unset). */
|
|
560
686
|
setValues(key: string, values: string[]): void {
|
|
561
687
|
if (values.length === 0) {
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { EMPTY_BLOB_ID, type ObjectId } from "@statewalker/vcs-core";
|
|
9
|
+
import { SHA256_OBJECT_FORMAT } from "@statewalker/vcs-utils";
|
|
9
10
|
import { compareGitPaths } from "@statewalker/vcs-utils/encoding";
|
|
10
11
|
import {
|
|
11
12
|
estimateSimilarity,
|
|
@@ -303,7 +304,10 @@ export async function detectRenames(
|
|
|
303
304
|
const configured = options.renameLimit ?? DEFAULT_RENAME_LIMIT;
|
|
304
305
|
const renameLimit = configured <= 0 ? MAX_RENAME_LIMIT : configured;
|
|
305
306
|
// merges leave empty files out of rename detection (git's rename_empty = 0)
|
|
306
|
-
|
|
307
|
+
// the empty blob of either object format
|
|
308
|
+
const keep = (c: RenameCandidate) =>
|
|
309
|
+
options.renameEmpty !== false ||
|
|
310
|
+
(c.id !== EMPTY_BLOB_ID && c.id !== SHA256_OBJECT_FORMAT.emptyBlobId);
|
|
307
311
|
// in path order, or as given (a merge: the order its trees were read in)
|
|
308
312
|
const src = options.keepOrder ? sources.filter(keep) : sources.filter(keep).sort(byPath);
|
|
309
313
|
const dst = options.keepOrder
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ObjectId } from "@statewalker/vcs-core";
|
|
2
|
+
import type { WorkingCopy } from "@statewalker/vcs-working-tree";
|
|
2
3
|
|
|
3
4
|
import type { FetchResult } from "./fetch-result.js";
|
|
4
5
|
|
|
@@ -40,4 +41,12 @@ export interface CloneResult {
|
|
|
40
41
|
* alternate for '<path>': <reason>" lines, each with its newline
|
|
41
42
|
*/
|
|
42
43
|
messages?: string[];
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* The repository's working copy when the clone switched it to the remote's object format
|
|
47
|
+
* (git's clone takes the hash the remote names: a SHA-256 remote makes a SHA-256
|
|
48
|
+
* repository): the working copy the command was made for still names objects with the old
|
|
49
|
+
* hash and must not be used any more. `Git.clone()` takes this one as its own.
|
|
50
|
+
*/
|
|
51
|
+
workingCopy?: WorkingCopy;
|
|
43
52
|
}
|
|
@@ -28,6 +28,7 @@ import {
|
|
|
28
28
|
createSha1,
|
|
29
29
|
diffLineCounts,
|
|
30
30
|
type FindFunction,
|
|
31
|
+
nullObjectIdLike,
|
|
31
32
|
type UnifiedDiffOptions,
|
|
32
33
|
type UnifiedDiffResult,
|
|
33
34
|
unifiedDiffHunks,
|
|
@@ -164,7 +165,6 @@ export interface DiffOutputOptions
|
|
|
164
165
|
|
|
165
166
|
const S_IFMT = 0o170000;
|
|
166
167
|
const GITLINK_MODE = 0o160000;
|
|
167
|
-
const NULL_ID = "0".repeat(40);
|
|
168
168
|
const FIRST_FEW_BYTES = 8000;
|
|
169
169
|
const GIT_DIFF_BIG_FILE_THRESHOLD = 512 * 1024 * 1024;
|
|
170
170
|
|
|
@@ -211,6 +211,8 @@ class LoadedSide {
|
|
|
211
211
|
constructor(
|
|
212
212
|
readonly spec: DiffSideSpec | undefined,
|
|
213
213
|
readonly driver: DiffDriver | undefined,
|
|
214
|
+
/** The other side's id: an absent side's null id is as long (64 zeros in SHA-256) */
|
|
215
|
+
private readonly otherId?: string,
|
|
214
216
|
) {}
|
|
215
217
|
|
|
216
218
|
get valid(): boolean {
|
|
@@ -222,7 +224,7 @@ class LoadedSide {
|
|
|
222
224
|
}
|
|
223
225
|
|
|
224
226
|
get id(): string {
|
|
225
|
-
return this.spec?.id ??
|
|
227
|
+
return this.spec?.id ?? nullObjectIdLike(this.otherId);
|
|
226
228
|
}
|
|
227
229
|
|
|
228
230
|
read(): Promise<Uint8Array> {
|
|
@@ -356,7 +358,7 @@ function metainfo(
|
|
|
356
358
|
id.slice(
|
|
357
359
|
0,
|
|
358
360
|
options.fullIndex || fullIndex
|
|
359
|
-
?
|
|
361
|
+
? id.length
|
|
360
362
|
: (options.abbrevLengths?.get(id) ?? options.abbrev ?? 7),
|
|
361
363
|
);
|
|
362
364
|
text += `index ${abbrev(one.id)}..${abbrev(two.id)}`;
|
|
@@ -393,8 +395,8 @@ async function builtinDiff(
|
|
|
393
395
|
const other = pathTwo !== name ? pathTwo : undefined;
|
|
394
396
|
const oneDriver = await driverOf(options, pathOne);
|
|
395
397
|
const twoDriver = pathTwo === pathOne ? oneDriver : await driverOf(options, pathTwo);
|
|
396
|
-
const one = new LoadedSide(pair.old, contentDriver(pair.old, oneDriver));
|
|
397
|
-
const two = new LoadedSide(pair.new, contentDriver(pair.new, twoDriver));
|
|
398
|
+
const one = new LoadedSide(pair.old, contentDriver(pair.old, oneDriver), pair.new?.id);
|
|
399
|
+
const two = new LoadedSide(pair.new, contentDriver(pair.new, twoDriver), pair.old?.id);
|
|
398
400
|
// a side with a textconv driver (git's get_textconv: valid sides only) is text
|
|
399
401
|
const textconvOne = one.driver?.textconv;
|
|
400
402
|
const textconvTwo = two.driver?.textconv;
|
|
@@ -546,8 +548,8 @@ export async function computeDiffstat(
|
|
|
546
548
|
const pathOne = nameA;
|
|
547
549
|
const oneDriver = await driverOf(options, pathOne);
|
|
548
550
|
const twoDriver = nameB === nameA ? oneDriver : await driverOf(options, nameB);
|
|
549
|
-
const one = new LoadedSide(pair.old, contentDriver(pair.old, oneDriver));
|
|
550
|
-
const two = new LoadedSide(pair.new, contentDriver(pair.new, twoDriver));
|
|
551
|
+
const one = new LoadedSide(pair.old, contentDriver(pair.old, oneDriver), pair.new?.id);
|
|
552
|
+
const two = new LoadedSide(pair.new, contentDriver(pair.new, twoDriver), pair.old?.id);
|
|
551
553
|
// git's may_differ: both ids known and equal, or the contents are compared
|
|
552
554
|
const mayDiffer = !(
|
|
553
555
|
one.valid &&
|
|
@@ -21,6 +21,15 @@ export interface InitResult {
|
|
|
21
21
|
/** Initial branch name */
|
|
22
22
|
initialBranch: string;
|
|
23
23
|
|
|
24
|
+
/**
|
|
25
|
+
* git's `advice.defaultBranchName` hint (stderr lines), when the branch is the built-in
|
|
26
|
+
* default: no `--initial-branch`, no `init.defaultBranch`, the advice not turned off
|
|
27
|
+
*/
|
|
28
|
+
hints?: string[];
|
|
29
|
+
|
|
30
|
+
/** git's warnings (stderr lines): `re-init: ignored --initial-branch=<name>` */
|
|
31
|
+
warnings?: string[];
|
|
32
|
+
|
|
24
33
|
/** Whether this is a bare repository */
|
|
25
34
|
bare: boolean;
|
|
26
35
|
|
|
@@ -26,6 +26,11 @@ export interface PullResult {
|
|
|
26
26
|
successful: boolean;
|
|
27
27
|
/** Fetch-from remote */
|
|
28
28
|
fetchedFrom: string;
|
|
29
|
+
/**
|
|
30
|
+
* git's warnings, one message each: pull.c's `fetch updated the current branch head.`
|
|
31
|
+
* when the fetch moved the checked-out branch (a branches remote named after it)
|
|
32
|
+
*/
|
|
33
|
+
warnings?: string[];
|
|
29
34
|
}
|
|
30
35
|
|
|
31
36
|
/**
|
|
@@ -88,6 +88,11 @@ export interface PushResult {
|
|
|
88
88
|
objectCount: number;
|
|
89
89
|
/** Server messages */
|
|
90
90
|
messages: string[];
|
|
91
|
+
/**
|
|
92
|
+
* git's own warnings before the push, one message each: 2.5x's deprecation warning for a
|
|
93
|
+
* remote read from `.git/remotes/` or `.git/branches/`; absent when there are none
|
|
94
|
+
*/
|
|
95
|
+
warnings?: string[];
|
|
91
96
|
/**
|
|
92
97
|
* The report git prints on stderr (`To <url>`, ` * [new branch] main -> main`,
|
|
93
98
|
* ` 1a2b3c4..5d6e7f8 main -> main`, ` ! [rejected] main -> main (fetch first)`,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ObjectId } from "@statewalker/vcs-core";
|
|
2
|
+
import { nullObjectIdLike } from "@statewalker/vcs-utils";
|
|
2
3
|
import { compareGitPaths } from "@statewalker/vcs-utils/encoding";
|
|
3
4
|
import type { StageStateValue } from "@statewalker/vcs-working-tree";
|
|
4
5
|
import { quoteCStyleBody } from "./quote-path.js";
|
|
@@ -176,8 +177,6 @@ function comparePaths(a: string, b: string): number {
|
|
|
176
177
|
return compareGitPaths(a, b);
|
|
177
178
|
}
|
|
178
179
|
|
|
179
|
-
const ZERO_ID = "0".repeat(40);
|
|
180
|
-
|
|
181
180
|
/**
|
|
182
181
|
* The submodule field of a porcelain v2 line: `N...` for a path that is no submodule, else
|
|
183
182
|
* `S` and whether its commit changed (`C`), it has tracked changes (`M`) and untracked files
|
|
@@ -268,6 +267,10 @@ export function formatStatusPorcelain(
|
|
|
268
267
|
}
|
|
269
268
|
const xy = `${e.index === " " ? "." : e.index}${e.worktree === " " ? "." : e.worktree}`;
|
|
270
269
|
const sub = submoduleToken(e);
|
|
270
|
+
// the null id of the repository's format: as long as the entry's other ids
|
|
271
|
+
const ZERO_ID = nullObjectIdLike(
|
|
272
|
+
e.head?.id ?? e.staged?.id ?? e.stages?.find((x) => x !== undefined)?.id,
|
|
273
|
+
);
|
|
271
274
|
if (from !== undefined) {
|
|
272
275
|
lines.push(
|
|
273
276
|
[
|