@statewalker/vcs-commands 0.14.0 → 0.15.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/add-command.d.ts.map +1 -1
- package/dist/commands/add-patch/patch-backend.d.ts +1 -1
- package/dist/commands/add-patch/patch-backend.d.ts.map +1 -1
- package/dist/commands/archive/remote-archive-command.d.ts +4 -1
- package/dist/commands/archive/remote-archive-command.d.ts.map +1 -1
- package/dist/commands/branch-command.d.ts +14 -2
- package/dist/commands/branch-command.d.ts.map +1 -1
- package/dist/commands/cat-file/batch-format.d.ts +8 -12
- package/dist/commands/cat-file/batch-format.d.ts.map +1 -1
- package/dist/commands/cat-file/cat-file-command.d.ts +39 -5
- 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/checkout-command.d.ts +4 -0
- package/dist/commands/checkout-command.d.ts.map +1 -1
- package/dist/commands/checkout-paths.d.ts +9 -0
- package/dist/commands/checkout-paths.d.ts.map +1 -1
- package/dist/commands/cherry-pick-command.d.ts +3 -0
- package/dist/commands/cherry-pick-command.d.ts.map +1 -1
- package/dist/commands/clean-interactive.d.ts +0 -9
- package/dist/commands/clean-interactive.d.ts.map +1 -1
- package/dist/commands/clone-command.d.ts +2 -0
- package/dist/commands/clone-command.d.ts.map +1 -1
- package/dist/commands/column/column-config.d.ts +23 -0
- package/dist/commands/column/column-config.d.ts.map +1 -0
- package/dist/commands/column/column-layout.d.ts +129 -0
- package/dist/commands/column/column-layout.d.ts.map +1 -0
- package/dist/commands/column/index.d.ts +3 -0
- package/dist/commands/column/index.d.ts.map +1 -0
- package/dist/commands/column-command.d.ts +59 -0
- package/dist/commands/column-command.d.ts.map +1 -0
- package/dist/commands/comment-char-config.d.ts +15 -0
- package/dist/commands/comment-char-config.d.ts.map +1 -1
- package/dist/commands/commit-command.d.ts +21 -2
- package/dist/commands/commit-command.d.ts.map +1 -1
- package/dist/commands/config-command.d.ts +12 -0
- package/dist/commands/config-command.d.ts.map +1 -1
- package/dist/commands/credential-helper.d.ts +214 -0
- package/dist/commands/credential-helper.d.ts.map +1 -0
- package/dist/commands/default-branch.d.ts +17 -1
- package/dist/commands/default-branch.d.ts.map +1 -1
- package/dist/commands/diff-color-config.d.ts +4 -0
- package/dist/commands/diff-color-config.d.ts.map +1 -1
- package/dist/commands/diff-command.d.ts +12 -0
- package/dist/commands/diff-command.d.ts.map +1 -1
- package/dist/commands/fast-export/fast-export-command.d.ts +89 -2
- package/dist/commands/fast-export/fast-export-command.d.ts.map +1 -1
- package/dist/commands/fast-export/fast-import-command.d.ts +113 -8
- package/dist/commands/fast-export/fast-import-command.d.ts.map +1 -1
- package/dist/commands/fast-export/fast-stream-support.d.ts +0 -9
- package/dist/commands/fast-export/fast-stream-support.d.ts.map +1 -1
- package/dist/commands/fetch-command.d.ts +21 -0
- package/dist/commands/fetch-command.d.ts.map +1 -1
- package/dist/commands/git-hooks.d.ts +28 -0
- package/dist/commands/git-hooks.d.ts.map +1 -1
- package/dist/commands/history-command.d.ts +173 -7
- package/dist/commands/history-command.d.ts.map +1 -1
- package/dist/commands/index-host.d.ts +19 -0
- package/dist/commands/index-host.d.ts.map +1 -1
- package/dist/commands/index-refresh.d.ts +36 -0
- package/dist/commands/index-refresh.d.ts.map +1 -0
- package/dist/commands/index.d.ts +9 -0
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +7 -6
- package/dist/commands/init-command.d.ts +20 -0
- package/dist/commands/init-command.d.ts.map +1 -1
- package/dist/commands/local-transport.d.ts +29 -1
- package/dist/commands/local-transport.d.ts.map +1 -1
- package/dist/commands/log-command.d.ts +7 -0
- package/dist/commands/log-command.d.ts.map +1 -1
- package/dist/commands/log-output.d.ts +11 -0
- package/dist/commands/log-output.d.ts.map +1 -1
- package/dist/commands/maintenance-schedule-command.d.ts +122 -0
- package/dist/commands/maintenance-schedule-command.d.ts.map +1 -0
- package/dist/commands/merge-command.d.ts +2 -0
- package/dist/commands/merge-command.d.ts.map +1 -1
- package/dist/commands/merge-index-command.d.ts +42 -0
- package/dist/commands/merge-index-command.d.ts.map +1 -0
- package/dist/commands/merge-one-file.d.ts +129 -0
- package/dist/commands/merge-one-file.d.ts.map +1 -0
- package/dist/commands/merge-support.d.ts +21 -2
- package/dist/commands/merge-support.d.ts.map +1 -1
- package/dist/commands/object-disk-info.d.ts +35 -0
- package/dist/commands/object-disk-info.d.ts.map +1 -0
- package/dist/commands/octopus-merge.d.ts +3 -3
- package/dist/commands/octopus-merge.d.ts.map +1 -1
- package/dist/commands/promisor-remote.d.ts.map +1 -1
- package/dist/commands/pull-command.d.ts +55 -7
- package/dist/commands/pull-command.d.ts.map +1 -1
- package/dist/commands/push-command.d.ts +18 -1
- package/dist/commands/push-command.d.ts.map +1 -1
- package/dist/commands/range-diff/range-diff-command.d.ts +37 -1
- package/dist/commands/range-diff/range-diff-command.d.ts.map +1 -1
- package/dist/commands/rebase-command.d.ts +13 -1
- package/dist/commands/rebase-command.d.ts.map +1 -1
- package/dist/commands/ref-filter/for-each-ref-command.d.ts +3 -2
- package/dist/commands/ref-filter/for-each-ref-command.d.ts.map +1 -1
- package/dist/commands/ref-filter/ref-filter.d.ts.map +1 -1
- package/dist/commands/ref-filter/ref-format.d.ts +26 -1
- package/dist/commands/ref-filter/ref-format.d.ts.map +1 -1
- package/dist/commands/ref-filter/ref-listing-command.d.ts +9 -0
- package/dist/commands/ref-filter/ref-listing-command.d.ts.map +1 -1
- package/dist/commands/remote-transport.d.ts +27 -0
- package/dist/commands/remote-transport.d.ts.map +1 -1
- package/dist/commands/repack-command.d.ts +18 -2
- package/dist/commands/repack-command.d.ts.map +1 -1
- package/dist/commands/repo-command.d.ts +2 -7
- package/dist/commands/repo-command.d.ts.map +1 -1
- package/dist/commands/reset-command.d.ts +4 -1
- package/dist/commands/reset-command.d.ts.map +1 -1
- package/dist/commands/restore-command.d.ts.map +1 -1
- package/dist/commands/rev-list-command.d.ts +65 -0
- package/dist/commands/rev-list-command.d.ts.map +1 -1
- package/dist/commands/revert-command.d.ts +3 -0
- package/dist/commands/revert-command.d.ts.map +1 -1
- package/dist/commands/revision-filenames.d.ts.map +1 -1
- package/dist/commands/revision-range.d.ts +17 -0
- package/dist/commands/revision-range.d.ts.map +1 -1
- package/dist/commands/revision-resolver.d.ts +12 -0
- package/dist/commands/revision-resolver.d.ts.map +1 -1
- package/dist/commands/serve-repository.d.ts +17 -1
- package/dist/commands/serve-repository.d.ts.map +1 -1
- package/dist/commands/served-lazy-fetch.d.ts +61 -0
- package/dist/commands/served-lazy-fetch.d.ts.map +1 -0
- package/dist/commands/signing.d.ts +10 -4
- package/dist/commands/signing.d.ts.map +1 -1
- package/dist/commands/status-color-config.d.ts +33 -0
- package/dist/commands/status-color-config.d.ts.map +1 -0
- package/dist/commands/status-command.d.ts +15 -0
- package/dist/commands/status-command.d.ts.map +1 -1
- package/dist/commands/status-format.d.ts +46 -4
- package/dist/commands/status-format.d.ts.map +1 -1
- package/dist/commands/tag-command.d.ts +15 -1
- package/dist/commands/tag-command.d.ts.map +1 -1
- package/dist/commands/tree-restore.d.ts +14 -0
- package/dist/commands/tree-restore.d.ts.map +1 -1
- package/dist/commands/verify-command.d.ts +22 -2
- package/dist/commands/verify-command.d.ts.map +1 -1
- package/dist/commands/worktree-add-command.d.ts.map +1 -1
- package/dist/commands/worktree-overwrite-checks.d.ts +31 -6
- package/dist/commands/worktree-overwrite-checks.d.ts.map +1 -1
- package/dist/{commands-C9M78Chn.js → commands-DT3VEv50.js} +14879 -16703
- package/dist/errors/commit-errors.d.ts +23 -3
- package/dist/errors/commit-errors.d.ts.map +1 -1
- package/dist/errors/git-api-error.d.ts +6 -0
- package/dist/errors/git-api-error.d.ts.map +1 -1
- package/dist/errors/index.js +30 -4
- package/dist/{fsck-C4US3l0B.js → fsck-BZ508Elg.js} +1 -1
- package/dist/git-command.d.ts +33 -1
- package/dist/git-command.d.ts.map +1 -1
- package/dist/git.d.ts +104 -1
- package/dist/git.d.ts.map +1 -1
- package/dist/index.js +8 -7
- package/dist/{remote-transport-C43eykfK.js → local-transport-D98U6p4d.js} +184 -683
- package/dist/{maintenance-run-command-CoJFKr2p.js → maintenance-run-command-DZFnbnbo.js} +2285 -79
- package/dist/remote-config/remote-config-store.d.ts +6 -0
- package/dist/remote-config/remote-config-store.d.ts.map +1 -1
- package/dist/remote-transport-zvSqwpOB.js +4865 -0
- package/dist/results/cherry-pick-result.d.ts +4 -3
- package/dist/results/cherry-pick-result.d.ts.map +1 -1
- package/dist/results/diff-output.d.ts +7 -0
- package/dist/results/diff-output.d.ts.map +1 -1
- package/dist/results/diff-words.d.ts +14 -3
- package/dist/results/diff-words.d.ts.map +1 -1
- package/dist/results/index.js +1 -1
- package/dist/results/line-prefix-sink.d.ts +50 -0
- package/dist/results/line-prefix-sink.d.ts.map +1 -0
- package/dist/results/merge-result.d.ts +4 -3
- package/dist/results/merge-result.d.ts.map +1 -1
- package/dist/results/rebase-result.d.ts +5 -0
- package/dist/results/rebase-result.d.ts.map +1 -1
- package/dist/results/revert-result.d.ts +4 -3
- package/dist/results/revert-result.d.ts.map +1 -1
- package/dist/{results-B0CWLCAp.js → results-rF81cQse.js} +1425 -202
- package/dist/transport-command.d.ts +10 -0
- package/dist/transport-command.d.ts.map +1 -1
- package/package.json +12 -12
- package/src/commands/add-command.ts +15 -2
- package/src/commands/add-patch/patch-backend.ts +6 -44
- package/src/commands/archive/remote-archive-command.ts +10 -3
- package/src/commands/branch-command.ts +57 -4
- package/src/commands/cat-file/batch-format.ts +17 -18
- package/src/commands/cat-file/cat-file-command.ts +181 -15
- package/src/commands/check-ignore-command.ts +61 -17
- package/src/commands/checkout-command.ts +149 -21
- package/src/commands/checkout-index-command.ts +2 -1
- package/src/commands/checkout-paths.ts +13 -0
- package/src/commands/cherry-pick-command.ts +9 -0
- package/src/commands/clean-interactive.ts +20 -74
- package/src/commands/clone-command.ts +13 -0
- package/src/commands/column/column-config.ts +63 -0
- package/src/commands/column/column-layout.ts +396 -0
- package/src/commands/column/index.ts +2 -0
- package/src/commands/column-command.ts +171 -0
- package/src/commands/comment-char-config.ts +42 -0
- package/src/commands/commit-command.ts +61 -21
- package/src/commands/config-command.ts +28 -0
- package/src/commands/credential-helper.ts +807 -0
- package/src/commands/default-branch.ts +38 -0
- package/src/commands/diff-color-config.ts +23 -10
- package/src/commands/diff-command.ts +25 -2
- package/src/commands/fast-export/fast-export-command.ts +661 -35
- package/src/commands/fast-export/fast-import-command.ts +694 -94
- package/src/commands/fast-export/fast-stream-support.ts +18 -1
- package/src/commands/fetch-command.ts +103 -14
- package/src/commands/git-hooks.ts +85 -0
- package/src/commands/history-command.ts +952 -20
- package/src/commands/index-host.ts +51 -0
- package/src/commands/index-refresh.ts +121 -0
- package/src/commands/index.ts +9 -0
- package/src/commands/init-command.ts +34 -1
- package/src/commands/legacy-remotes.ts +4 -20
- package/src/commands/local-transport.ts +130 -9
- package/src/commands/log-command.ts +39 -1
- package/src/commands/log-output.ts +31 -4
- package/src/commands/maintenance-schedule-command.ts +418 -0
- package/src/commands/merge-command.ts +10 -0
- package/src/commands/merge-index-command.ts +202 -0
- package/src/commands/merge-one-file.ts +451 -0
- package/src/commands/merge-support.ts +127 -11
- package/src/commands/object-disk-info.ts +169 -0
- package/src/commands/octopus-merge.ts +37 -128
- package/src/commands/promisor-remote.ts +14 -3
- package/src/commands/pull-command.ts +173 -27
- package/src/commands/push-command.ts +50 -5
- package/src/commands/range-diff/range-diff-command.ts +86 -3
- package/src/commands/rebase-command.ts +46 -1
- package/src/commands/ref-filter/for-each-ref-command.ts +4 -3
- package/src/commands/ref-filter/ref-filter.ts +59 -4
- package/src/commands/ref-filter/ref-format.ts +83 -10
- package/src/commands/ref-filter/ref-listing-command.ts +30 -0
- package/src/commands/remote-command.ts +2 -2
- package/src/commands/remote-transport.ts +66 -3
- package/src/commands/repack-command.ts +75 -9
- package/src/commands/repo-command.ts +6 -70
- package/src/commands/reset-command.ts +11 -1
- package/src/commands/restore-command.ts +1 -0
- package/src/commands/rev-list-command.ts +205 -3
- package/src/commands/revert-command.ts +9 -0
- package/src/commands/revision-filenames.ts +32 -4
- package/src/commands/revision-range.ts +2 -2
- package/src/commands/revision-resolver.ts +21 -1
- package/src/commands/serve-repository.ts +34 -8
- package/src/commands/served-lazy-fetch.ts +164 -0
- package/src/commands/signing.ts +18 -10
- package/src/commands/status-color-config.ts +92 -0
- package/src/commands/status-command.ts +50 -2
- package/src/commands/status-format.ts +198 -50
- package/src/commands/tag-command.ts +57 -2
- package/src/commands/tree-restore.ts +17 -0
- package/src/commands/verify-command.ts +84 -12
- package/src/commands/worktree-add-command.ts +2 -0
- package/src/commands/worktree-overwrite-checks.ts +75 -14
- package/src/errors/commit-errors.ts +31 -3
- package/src/errors/git-api-error.ts +7 -0
- package/src/git-command.ts +105 -4
- package/src/git.ts +153 -0
- package/src/remote-config/remote-config-store.ts +16 -0
- package/src/results/cherry-pick-result.ts +4 -3
- package/src/results/diff-output.ts +8 -0
- package/src/results/diff-words.ts +160 -32
- package/src/results/line-prefix-sink.ts +102 -0
- package/src/results/merge-result.ts +4 -3
- package/src/results/rebase-result.ts +5 -0
- package/src/results/revert-result.ts +4 -3
- package/src/transport-command.ts +48 -2
|
@@ -47,6 +47,7 @@ import type { RevisionResolver } from "./revision-resolver.js";
|
|
|
47
47
|
import { pushSparseWarnings, SparseUnpack } from "./sparse-checkout-support.js";
|
|
48
48
|
import type { SubmoduleUnpack } from "./submodule-unpack.js";
|
|
49
49
|
import {
|
|
50
|
+
type CheckoutRef,
|
|
50
51
|
planFlatRestore,
|
|
51
52
|
planTreeRestore,
|
|
52
53
|
restoreCaseOptions,
|
|
@@ -54,12 +55,15 @@ import {
|
|
|
54
55
|
writeTreeRestorePlan,
|
|
55
56
|
} from "./tree-restore.js";
|
|
56
57
|
import {
|
|
58
|
+
belowRefused,
|
|
57
59
|
type CheckedEntry,
|
|
58
60
|
entryNotUptodate,
|
|
59
61
|
findInTheWay,
|
|
62
|
+
leadingFileOf,
|
|
60
63
|
overwriteMessage,
|
|
61
64
|
pruneEmptyParents,
|
|
62
65
|
removeCaseVariants,
|
|
66
|
+
takeCleanSubdirectory,
|
|
63
67
|
} from "./worktree-overwrite-checks.js";
|
|
64
68
|
import { firstInvalidPath, worktreePathRules } from "./worktree-path-rules.js";
|
|
65
69
|
|
|
@@ -549,11 +553,24 @@ export async function updateIndexCacheTree(
|
|
|
549
553
|
trees: CommandTrees,
|
|
550
554
|
/** the repository's object format, the cache-tree's trees are hashed in */
|
|
551
555
|
format: ObjectFormat,
|
|
556
|
+
/**
|
|
557
|
+
* An index no tree can hold (a file and a directory of one name) leaves the cache-tree as
|
|
558
|
+
* it is and gives verify_cache's lines here, as git's cache_tree_update fails and the
|
|
559
|
+
* command goes on (checkout); without it the update throws
|
|
560
|
+
*/
|
|
561
|
+
onClash?: (lines: string[]) => void,
|
|
552
562
|
): Promise<void> {
|
|
553
563
|
if (!staging.getCacheTree || !staging.setCacheTree) return;
|
|
554
564
|
if (await staging.hasConflicts()) return;
|
|
555
565
|
const previous = staging.getCacheTree();
|
|
556
566
|
if (previous && cacheTreeFullyValid(previous)) return;
|
|
567
|
+
if (onClash) {
|
|
568
|
+
const lines = verifyCacheLines(await indexEntryList(staging));
|
|
569
|
+
if (lines.length > 0) {
|
|
570
|
+
onClash(lines);
|
|
571
|
+
return;
|
|
572
|
+
}
|
|
573
|
+
}
|
|
557
574
|
const treeId = await staging.writeTree(trees);
|
|
558
575
|
const cacheTree = await updateCacheTree(trees, treeId, previous, format);
|
|
559
576
|
for (const entry of await indexEntryList(staging)) {
|
|
@@ -564,6 +581,27 @@ export async function updateIndexCacheTree(
|
|
|
564
581
|
staging.setCacheTree(cacheTree);
|
|
565
582
|
}
|
|
566
583
|
|
|
584
|
+
/**
|
|
585
|
+
* What git's `verify_cache` prints for an index of stage-0 entries holding a path and a path
|
|
586
|
+
* below it: one "You have both" line per such neighbouring pair in index order, at most ten,
|
|
587
|
+
* then "...".
|
|
588
|
+
*/
|
|
589
|
+
export function verifyCacheLines(entries: readonly { path: string }[]): string[] {
|
|
590
|
+
const lines: string[] = [];
|
|
591
|
+
for (let i = 0; i + 1 < entries.length; i++) {
|
|
592
|
+
const name = (entries[i] as { path: string }).path;
|
|
593
|
+
const next = (entries[i + 1] as { path: string }).path;
|
|
594
|
+
if (next.length > name.length && next.startsWith(name) && next[name.length] === "/") {
|
|
595
|
+
if (lines.length === 10) {
|
|
596
|
+
lines.push("...");
|
|
597
|
+
break;
|
|
598
|
+
}
|
|
599
|
+
lines.push(`You have both ${name} and ${next}`);
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
return lines;
|
|
603
|
+
}
|
|
604
|
+
|
|
567
605
|
/** Every index entry in the index's order, at once where the staging can give them so. */
|
|
568
606
|
async function indexEntryList(staging: Staging): Promise<readonly IndexEntryInput[]> {
|
|
569
607
|
const list = staging.entryList?.();
|
|
@@ -892,6 +930,11 @@ export async function switchTrees(
|
|
|
892
930
|
export interface SwitchTreesOptions {
|
|
893
931
|
/** Names the operation in git's refusal messages */
|
|
894
932
|
action: "merge" | "checkout";
|
|
933
|
+
/**
|
|
934
|
+
* git's checkout metadata of the switch (unpack-trees' `o->meta`: the ref and commit
|
|
935
|
+
* checked out), handed with each file's blob to a long-running filter process
|
|
936
|
+
*/
|
|
937
|
+
metadata?: CheckoutRef;
|
|
895
938
|
/** Names the operation in restore failures */
|
|
896
939
|
operation: string;
|
|
897
940
|
/** The conflicts to stage */
|
|
@@ -992,17 +1035,60 @@ async function switchTreesWith(
|
|
|
992
1035
|
const subs = options.submodules;
|
|
993
1036
|
/** Paths whose submodule checks replace the untracked-file checks (verify_absent_1) */
|
|
994
1037
|
const submodulePaths = new Set<string>();
|
|
1038
|
+
/**
|
|
1039
|
+
* Index entries git's verify_clean_subdirectory took out of the switch: the entries below a
|
|
1040
|
+
* directory that a new file replaces or a deletion removes (no index entry at the
|
|
1041
|
+
* directory's own path). Each is removed, and its own path merged as if the index lacked it.
|
|
1042
|
+
*/
|
|
1043
|
+
const consumed = new Set<string>();
|
|
1044
|
+
/** Directories deleted_entry's verify_absent checks for untracked files */
|
|
1045
|
+
const absentDirs: string[] = [];
|
|
1046
|
+
/** Paths whose merge failed: traverse_trees enters no subtree of theirs */
|
|
1047
|
+
const refused = new Set<string>();
|
|
1048
|
+
/** The paths each refusal list holds (a path is listed once) */
|
|
1049
|
+
const listed = new Map<string[], Set<string>>();
|
|
1050
|
+
const refuse = (list: string[], path: string, at = path) => {
|
|
1051
|
+
let seen = listed.get(list);
|
|
1052
|
+
if (!seen) {
|
|
1053
|
+
seen = new Set(list);
|
|
1054
|
+
listed.set(list, seen);
|
|
1055
|
+
}
|
|
1056
|
+
if (!seen.has(at)) {
|
|
1057
|
+
seen.add(at);
|
|
1058
|
+
list.push(at);
|
|
1059
|
+
}
|
|
1060
|
+
refused.add(path);
|
|
1061
|
+
};
|
|
1062
|
+
/**
|
|
1063
|
+
* verify_absent of `path` (no index entry there) finding a directory: the clean index
|
|
1064
|
+
* entries below it are taken out, a local change refuses `path`. Whether it passed.
|
|
1065
|
+
*/
|
|
1066
|
+
const cleanSubdirectory = async (path: string) => {
|
|
1067
|
+
const result = await takeCleanSubdirectory(
|
|
1068
|
+
checked as Worktree,
|
|
1069
|
+
path,
|
|
1070
|
+
index,
|
|
1071
|
+
consumed,
|
|
1072
|
+
trust,
|
|
1073
|
+
indexTime,
|
|
1074
|
+
);
|
|
1075
|
+
removes.push(...result.taken);
|
|
1076
|
+
if (result.notUptodate === undefined) return true;
|
|
1077
|
+
refuse(local, path, result.notUptodate);
|
|
1078
|
+
return false;
|
|
1079
|
+
};
|
|
995
1080
|
const paths = [...new Set([...head.keys(), ...target.keys()])].sort();
|
|
996
1081
|
for (const path of paths) {
|
|
1082
|
+
if (belowRefused(path, refused)) continue;
|
|
997
1083
|
const h = head.get(path);
|
|
998
1084
|
const t = target.get(path);
|
|
999
|
-
const i = index.get(path);
|
|
1085
|
+
const i = consumed.has(path) ? undefined : index.get(path);
|
|
1000
1086
|
if (sameEntry(h, t) && !(options.initialCheckout && t && !i)) continue;
|
|
1001
1087
|
if (i) {
|
|
1002
1088
|
if (t && sameEntry(i, t)) continue;
|
|
1003
1089
|
if (!sameEntry(i, h)) {
|
|
1004
1090
|
// a staged change the switch would lose (reject_merge)
|
|
1005
|
-
staged
|
|
1091
|
+
refuse(staged, path);
|
|
1006
1092
|
continue;
|
|
1007
1093
|
}
|
|
1008
1094
|
if (subs && checked && !quiet(path) && i.mode === FileMode.GITLINK) {
|
|
@@ -1010,12 +1096,12 @@ async function switchTreesWith(
|
|
|
1010
1096
|
if (!t && update && (await subs.isSubmodule(path, i)) && (await subs.exists(path))) {
|
|
1011
1097
|
await subs.refuses(path, (h ?? i).objectId, null);
|
|
1012
1098
|
}
|
|
1013
|
-
const
|
|
1014
|
-
if (
|
|
1015
|
-
local
|
|
1099
|
+
const notUptodate = await subs.notUptodate(path, i);
|
|
1100
|
+
if (notUptodate) {
|
|
1101
|
+
refuse(local, path);
|
|
1016
1102
|
continue;
|
|
1017
1103
|
}
|
|
1018
|
-
if (
|
|
1104
|
+
if (notUptodate === false) {
|
|
1019
1105
|
if (t && t.mode !== FileMode.GITLINK) await subs.fileReplacesRefuses(path, i);
|
|
1020
1106
|
if (t) await subs.mergedRefuses(path, i, t);
|
|
1021
1107
|
(t ? updates : removes).push(path);
|
|
@@ -1023,7 +1109,7 @@ async function switchTreesWith(
|
|
|
1023
1109
|
}
|
|
1024
1110
|
}
|
|
1025
1111
|
if (checked && !quiet(path) && (await entryNotUptodate(checked, path, i, trust, indexTime))) {
|
|
1026
|
-
local
|
|
1112
|
+
refuse(local, path);
|
|
1027
1113
|
continue;
|
|
1028
1114
|
}
|
|
1029
1115
|
if (subs && t && !quiet(path)) await subs.mergedRefuses(path, i, t);
|
|
@@ -1033,7 +1119,7 @@ async function switchTreesWith(
|
|
|
1033
1119
|
if (t) {
|
|
1034
1120
|
// a staged deletion of a path the target changes (none in an initial checkout)
|
|
1035
1121
|
if (h && !options.initialCheckout) {
|
|
1036
|
-
staged
|
|
1122
|
+
refuse(staged, path);
|
|
1037
1123
|
continue;
|
|
1038
1124
|
}
|
|
1039
1125
|
if (subs && !quiet(path)) {
|
|
@@ -1042,11 +1128,39 @@ async function switchTreesWith(
|
|
|
1042
1128
|
if (absent !== undefined) submodulePaths.add(path);
|
|
1043
1129
|
if (!absent) await subs.mergedRefuses(path, undefined, t);
|
|
1044
1130
|
}
|
|
1131
|
+
// merged_entry's verify_absent: a directory here loses the index entries below it
|
|
1132
|
+
if (worktree && !quiet(path) && t.mode !== FileMode.GITLINK) {
|
|
1133
|
+
const there = await worktree.getEntry(path);
|
|
1134
|
+
if (there?.isDirectory && !(await cleanSubdirectory(path))) continue;
|
|
1135
|
+
}
|
|
1045
1136
|
updates.push(path);
|
|
1046
1137
|
continue;
|
|
1047
1138
|
}
|
|
1048
|
-
|
|
1049
|
-
|
|
1139
|
+
if (!worktree || quiet(path)) continue;
|
|
1140
|
+
// a deletion already staged (deleted_entry's verify_absent)
|
|
1141
|
+
const there = await worktree.getEntry(path);
|
|
1142
|
+
if (there?.isDirectory) {
|
|
1143
|
+
if (h?.mode !== FileMode.GITLINK && (await cleanSubdirectory(path))) absentDirs.push(path);
|
|
1144
|
+
continue;
|
|
1145
|
+
}
|
|
1146
|
+
if (there) {
|
|
1147
|
+
// an untracked file there would be removed (check_ok_to_remove: not a file the result
|
|
1148
|
+
// removes, as one verify_clean_subdirectory took out)
|
|
1149
|
+
if (!consumed.has(path) && (await untrackedFileAt(worktree, path))) {
|
|
1150
|
+
refuse(untrackedRemoved, path);
|
|
1151
|
+
}
|
|
1152
|
+
continue;
|
|
1153
|
+
}
|
|
1154
|
+
// a file among its leading directories is removed too (check_leading_path, then
|
|
1155
|
+
// check_ok_to_remove): only an ignored one, or one the switch deletes, may go
|
|
1156
|
+
const leading = await leadingFileOf(worktree, path);
|
|
1157
|
+
if (
|
|
1158
|
+
leading !== undefined &&
|
|
1159
|
+
!(index.has(leading) && (consumed.has(leading) || removes.includes(leading))) &&
|
|
1160
|
+
!(await worktree.isIgnored(leading))
|
|
1161
|
+
) {
|
|
1162
|
+
refuse(untrackedRemoved, path, leading);
|
|
1163
|
+
}
|
|
1050
1164
|
}
|
|
1051
1165
|
// a dirty file the target deletes is reported as a local change only (git's
|
|
1052
1166
|
// verify_clean_subdirectory counts tracked files under a replaced directory as such)
|
|
@@ -1055,7 +1169,8 @@ async function switchTreesWith(
|
|
|
1055
1169
|
const writing = new Set(updates.filter((p) => !sparse || sparse.writes(p)));
|
|
1056
1170
|
const found = worktree
|
|
1057
1171
|
? await findInTheWay(worktree, {
|
|
1058
|
-
|
|
1172
|
+
// deleted_entry's directories are checked as a file written there would check them
|
|
1173
|
+
writes: [...[...writing].filter((p) => !submodulePaths.has(p)), ...absentDirs],
|
|
1059
1174
|
removes: new Set(deleting),
|
|
1060
1175
|
index,
|
|
1061
1176
|
...(await restoreCaseOptions(worktree, ignoreCase)),
|
|
@@ -1198,6 +1313,7 @@ async function switchTreesWith(
|
|
|
1198
1313
|
replaceInTheWay: true,
|
|
1199
1314
|
attributes: { direction: "checkout", index: attributesIndexOf(result) },
|
|
1200
1315
|
progress,
|
|
1316
|
+
...(options.metadata ? { metadata: options.metadata } : {}),
|
|
1201
1317
|
},
|
|
1202
1318
|
);
|
|
1203
1319
|
}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What an object takes on disk, as git's `odb_read_object_info_extended` reports it through
|
|
3
|
+
* `disk_sizep`: a packed object's entry (from its offset to the next entry's, or to the pack's
|
|
4
|
+
* trailer for the last), else its loose file's size. Packs are asked first (the repository's
|
|
5
|
+
* own in the pack set's lookup order, then its alternates'), then the loose files (its own,
|
|
6
|
+
* then its alternates'), as git's `oid_object_info_extended` looks objects up.
|
|
7
|
+
*
|
|
8
|
+
* `git repo structure` (its disk sizes), `git rev-list --disk-usage`, and the
|
|
9
|
+
* `%(objectsize:disk)`/`%(deltabase)` atoms of `cat-file` and the ref filter share it.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import {
|
|
13
|
+
joinPath,
|
|
14
|
+
type ObjectId,
|
|
15
|
+
objectFormatOf,
|
|
16
|
+
type Pack,
|
|
17
|
+
packNameOf,
|
|
18
|
+
} from "@statewalker/vcs-core";
|
|
19
|
+
import type { WorkingCopy } from "@statewalker/vcs-working-tree";
|
|
20
|
+
import { commonGitFileOf } from "./git-hooks.js";
|
|
21
|
+
|
|
22
|
+
interface OffsetPack extends Pack {
|
|
23
|
+
indexOf?(id: ObjectId): number;
|
|
24
|
+
offsetAt?(i: number): number;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** The on-disk measures of a repository's objects. */
|
|
28
|
+
export interface ObjectDiskInfo {
|
|
29
|
+
/** The bytes `id` takes on disk; undefined when neither a pack nor a loose file holds it. */
|
|
30
|
+
diskSize(id: ObjectId): Promise<number | undefined>;
|
|
31
|
+
/**
|
|
32
|
+
* `delta_base_oid`: the base of `id`'s pack entry when it is stored as a delta (an
|
|
33
|
+
* OFS_DELTA's base named through the idx, a REF_DELTA's as written), read from the entry's
|
|
34
|
+
* header (the delta is never applied); the format's null id for a whole entry or a loose
|
|
35
|
+
* object; undefined when neither a pack nor a loose file holds it.
|
|
36
|
+
*/
|
|
37
|
+
deltaBase(id: ObjectId): Promise<ObjectId | undefined>;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The on-disk measures of the objects of `workingCopy`'s object directory and its alternates.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```typescript
|
|
45
|
+
* const info = await objectDiskInfoOf(workingCopy);
|
|
46
|
+
* const bytes = (await info.diskSize(id)) ?? 0;
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export async function objectDiskInfoOf(workingCopy: WorkingCopy): Promise<ObjectDiskInfo> {
|
|
50
|
+
const objectsFile = await commonGitFileOf(workingCopy, "objects");
|
|
51
|
+
const packSet = workingCopy.history.packs;
|
|
52
|
+
const packs: OffsetPack[] = [];
|
|
53
|
+
/** The objects directory of each pack and of each loose source, own first */
|
|
54
|
+
const packDirs = new Map<OffsetPack, string>();
|
|
55
|
+
const looseDirs: string[] = [];
|
|
56
|
+
/**
|
|
57
|
+
* Reads the pack lists (again): a lazy fetch of a partial clone installs a new pack while a
|
|
58
|
+
* command runs, as git's `reprepare_packed_git` after a miss.
|
|
59
|
+
*/
|
|
60
|
+
const loadPacks = async (rescan = false): Promise<void> => {
|
|
61
|
+
const add = (pack: OffsetPack, dir: string) => {
|
|
62
|
+
if (packDirs.has(pack)) return;
|
|
63
|
+
packs.push(pack);
|
|
64
|
+
packDirs.set(pack, dir);
|
|
65
|
+
};
|
|
66
|
+
if (!objectsFile) return;
|
|
67
|
+
if (rescan) await packSet?.refresh().catch(() => false);
|
|
68
|
+
for (const pack of ((await packSet?.packs().catch(() => [])) ?? []) as OffsetPack[]) {
|
|
69
|
+
add(pack, objectsFile.path);
|
|
70
|
+
}
|
|
71
|
+
const alternates =
|
|
72
|
+
(await workingCopy.history.objects?.alternates?.list().catch(() => [])) ?? [];
|
|
73
|
+
for (const alternate of alternates) {
|
|
74
|
+
if (rescan) await alternate.packs.refresh().catch(() => false);
|
|
75
|
+
for (const pack of ((await alternate.packs.packs().catch(() => [])) ?? []) as OffsetPack[]) {
|
|
76
|
+
add(pack, alternate.objectsDir);
|
|
77
|
+
}
|
|
78
|
+
if (!looseDirs.includes(alternate.objectsDir)) looseDirs.push(alternate.objectsDir);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
if (objectsFile) looseDirs.push(objectsFile.path);
|
|
82
|
+
await loadPacks();
|
|
83
|
+
const format = objectFormatOf(workingCopy.history.objects);
|
|
84
|
+
const trailer = format.rawLength;
|
|
85
|
+
const sorted = new Map<OffsetPack, Float64Array>();
|
|
86
|
+
const packSizes = new Map<OffsetPack, number>();
|
|
87
|
+
const offsetsOf = (pack: OffsetPack): Float64Array => {
|
|
88
|
+
let offsets = sorted.get(pack);
|
|
89
|
+
if (!offsets) {
|
|
90
|
+
offsets = new Float64Array(pack.count);
|
|
91
|
+
for (let i = 0; i < pack.count; i++) offsets[i] = pack.offsetAt?.(i) ?? 0;
|
|
92
|
+
offsets.sort();
|
|
93
|
+
sorted.set(pack, offsets);
|
|
94
|
+
}
|
|
95
|
+
return offsets;
|
|
96
|
+
};
|
|
97
|
+
const packSizeOf = async (pack: OffsetPack): Promise<number> => {
|
|
98
|
+
let size = packSizes.get(pack);
|
|
99
|
+
if (size === undefined) {
|
|
100
|
+
size = 0;
|
|
101
|
+
const dir = packDirs.get(pack);
|
|
102
|
+
if (objectsFile && dir !== undefined) {
|
|
103
|
+
const path = joinPath(dir, "pack", `${packNameOf(pack)}.pack`);
|
|
104
|
+
size = (await objectsFile.files.stats(path))?.size ?? 0;
|
|
105
|
+
}
|
|
106
|
+
packSizes.set(pack, size);
|
|
107
|
+
}
|
|
108
|
+
return size;
|
|
109
|
+
};
|
|
110
|
+
/** The pack holding `id` (the first in lookup order) and the entry's offset. */
|
|
111
|
+
const packedIn = (id: ObjectId): { pack: OffsetPack; offset: number } | undefined => {
|
|
112
|
+
for (const pack of packs) {
|
|
113
|
+
if (!pack.has(id) || !pack.indexOf || !pack.offsetAt) continue;
|
|
114
|
+
const index = pack.indexOf(id);
|
|
115
|
+
if (index < 0) continue;
|
|
116
|
+
return { pack, offset: pack.offsetAt(index) };
|
|
117
|
+
}
|
|
118
|
+
return undefined;
|
|
119
|
+
};
|
|
120
|
+
const looseSize = async (id: ObjectId): Promise<number | undefined> => {
|
|
121
|
+
for (const dir of looseDirs) {
|
|
122
|
+
const path = joinPath(dir, id.slice(0, 2), id.slice(2));
|
|
123
|
+
const stats = await objectsFile?.files.stats(path).catch(() => undefined);
|
|
124
|
+
if (stats?.kind === "file") return stats.size;
|
|
125
|
+
}
|
|
126
|
+
return undefined;
|
|
127
|
+
};
|
|
128
|
+
type Located = { packed: { pack: OffsetPack; offset: number } } | { loose: number } | undefined;
|
|
129
|
+
/** Where `id` is stored: packs first, then loose files, the pack lists reread on a miss. */
|
|
130
|
+
const locate = async (id: ObjectId): Promise<Located> => {
|
|
131
|
+
for (let pass = 0; pass < 2; pass++) {
|
|
132
|
+
const packed = packedIn(id);
|
|
133
|
+
if (packed) return { packed };
|
|
134
|
+
const loose = await looseSize(id);
|
|
135
|
+
if (loose !== undefined) return { loose };
|
|
136
|
+
if (pass === 0) await loadPacks(true);
|
|
137
|
+
}
|
|
138
|
+
return undefined;
|
|
139
|
+
};
|
|
140
|
+
return {
|
|
141
|
+
async diskSize(id) {
|
|
142
|
+
const where = await locate(id);
|
|
143
|
+
if (!where) return undefined;
|
|
144
|
+
if ("loose" in where) return where.loose;
|
|
145
|
+
const { pack, offset } = where.packed;
|
|
146
|
+
const offsets = offsetsOf(pack);
|
|
147
|
+
let lo = 0;
|
|
148
|
+
let hi = offsets.length;
|
|
149
|
+
while (lo < hi) {
|
|
150
|
+
const mid = (lo + hi) >> 1;
|
|
151
|
+
if ((offsets[mid] as number) <= offset) lo = mid + 1;
|
|
152
|
+
else hi = mid;
|
|
153
|
+
}
|
|
154
|
+
// the last entry ends at the trailer (the pack's checksum, one raw id long)
|
|
155
|
+
const next =
|
|
156
|
+
lo < offsets.length ? (offsets[lo] as number) : (await packSizeOf(pack)) - trailer;
|
|
157
|
+
return next - offset;
|
|
158
|
+
},
|
|
159
|
+
async deltaBase(id) {
|
|
160
|
+
const where = await locate(id);
|
|
161
|
+
if (!where) return undefined;
|
|
162
|
+
if ("packed" in where) {
|
|
163
|
+
const entry = await where.packed.pack.entry(id);
|
|
164
|
+
if (entry && (entry.kind === 6 || entry.kind === 7)) return entry.baseId;
|
|
165
|
+
}
|
|
166
|
+
return format.nullId;
|
|
167
|
+
},
|
|
168
|
+
};
|
|
169
|
+
}
|
|
@@ -10,14 +10,14 @@
|
|
|
10
10
|
* the strategy gave up, leaves everything as it was (git's restore_state).
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
13
|
+
import type { Blobs, ObjectId } from "@statewalker/vcs-core";
|
|
14
|
+
import type { ConflictStyle } from "@statewalker/vcs-utils";
|
|
15
15
|
|
|
16
16
|
import type { CommandCommits, CommandTrees } from "../git-command.js";
|
|
17
|
-
import { isBinaryContent } from "../rename/index.js";
|
|
18
17
|
import { commitsBaseSource, MergeBaseGraph } from "./merge-bases.js";
|
|
18
|
+
import { planOneFile } from "./merge-one-file.js";
|
|
19
19
|
import { flatTree } from "./merge-support.js";
|
|
20
|
-
import {
|
|
20
|
+
import type { OrtConflict } from "./ort-merge.js";
|
|
21
21
|
import type { CheckedEntry } from "./worktree-overwrite-checks.js";
|
|
22
22
|
|
|
23
23
|
/** A head to merge and the name git's messages give it (as the user named it). */
|
|
@@ -263,140 +263,49 @@ async function mergeOneFile(
|
|
|
263
263
|
tempName: () => string,
|
|
264
264
|
): Promise<boolean> {
|
|
265
265
|
const { path, base: o, ours: a, theirs: b } = s;
|
|
266
|
-
const
|
|
266
|
+
const plan = await planOneFile(
|
|
267
|
+
{ blobs: ctx.blobs, style: ctx.style, tempName },
|
|
268
|
+
{
|
|
269
|
+
path,
|
|
270
|
+
ids: [o?.objectId ?? "", a?.objectId ?? "", b?.objectId ?? ""],
|
|
271
|
+
modes: [octal(o), octal(a), octal(b)],
|
|
272
|
+
},
|
|
273
|
+
);
|
|
274
|
+
output.push(...plan.output);
|
|
275
|
+
const leave = (tree?: CheckedEntry) => {
|
|
267
276
|
conflicts.push({
|
|
268
277
|
stagePath: path,
|
|
269
278
|
mode: (a ?? b ?? o)?.mode ?? 0,
|
|
270
279
|
...(o ? { base: o } : {}),
|
|
271
280
|
...(a ? { ours: a } : {}),
|
|
272
281
|
...(b ? { theirs: b } : {}),
|
|
273
|
-
...(a ? { tree: a } : {}),
|
|
282
|
+
...((tree ?? a) ? { tree: tree ?? a } : {}),
|
|
274
283
|
});
|
|
275
|
-
// the worktree keeps what it had (ours)
|
|
276
|
-
|
|
284
|
+
// the worktree keeps what it had (ours), or holds the merge's result
|
|
285
|
+
const kept = tree ?? a;
|
|
286
|
+
if (kept) worktree.set(path, kept);
|
|
277
287
|
return false;
|
|
278
288
|
};
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
o &&
|
|
283
|
-
((!a && !b) || (!a && b?.objectId === o.objectId) || (!b && a?.objectId === o.objectId))
|
|
284
|
-
) {
|
|
285
|
-
if ((!a && m1 !== m3) || (!b && m1 !== m2)) {
|
|
286
|
-
errors.push(
|
|
287
|
-
`ERROR: File ${path} deleted on one branch but had its`,
|
|
288
|
-
"ERROR: permissions changed on the other.",
|
|
289
|
-
);
|
|
290
|
-
return leave();
|
|
291
|
-
}
|
|
292
|
-
if (a) output.push(`Removing ${path}`);
|
|
293
|
-
return true;
|
|
294
|
-
}
|
|
295
|
-
if (!o && a && !b) {
|
|
296
|
-
index.set(path, a);
|
|
297
|
-
return true;
|
|
298
|
-
}
|
|
299
|
-
if (!o && !a && b) {
|
|
300
|
-
output.push(`Adding ${path}`);
|
|
301
|
-
index.set(path, b);
|
|
302
|
-
return true;
|
|
303
|
-
}
|
|
304
|
-
if (!o && a && b && a.objectId === b.objectId) {
|
|
305
|
-
if (m2 !== m3) {
|
|
306
|
-
errors.push(
|
|
307
|
-
`ERROR: File ${path} added identically in both branches,`,
|
|
308
|
-
`ERROR: but permissions conflict ${m2}->${m3}.`,
|
|
309
|
-
);
|
|
310
|
-
return leave();
|
|
311
|
-
}
|
|
312
|
-
output.push(`Adding ${path}`);
|
|
313
|
-
index.set(path, a);
|
|
314
|
-
return true;
|
|
315
|
-
}
|
|
316
|
-
if (a && b) {
|
|
317
|
-
if (m2 === "120000" || m3 === "120000") {
|
|
318
|
-
errors.push(`ERROR: ${path}: Not merging symbolic link changes.`);
|
|
289
|
+
switch (plan.kind) {
|
|
290
|
+
case "fail":
|
|
291
|
+
errors.push(...plan.errors);
|
|
319
292
|
return leave();
|
|
293
|
+
case "remove":
|
|
294
|
+
return true;
|
|
295
|
+
case "add":
|
|
296
|
+
index.set(path, { objectId: plan.id, mode: Number.parseInt(plan.mode, 8) });
|
|
297
|
+
return true;
|
|
298
|
+
case "merge": {
|
|
299
|
+
errors.push(...plan.errors);
|
|
300
|
+
const objectId = plan.contentId ?? (await ctx.blobs.store([plan.content]));
|
|
301
|
+
// the worktree file: ours (its mode), holding the merge's result
|
|
302
|
+
const result = { objectId, mode: (a as CheckedEntry).mode };
|
|
303
|
+
if (plan.message) {
|
|
304
|
+
errors.push(`ERROR: ${plan.message} in ${path}`);
|
|
305
|
+
return leave(result);
|
|
306
|
+
}
|
|
307
|
+
index.set(path, result);
|
|
308
|
+
return true;
|
|
320
309
|
}
|
|
321
|
-
if (m2 === "160000" || m3 === "160000") {
|
|
322
|
-
errors.push(`ERROR: ${path}: Not merging conflicting submodule changes.`);
|
|
323
|
-
return leave();
|
|
324
|
-
}
|
|
325
|
-
const [n1, n2] = [tempName(), tempName()];
|
|
326
|
-
output.push(o ? `Auto-merging ${path}` : `Added ${path} in both, but differently.`);
|
|
327
|
-
const emptyBlob = ctx.blobs.objectFormat?.emptyBlobId ?? EMPTY_BLOB_ID;
|
|
328
|
-
if (!o && !(await ctx.blobs.has(emptyBlob))) {
|
|
329
|
-
// the script's base is the empty blob, which `hash-object` never stored: unpack-file
|
|
330
|
-
// and merge-file fail, ours stays in the worktree
|
|
331
|
-
errors.push(
|
|
332
|
-
`fatal: unable to read blob object ${emptyBlob}`,
|
|
333
|
-
"error: Could not stat : No such file or directory",
|
|
334
|
-
`ERROR: content conflict in ${path}`,
|
|
335
|
-
);
|
|
336
|
-
return leave();
|
|
337
|
-
}
|
|
338
|
-
const nO = tempName();
|
|
339
|
-
const contents = {
|
|
340
|
-
ours: await readBlob(ctx.blobs, a.objectId),
|
|
341
|
-
base: o ? await readBlob(ctx.blobs, o.objectId) : new Uint8Array(0),
|
|
342
|
-
theirs: await readBlob(ctx.blobs, b.objectId),
|
|
343
|
-
};
|
|
344
|
-
// `git merge-file` reads its three files in order and stops at the first binary one
|
|
345
|
-
// ("Cannot merge binary files: <its temporary name>"), leaving ours in the worktree
|
|
346
|
-
const binary = (
|
|
347
|
-
[
|
|
348
|
-
[contents.ours, n1],
|
|
349
|
-
[contents.base, nO],
|
|
350
|
-
[contents.theirs, n2],
|
|
351
|
-
] as const
|
|
352
|
-
).find(([content]) => isBinaryContent(content));
|
|
353
|
-
if (binary) {
|
|
354
|
-
errors.push(`error: Cannot merge binary files: ${binary[1]}`);
|
|
355
|
-
let msg = "content conflict";
|
|
356
|
-
if (m2 !== m3) msg = `${msg}, permissions conflict: ${m1}->${m2},${m3}`;
|
|
357
|
-
errors.push(`ERROR: ${msg} in ${path}`);
|
|
358
|
-
conflicts.push({
|
|
359
|
-
stagePath: path,
|
|
360
|
-
mode: a.mode,
|
|
361
|
-
...(o ? { base: o } : {}),
|
|
362
|
-
ours: a,
|
|
363
|
-
theirs: b,
|
|
364
|
-
tree: a,
|
|
365
|
-
});
|
|
366
|
-
worktree.set(path, a);
|
|
367
|
-
return false;
|
|
368
|
-
}
|
|
369
|
-
const merged = mergeLines(contents.base, contents.ours, contents.theirs, {
|
|
370
|
-
oursLabel: n1,
|
|
371
|
-
baseLabel: nO,
|
|
372
|
-
theirsLabel: n2,
|
|
373
|
-
style: ctx.style,
|
|
374
|
-
algorithm: "myers",
|
|
375
|
-
level: "zealous-alnum",
|
|
376
|
-
});
|
|
377
|
-
const objectId = await ctx.blobs.store([merged.content]);
|
|
378
|
-
// the worktree file: ours (its mode), holding the merge's result
|
|
379
|
-
const result = { objectId, mode: a.mode };
|
|
380
|
-
let msg = merged.conflicts > 0 || !o ? "content conflict" : "";
|
|
381
|
-
if (m2 !== m3) msg = `${msg ? `${msg}, ` : ""}permissions conflict: ${m1}->${m2},${m3}`;
|
|
382
|
-
if (msg) {
|
|
383
|
-
errors.push(`ERROR: ${msg} in ${path}`);
|
|
384
|
-
conflicts.push({
|
|
385
|
-
stagePath: path,
|
|
386
|
-
mode: a.mode,
|
|
387
|
-
...(o ? { base: o } : {}),
|
|
388
|
-
ours: a,
|
|
389
|
-
theirs: b,
|
|
390
|
-
tree: result,
|
|
391
|
-
});
|
|
392
|
-
worktree.set(path, result);
|
|
393
|
-
return false;
|
|
394
|
-
}
|
|
395
|
-
index.set(path, result);
|
|
396
|
-
return true;
|
|
397
310
|
}
|
|
398
|
-
errors.push(
|
|
399
|
-
`ERROR: ${path}: Not handling case ${o?.objectId ?? ""} -> ${a?.objectId ?? ""} -> ${b?.objectId ?? ""}`,
|
|
400
|
-
);
|
|
401
|
-
return leave();
|
|
402
311
|
}
|
|
@@ -208,9 +208,9 @@ export function createPromisorFetcher(
|
|
|
208
208
|
});
|
|
209
209
|
// loaded when first needed: GitCommand installs this fetcher, and the transport's
|
|
210
210
|
// modules (local remotes run commands) import GitCommand
|
|
211
|
-
const { prepareRemote, protocolVersionOf, withRemoteUploadPack } =
|
|
212
|
-
"./remote-transport.js"
|
|
213
|
-
);
|
|
211
|
+
const { localLazyFetchOf, prepareRemote, protocolVersionOf, withRemoteUploadPack } =
|
|
212
|
+
await import("./remote-transport.js");
|
|
213
|
+
const { remoteHookSession } = await import("./local-transport.js");
|
|
214
214
|
const prepared = await prepareRemote(
|
|
215
215
|
workingCopy,
|
|
216
216
|
url,
|
|
@@ -233,6 +233,17 @@ export function createPromisorFetcher(
|
|
|
233
233
|
: settings;
|
|
234
234
|
},
|
|
235
235
|
...(options.credentialHelper ? { credentialHelper: options.credentialHelper } : {}),
|
|
236
|
+
// a local promisor's upload-pack runs the protected uploadpack.packObjectsHook
|
|
237
|
+
localHooks: (remote) => remoteHookSession(workingCopy, remote, { localPush: true }),
|
|
238
|
+
// the child fetch's local upload-pack inherits GIT_NAMESPACE
|
|
239
|
+
...(environment?.namespace ? { namespace: environment.namespace } : {}),
|
|
240
|
+
// and its GIT_NO_LAZY_FETCH=0: a local promisor's upload-pack fetches what it lacks
|
|
241
|
+
...localLazyFetchOf(environment, {
|
|
242
|
+
transports: options.transports ?? createDefaultTransports(),
|
|
243
|
+
...(options.credentialHelper ? { credentialHelper: options.credentialHelper } : {}),
|
|
244
|
+
...(options.timeout !== undefined ? { timeout: options.timeout } : {}),
|
|
245
|
+
...(options.warningCallback ? { warningCallback: options.warningCallback } : {}),
|
|
246
|
+
}),
|
|
236
247
|
},
|
|
237
248
|
async (connection) => {
|
|
238
249
|
try {
|