@statewalker/vcs-commands 0.13.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/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 +27 -2
- 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/branch-command.d.ts +14 -2
- package/dist/commands/branch-command.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/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 +17 -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 +30 -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 +33 -3
- 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 +23 -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 +31 -3
- 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 +40 -2
- 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/ls-tree-command.d.ts +10 -0
- package/dist/commands/ls-tree-command.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 +13 -1
- 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 +40 -4
- 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/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/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/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 +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 +21 -4
- 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 +37 -4
- 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/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-CPceUCP2.js → commands-DT3VEv50.js} +15168 -16842
- package/dist/errors/commit-errors.d.ts +37 -1
- 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 +44 -3
- package/dist/{fsck-tbrPZX2q.js → fsck-BZ508Elg.js} +2 -2
- 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-C0OSJtor.js → local-transport-D98U6p4d.js} +228 -692
- package/dist/{maintenance-run-command-UiSIaeP8.js → maintenance-run-command-DZFnbnbo.js} +2366 -108
- 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-CkS1p1CH.js → results-rF81cQse.js} +1788 -247
- package/dist/transport-command.d.ts +13 -0
- package/dist/transport-command.d.ts.map +1 -1
- package/package.json +21 -13
- package/src/commands/add-command.ts +15 -2
- package/src/commands/add-patch/patch-backend.ts +6 -44
- package/src/commands/archive/archive-command.ts +7 -3
- package/src/commands/archive/remote-archive-command.ts +45 -4
- package/src/commands/archive/upload-archive-writer.ts +34 -22
- package/src/commands/branch-command.ts +57 -4
- 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/batch-format.ts +17 -18
- package/src/commands/cat-file/cat-file-command.ts +182 -48
- package/src/commands/check-ignore-command.ts +110 -21
- 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 +102 -11
- 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 +93 -18
- package/src/commands/config-command.ts +28 -0
- package/src/commands/credential-helper.ts +807 -0
- package/src/commands/default-branch.ts +57 -5
- 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 +116 -16
- package/src/commands/fsck/fsck-object-checks.ts +3 -1
- package/src/commands/git-hooks.ts +96 -5
- 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 +57 -4
- package/src/commands/legacy-remotes.ts +4 -20
- package/src/commands/local-transport.ts +183 -18
- package/src/commands/log-command.ts +39 -1
- package/src/commands/log-output.ts +31 -4
- package/src/commands/ls-tree-command.ts +20 -12
- package/src/commands/maintenance-schedule-command.ts +418 -0
- package/src/commands/merge-command.ts +42 -8
- package/src/commands/merge-index-command.ts +202 -0
- package/src/commands/merge-one-file.ts +451 -0
- package/src/commands/merge-support.ts +169 -15
- package/src/commands/object-disk-info.ts +169 -0
- package/src/commands/octopus-merge.ts +37 -128
- package/src/commands/plumbing-input.ts +3 -1
- package/src/commands/promisor-remote-reply.ts +338 -56
- package/src/commands/promisor-remote.ts +39 -6
- package/src/commands/pull-command.ts +173 -27
- package/src/commands/push-command.ts +55 -6
- package/src/commands/range-diff/range-diff-command.ts +86 -3
- package/src/commands/read-tree-command.ts +2 -2
- 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/index.ts +1 -0
- package/src/commands/ref-filter/peel-limit.ts +7 -0
- package/src/commands/ref-filter/ref-filter.ts +68 -7
- package/src/commands/ref-filter/ref-format.ts +85 -11
- 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 +42 -11
- package/src/commands/served-lazy-fetch.ts +164 -0
- package/src/commands/signing.ts +103 -12
- package/src/commands/split-cmdline.ts +32 -0
- 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 +52 -2
- 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 +79 -3
package/src/git.ts
CHANGED
|
@@ -35,6 +35,7 @@ import {
|
|
|
35
35
|
CherryPickCommand,
|
|
36
36
|
CleanCommand,
|
|
37
37
|
CloneCommand,
|
|
38
|
+
ColumnCommand,
|
|
38
39
|
CommitCommand,
|
|
39
40
|
ConfigCommand,
|
|
40
41
|
CopyBranchCommand,
|
|
@@ -60,8 +61,11 @@ import {
|
|
|
60
61
|
FsckCommand,
|
|
61
62
|
GarbageCollectCommand,
|
|
62
63
|
GrepCommand,
|
|
64
|
+
HistoryDropCommand,
|
|
65
|
+
HistoryFixupCommand,
|
|
63
66
|
HistoryRewordCommand,
|
|
64
67
|
HistorySplitCommand,
|
|
68
|
+
HistorySquashCommand,
|
|
65
69
|
HookListCommand,
|
|
66
70
|
HookRunCommand,
|
|
67
71
|
InitCommand,
|
|
@@ -76,9 +80,15 @@ import {
|
|
|
76
80
|
LsFilesCommand,
|
|
77
81
|
LsRemoteCommand,
|
|
78
82
|
LsTreeCommand,
|
|
83
|
+
MaintenanceRegisterCommand,
|
|
79
84
|
MaintenanceRunCommand,
|
|
85
|
+
MaintenanceStartCommand,
|
|
86
|
+
MaintenanceStopCommand,
|
|
87
|
+
MaintenanceUnregisterCommand,
|
|
80
88
|
MergeBaseCommand,
|
|
81
89
|
MergeCommand,
|
|
90
|
+
MergeIndexCommand,
|
|
91
|
+
MergeOneFileCommand,
|
|
82
92
|
MergeTreeCommand,
|
|
83
93
|
MktagCommand,
|
|
84
94
|
MvCommand,
|
|
@@ -522,6 +532,48 @@ export class Git implements Disposable {
|
|
|
522
532
|
return new HistoryRewordCommand(this._workingCopy);
|
|
523
533
|
}
|
|
524
534
|
|
|
535
|
+
/**
|
|
536
|
+
* `git history drop <commit>` (git 2.56): the commit removed, its descendants replayed
|
|
537
|
+
* onto its parent, the branches on them moved; HEAD's index and worktree follow.
|
|
538
|
+
*
|
|
539
|
+
* @example
|
|
540
|
+
* ```typescript
|
|
541
|
+
* await git.historyDrop().addArgument("HEAD~1").call();
|
|
542
|
+
* ```
|
|
543
|
+
*/
|
|
544
|
+
historyDrop(): HistoryDropCommand {
|
|
545
|
+
this.checkClosed();
|
|
546
|
+
return new HistoryDropCommand(this._workingCopy);
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
/**
|
|
550
|
+
* `git history fixup <commit>` (git 2.55): the staged changes merged into the commit, its
|
|
551
|
+
* descendants replayed, the branches on them moved; the index and worktree stay.
|
|
552
|
+
*
|
|
553
|
+
* @example
|
|
554
|
+
* ```typescript
|
|
555
|
+
* await git.historyFixup().addArgument("HEAD~1").call();
|
|
556
|
+
* ```
|
|
557
|
+
*/
|
|
558
|
+
historyFixup(): HistoryFixupCommand {
|
|
559
|
+
this.checkClosed();
|
|
560
|
+
return new HistoryFixupCommand(this._workingCopy);
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
/**
|
|
564
|
+
* `git history squash <revision-range>` (git master): the commits of the range folded into
|
|
565
|
+
* one, its descendants replayed, the branches on them moved; trees, index and worktree stay.
|
|
566
|
+
*
|
|
567
|
+
* @example
|
|
568
|
+
* ```typescript
|
|
569
|
+
* await git.historySquash().addArgument("main~3..main").setEdit(false).call();
|
|
570
|
+
* ```
|
|
571
|
+
*/
|
|
572
|
+
historySquash(): HistorySquashCommand {
|
|
573
|
+
this.checkClosed();
|
|
574
|
+
return new HistorySquashCommand(this._workingCopy);
|
|
575
|
+
}
|
|
576
|
+
|
|
525
577
|
/**
|
|
526
578
|
* `git history split <commit> [<pathspec>...]`: the hunks chosen become a new commit
|
|
527
579
|
* under the original one.
|
|
@@ -947,6 +999,34 @@ export class Git implements Disposable {
|
|
|
947
999
|
return new UpdateIndexCommand(this._workingCopy);
|
|
948
1000
|
}
|
|
949
1001
|
|
|
1002
|
+
/**
|
|
1003
|
+
* Create a MergeIndexCommand running a merge program over the index's unmerged paths
|
|
1004
|
+
* (`git merge-index`).
|
|
1005
|
+
*
|
|
1006
|
+
* @example
|
|
1007
|
+
* ```typescript
|
|
1008
|
+
* await git.mergeIndex().setArguments(["-o", "git-merge-one-file", "-a"]).call();
|
|
1009
|
+
* ```
|
|
1010
|
+
*/
|
|
1011
|
+
mergeIndex(): MergeIndexCommand {
|
|
1012
|
+
this.checkClosed();
|
|
1013
|
+
return new MergeIndexCommand(this._workingCopy);
|
|
1014
|
+
}
|
|
1015
|
+
|
|
1016
|
+
/**
|
|
1017
|
+
* Create a MergeOneFileCommand merging one unmerged path from its stages
|
|
1018
|
+
* (`git merge-one-file`, git's default merge program for `merge-index`).
|
|
1019
|
+
*
|
|
1020
|
+
* @example
|
|
1021
|
+
* ```typescript
|
|
1022
|
+
* await git.mergeOneFile().setArguments([base, ours, theirs, "f", "100644", "100644", "100644"]).call();
|
|
1023
|
+
* ```
|
|
1024
|
+
*/
|
|
1025
|
+
mergeOneFile(): MergeOneFileCommand {
|
|
1026
|
+
this.checkClosed();
|
|
1027
|
+
return new MergeOneFileCommand(this._workingCopy);
|
|
1028
|
+
}
|
|
1029
|
+
|
|
950
1030
|
/**
|
|
951
1031
|
* Create a MktagCommand writing a tag object from its text after git's strict fsck check
|
|
952
1032
|
* (`git mktag`).
|
|
@@ -1165,6 +1245,64 @@ export class Git implements Disposable {
|
|
|
1165
1245
|
return this.withTransports(new MaintenanceRunCommand(this._workingCopy));
|
|
1166
1246
|
}
|
|
1167
1247
|
|
|
1248
|
+
/**
|
|
1249
|
+
* Create a MaintenanceRegisterCommand (`git maintenance register [--config-file <path>]`):
|
|
1250
|
+
* the repository's path added to `maintenance.repo` of the global configuration, its
|
|
1251
|
+
* foreground maintenance turned off.
|
|
1252
|
+
*
|
|
1253
|
+
* @example
|
|
1254
|
+
* ```typescript
|
|
1255
|
+
* const { exitCode, stderr } = await git.maintenanceRegister().call();
|
|
1256
|
+
* ```
|
|
1257
|
+
*/
|
|
1258
|
+
maintenanceRegister(): MaintenanceRegisterCommand {
|
|
1259
|
+
this.checkClosed();
|
|
1260
|
+
return new MaintenanceRegisterCommand(this._workingCopy);
|
|
1261
|
+
}
|
|
1262
|
+
|
|
1263
|
+
/**
|
|
1264
|
+
* Create a MaintenanceUnregisterCommand (`git maintenance unregister [--config-file <path>]
|
|
1265
|
+
* [--force]`).
|
|
1266
|
+
*
|
|
1267
|
+
* @example
|
|
1268
|
+
* ```typescript
|
|
1269
|
+
* await git.maintenanceUnregister().setForce(true).call();
|
|
1270
|
+
* ```
|
|
1271
|
+
*/
|
|
1272
|
+
maintenanceUnregister(): MaintenanceUnregisterCommand {
|
|
1273
|
+
this.checkClosed();
|
|
1274
|
+
return new MaintenanceUnregisterCommand(this._workingCopy);
|
|
1275
|
+
}
|
|
1276
|
+
|
|
1277
|
+
/**
|
|
1278
|
+
* Create a MaintenanceStartCommand (`git maintenance start [--scheduler=<scheduler>]`):
|
|
1279
|
+
* the host's scheduler (`GitHostEnvironment.maintenanceScheduler`) told to run the hourly,
|
|
1280
|
+
* daily and weekly maintenance, then the repository registered.
|
|
1281
|
+
*
|
|
1282
|
+
* @example
|
|
1283
|
+
* ```typescript
|
|
1284
|
+
* await git.maintenanceStart().setScheduler("crontab").call();
|
|
1285
|
+
* ```
|
|
1286
|
+
*/
|
|
1287
|
+
maintenanceStart(): MaintenanceStartCommand {
|
|
1288
|
+
this.checkClosed();
|
|
1289
|
+
return new MaintenanceStartCommand(this._workingCopy);
|
|
1290
|
+
}
|
|
1291
|
+
|
|
1292
|
+
/**
|
|
1293
|
+
* Create a MaintenanceStopCommand (`git maintenance stop`): the host's scheduler told to
|
|
1294
|
+
* remove the runs; the repository stays registered.
|
|
1295
|
+
*
|
|
1296
|
+
* @example
|
|
1297
|
+
* ```typescript
|
|
1298
|
+
* await git.maintenanceStop().call();
|
|
1299
|
+
* ```
|
|
1300
|
+
*/
|
|
1301
|
+
maintenanceStop(): MaintenanceStopCommand {
|
|
1302
|
+
this.checkClosed();
|
|
1303
|
+
return new MaintenanceStopCommand(this._workingCopy);
|
|
1304
|
+
}
|
|
1305
|
+
|
|
1168
1306
|
/**
|
|
1169
1307
|
* Create an FsckCommand that verifies the connectivity and validity of the objects
|
|
1170
1308
|
* (`git fsck`).
|
|
@@ -1470,6 +1608,21 @@ export class Git implements Disposable {
|
|
|
1470
1608
|
return new StripspaceCommand(this._workingCopy);
|
|
1471
1609
|
}
|
|
1472
1610
|
|
|
1611
|
+
/**
|
|
1612
|
+
* Create a ColumnCommand (`git column`): lines laid out in columns as git's column.c lays
|
|
1613
|
+
* them out (`column.ui`, `--mode`, `--width`, `--padding`, `--indent`, `--nl`).
|
|
1614
|
+
*
|
|
1615
|
+
* @example
|
|
1616
|
+
* ```typescript
|
|
1617
|
+
* await git.column().setMode("column").setWidth(20).setInput("one\ntwo\nthree\n").call();
|
|
1618
|
+
* // { exitCode: 0, stdout: "one two three\n", stderr: "" }
|
|
1619
|
+
* ```
|
|
1620
|
+
*/
|
|
1621
|
+
column(): ColumnCommand {
|
|
1622
|
+
this.checkClosed();
|
|
1623
|
+
return new ColumnCommand(this._workingCopy);
|
|
1624
|
+
}
|
|
1625
|
+
|
|
1473
1626
|
/**
|
|
1474
1627
|
* Create a ShowBranchCommand (`git show-branch`): the commit-ancestry table of branches,
|
|
1475
1628
|
* `--list`, `--more`, `--independent`, `--merge-base`, `--topics`, `--reflog`; git's argv,
|
|
@@ -131,6 +131,12 @@ interface GitConfigLike {
|
|
|
131
131
|
* includes or `config.worktree`), in file order: what git's config writer edits.
|
|
132
132
|
*/
|
|
133
133
|
getLocal?(key: string): unknown[];
|
|
134
|
+
/**
|
|
135
|
+
* Optional: sets every value of a key as git's `set_multivar` with a value pattern edits
|
|
136
|
+
* them (values kept stay on their lines, a replaced one is written where it stood, removed
|
|
137
|
+
* ones are unset), as `GitWorkingCopyConfig` does; without it the values are set and added.
|
|
138
|
+
*/
|
|
139
|
+
editValues?(key: string, values: unknown[]): void;
|
|
134
140
|
}
|
|
135
141
|
|
|
136
142
|
/** A config value, its text as written and where it was read (see {@link RemoteConfigStore.valuesWithOrigin}). */
|
|
@@ -801,6 +807,16 @@ export class RemoteConfigStore {
|
|
|
801
807
|
for (const value of values.slice(1)) this.config.add(key, value);
|
|
802
808
|
}
|
|
803
809
|
|
|
810
|
+
/**
|
|
811
|
+
* Sets every value of a config variable as git's pattern edits change them (`git config
|
|
812
|
+
* <key> <new> <pattern>`, `--unset-all <key> <pattern>`): the values kept stay where they
|
|
813
|
+
* are, a replaced value is written on its line, the removed ones are unset.
|
|
814
|
+
*/
|
|
815
|
+
editValues(key: string, values: string[]): void {
|
|
816
|
+
if (this.config.editValues) this.config.editValues(key, values);
|
|
817
|
+
else this.setValues(key, values);
|
|
818
|
+
}
|
|
819
|
+
|
|
804
820
|
/** Flush to the backing file, if the config has one. */
|
|
805
821
|
async save(): Promise<void> {
|
|
806
822
|
await this.config.save?.();
|
|
@@ -37,9 +37,10 @@ export interface CherryPickResult {
|
|
|
37
37
|
/** What is printed on stdout: merge-ort's `Auto-merging f`, `CONFLICT (...)` lines */
|
|
38
38
|
readonly output?: string[];
|
|
39
39
|
/**
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
40
|
+
* Warnings git printed on stderr, line by line: first git 2.5x's `core.commentChar=auto`
|
|
41
|
+
* deprecation warning and its advice, then what the sparse checkout printed while the
|
|
42
|
+
* result was written (the patterns' warnings, git's "The following paths are not up to
|
|
43
|
+
* date and were left despite sparse patterns:" block). Absent when there was nothing to say.
|
|
43
44
|
*/
|
|
44
45
|
readonly warnings?: string[];
|
|
45
46
|
/**
|
|
@@ -54,6 +54,7 @@ import { gitBinaryPatch } from "./binary-patch.js";
|
|
|
54
54
|
import { type ColoredHunk, type DiffColors, WSEH_NEW, writeColoredHunks } from "./diff-color.js";
|
|
55
55
|
import type { LineRange } from "./diff-entry.js";
|
|
56
56
|
import { compileWordRegex, writeWordDiffHunks } from "./diff-words.js";
|
|
57
|
+
import type { LinePrefixSink } from "./line-prefix-sink.js";
|
|
57
58
|
import { cutToLineRanges, lineRangesSpan } from "./line-range-hunks.js";
|
|
58
59
|
import { quoteCStyleBody, quotePath, quoteTwo } from "./quote-path.js";
|
|
59
60
|
|
|
@@ -231,6 +232,12 @@ export interface DiffOutputOptions
|
|
|
231
232
|
* asks for the plain word diff
|
|
232
233
|
*/
|
|
233
234
|
wordDiffRegex?: string;
|
|
235
|
+
/**
|
|
236
|
+
* diff.c's `diff_line_prefix` (`log --graph`'s padding) is placed later, by this sink the
|
|
237
|
+
* whole output goes through: it puts the prefix before every line except in the chunks the
|
|
238
|
+
* writers that place it themselves (the word diff) mark
|
|
239
|
+
*/
|
|
240
|
+
linePrefix?: LinePrefixSink;
|
|
234
241
|
/** `diff.wordRegex`: the word regex of a pair whose drivers give none */
|
|
235
242
|
defaultWordRegex?: string;
|
|
236
243
|
}
|
|
@@ -755,6 +762,7 @@ async function builtinDiff(
|
|
|
755
762
|
mode: wordDiff,
|
|
756
763
|
...(pattern !== undefined ? { regex: compileWordRegex(pattern) } : {}),
|
|
757
764
|
...(colors ? { colors } : {}),
|
|
765
|
+
...(options.linePrefix ? { linePrefix: options.linePrefix } : {}),
|
|
758
766
|
});
|
|
759
767
|
return;
|
|
760
768
|
}
|
|
@@ -18,9 +18,13 @@
|
|
|
18
18
|
* mode, one `-`/`+`/` ` line per piece with `~` for each newline in porcelain mode. Context
|
|
19
19
|
* lines are printed without their sign (porcelain: with it, followed by `~`).
|
|
20
20
|
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
21
|
+
* Under `log --graph` (`linePrefix`, diff.c's `diff_line_prefix`) hunk headers and context
|
|
22
|
+
* lines start with the prefix as usual, but the word diff places it itself, as git does: where
|
|
23
|
+
* a word hunk starts on a new line (`color_words_output_graph_prefix`) and after each newline
|
|
24
|
+
* inside a piece's text (`fn_out_diff_words_write_helper`); porcelain's `~` lines and most of
|
|
25
|
+
* its `-`/`+` lines go without it. Its chunks are marked for the `LinePrefixSink` the output
|
|
26
|
+
* goes through, which records where the prefix goes. A word hunk's prefix is git's `fputs`,
|
|
27
|
+
* which bypasses `--color-moved`'s buffer: it lands at the start of the patch there.
|
|
24
28
|
*
|
|
25
29
|
* @module
|
|
26
30
|
*/
|
|
@@ -34,7 +38,13 @@ import {
|
|
|
34
38
|
import { encodeGitPath } from "@statewalker/vcs-utils/encoding";
|
|
35
39
|
|
|
36
40
|
import { GitApiError } from "../errors/index.js";
|
|
37
|
-
import {
|
|
41
|
+
import {
|
|
42
|
+
type ColoredHunk,
|
|
43
|
+
coloredHunkHeader,
|
|
44
|
+
type DiffColors,
|
|
45
|
+
MovedLineBuffer,
|
|
46
|
+
} from "./diff-color.js";
|
|
47
|
+
import { type LinePrefixSink, markLinePrefix } from "./line-prefix-sink.js";
|
|
38
48
|
|
|
39
49
|
/** `--word-diff=<mode>` (`--color-words` is `color`) */
|
|
40
50
|
export type WordDiffMode = "plain" | "color" | "porcelain";
|
|
@@ -49,6 +59,12 @@ export interface WordDiffOptions {
|
|
|
49
59
|
regex?: PosixRegex;
|
|
50
60
|
/** The palette of `--color`; unset, no colors */
|
|
51
61
|
colors?: DiffColors;
|
|
62
|
+
/**
|
|
63
|
+
* The sink the whole output goes through, placing diff.c's `diff_line_prefix` (`log
|
|
64
|
+
* --graph`'s padding): each chunk is marked with the prefixes git's word diff writes before
|
|
65
|
+
* it, and the sink adds none inside it; unset, the chunks are not marked
|
|
66
|
+
*/
|
|
67
|
+
linePrefix?: LinePrefixSink;
|
|
52
68
|
}
|
|
53
69
|
|
|
54
70
|
/** One kind of piece of a style (diff.c's `diff_words_style_elem`) */
|
|
@@ -150,26 +166,87 @@ class Pieces {
|
|
|
150
166
|
* Prints the piece as `DIFF_SYMBOL_WORD_DIFF` does (`fprintf("%.*s")`): up to its first NUL
|
|
151
167
|
* byte, whatever follows (suffix, reset, newline) dropped with it
|
|
152
168
|
*/
|
|
153
|
-
flushTo(sink: ByteSink): void {
|
|
169
|
+
flushTo(sink: ByteSink, prefix: Prefixes | undefined): void {
|
|
170
|
+
const out = (b: Uint8Array) => (prefix ? prefix.push(sink, b) : sink.push(b));
|
|
154
171
|
for (const p of this.parts) {
|
|
155
172
|
const nul = p.indexOf(0);
|
|
156
173
|
if (nul < 0) {
|
|
157
|
-
|
|
174
|
+
out(p);
|
|
158
175
|
continue;
|
|
159
176
|
}
|
|
160
|
-
if (nul > 0)
|
|
177
|
+
if (nul > 0) out(p.subarray(0, nul));
|
|
161
178
|
break;
|
|
162
179
|
}
|
|
163
180
|
this.parts = [];
|
|
164
181
|
}
|
|
165
182
|
}
|
|
166
183
|
|
|
167
|
-
/**
|
|
168
|
-
|
|
184
|
+
/**
|
|
185
|
+
* The line prefixes the word diff writes (`DIFF_SYMBOL_WORD_DIFF`s of `diff_line_prefix`),
|
|
186
|
+
* each attached to the next chunk it pushes
|
|
187
|
+
*/
|
|
188
|
+
class Prefixes {
|
|
189
|
+
private pending = 0;
|
|
190
|
+
|
|
191
|
+
constructor(
|
|
192
|
+
/** The output's sink when the writer's sink reaches it in order (no scratch sink) */
|
|
193
|
+
private readonly direct: LinePrefixSink | undefined,
|
|
194
|
+
) {}
|
|
195
|
+
|
|
196
|
+
/** A prefix before whatever is pushed next */
|
|
197
|
+
add(): void {
|
|
198
|
+
this.pending++;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* A prefix `fputs` writes to the file (`fn_out_diff_words_aux`): ahead of the symbols
|
|
203
|
+
* `--color-moved` buffers, else where it stands
|
|
204
|
+
*/
|
|
205
|
+
addDirect(): void {
|
|
206
|
+
if (this.direct) this.direct.addPoint();
|
|
207
|
+
else this.add();
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/** `bytes`, written by the word diff (no prefix inside it), after the pending prefixes */
|
|
211
|
+
push(sink: ByteSink, bytes: Uint8Array): void {
|
|
212
|
+
if (bytes.length === 0) return;
|
|
213
|
+
// a view of its own: the mark belongs to the array, and style bytes are pushed often
|
|
214
|
+
sink.push(markLinePrefix(bytes.subarray(0), { before: this.pending, own: true }));
|
|
215
|
+
this.pending = 0;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* `bytes` printed through `emit_line_0` (a context line, a hunk header: the prefix at each
|
|
220
|
+
* line start as usual), after the pending prefixes
|
|
221
|
+
*/
|
|
222
|
+
pushLine(sink: ByteSink, bytes: Uint8Array): void {
|
|
223
|
+
if (bytes.length === 0) return;
|
|
224
|
+
sink.push(
|
|
225
|
+
this.pending > 0
|
|
226
|
+
? markLinePrefix(bytes.subarray(0), { before: this.pending, own: false })
|
|
227
|
+
: bytes,
|
|
228
|
+
);
|
|
229
|
+
this.pending = 0;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* `fn_out_diff_words_write_helper`: `text` as pieces of `el`, `newline` for each LF, the line
|
|
235
|
+
* prefix (when placed) before each piece after a newline
|
|
236
|
+
*/
|
|
237
|
+
function writeHelper(
|
|
238
|
+
sink: ByteSink,
|
|
239
|
+
el: StyleElem,
|
|
240
|
+
newline: Uint8Array,
|
|
241
|
+
text: Uint8Array,
|
|
242
|
+
prefix: Prefixes | undefined,
|
|
243
|
+
): void {
|
|
169
244
|
const sb = new Pieces();
|
|
245
|
+
let print = false;
|
|
170
246
|
let at = 0;
|
|
171
247
|
let count = text.length;
|
|
172
248
|
while (count > 0) {
|
|
249
|
+
if (print) prefix?.add();
|
|
173
250
|
const nl = text.subarray(at, at + count).indexOf(NEWLINE);
|
|
174
251
|
if (nl !== 0) {
|
|
175
252
|
const colored = el.color !== undefined && el.color !== "";
|
|
@@ -183,9 +260,10 @@ function writeHelper(sink: ByteSink, el: StyleElem, newline: Uint8Array, text: U
|
|
|
183
260
|
sb.bytes(newline);
|
|
184
261
|
count -= nl + 1;
|
|
185
262
|
at += nl + 1;
|
|
186
|
-
|
|
263
|
+
print = true;
|
|
264
|
+
if (count > 0) sb.flushTo(sink, prefix);
|
|
187
265
|
}
|
|
188
|
-
sb.flushTo(sink);
|
|
266
|
+
sb.flushTo(sink, prefix);
|
|
189
267
|
}
|
|
190
268
|
|
|
191
269
|
/** One side's words (diff.c's `diff_words_buffer`): `orig[0]` is the empty 0th word */
|
|
@@ -249,12 +327,18 @@ class WordDiffState {
|
|
|
249
327
|
private minus: Uint8Array[] = [];
|
|
250
328
|
private plus: Uint8Array[] = [];
|
|
251
329
|
private readonly style: Style;
|
|
330
|
+
/** `diff_words_data.current_plus`, an offset into the added text */
|
|
331
|
+
private currentPlus = 0;
|
|
332
|
+
/** `diff_words_data.last_minus` */
|
|
333
|
+
private lastMinus = 0;
|
|
252
334
|
|
|
253
335
|
constructor(
|
|
254
336
|
private readonly sink: ByteSink,
|
|
255
337
|
private readonly regex: PosixRegex | undefined,
|
|
256
338
|
mode: WordDiffMode,
|
|
257
339
|
colors: DiffColors | undefined,
|
|
340
|
+
/** Where `diff_line_prefix` goes, undefined when not placed */
|
|
341
|
+
private readonly prefix: Prefixes | undefined,
|
|
258
342
|
) {
|
|
259
343
|
this.style = styleOf(mode, colors);
|
|
260
344
|
}
|
|
@@ -269,6 +353,22 @@ class WordDiffState {
|
|
|
269
353
|
if (this.minus.length > 0 || this.plus.length > 0) this.show();
|
|
270
354
|
}
|
|
271
355
|
|
|
356
|
+
/** The line prefix as its own `DIFF_SYMBOL_WORD_DIFF` */
|
|
357
|
+
private writePrefix(): void {
|
|
358
|
+
this.prefix?.add();
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* `color_words_output_graph_prefix`: at the first hunk when it starts the added text, or
|
|
363
|
+
* where the added text printed so far ends with a newline
|
|
364
|
+
*/
|
|
365
|
+
private prefixDue(plus: Uint8Array): boolean {
|
|
366
|
+
return (
|
|
367
|
+
(this.lastMinus === 0 && this.currentPlus === 0) ||
|
|
368
|
+
(this.currentPlus > 0 && plus[this.currentPlus - 1] === NEWLINE)
|
|
369
|
+
);
|
|
370
|
+
}
|
|
371
|
+
|
|
272
372
|
/** `diff_words_show` */
|
|
273
373
|
private show(): void {
|
|
274
374
|
const minus = concat(this.minus);
|
|
@@ -276,12 +376,15 @@ class WordDiffState {
|
|
|
276
376
|
this.minus = [];
|
|
277
377
|
this.plus = [];
|
|
278
378
|
const style = this.style;
|
|
379
|
+
const prefix = this.prefix;
|
|
279
380
|
if (plus.length === 0) {
|
|
280
381
|
// special case: only removal
|
|
281
|
-
|
|
382
|
+
this.writePrefix();
|
|
383
|
+
writeHelper(this.sink, style.oldWord, style.newline, minus, prefix);
|
|
282
384
|
return;
|
|
283
385
|
}
|
|
284
|
-
|
|
386
|
+
this.currentPlus = 0;
|
|
387
|
+
this.lastMinus = 0;
|
|
285
388
|
const mw = fillWords(minus, this.regex);
|
|
286
389
|
const pw = fillWords(plus, this.regex);
|
|
287
390
|
for (const change of xdiffHunks(mw.lines, pw.lines)) {
|
|
@@ -290,19 +393,42 @@ class WordDiffState {
|
|
|
290
393
|
const plusFirst = change.chg2 ? change.i2 + 1 : change.i2;
|
|
291
394
|
const [minusBegin, minusEnd] = span(mw.orig, minusFirst, change.chg1);
|
|
292
395
|
const [plusBegin, plusEnd] = span(pw.orig, plusFirst, change.chg2);
|
|
396
|
+
// fputs(line_prefix): straight to the file, past the --color-moved buffer
|
|
397
|
+
if (this.prefixDue(plus)) this.prefix?.addDirect();
|
|
398
|
+
const currentPlus = this.currentPlus;
|
|
293
399
|
if (currentPlus !== plusBegin) {
|
|
294
|
-
writeHelper(
|
|
400
|
+
writeHelper(
|
|
401
|
+
this.sink,
|
|
402
|
+
style.ctx,
|
|
403
|
+
style.newline,
|
|
404
|
+
plus.subarray(currentPlus, plusBegin),
|
|
405
|
+
prefix,
|
|
406
|
+
);
|
|
295
407
|
}
|
|
296
408
|
if (minusBegin !== minusEnd) {
|
|
297
|
-
writeHelper(
|
|
409
|
+
writeHelper(
|
|
410
|
+
this.sink,
|
|
411
|
+
style.oldWord,
|
|
412
|
+
style.newline,
|
|
413
|
+
minus.subarray(minusBegin, minusEnd),
|
|
414
|
+
prefix,
|
|
415
|
+
);
|
|
298
416
|
}
|
|
299
417
|
if (plusBegin !== plusEnd) {
|
|
300
|
-
writeHelper(
|
|
418
|
+
writeHelper(
|
|
419
|
+
this.sink,
|
|
420
|
+
style.newWord,
|
|
421
|
+
style.newline,
|
|
422
|
+
plus.subarray(plusBegin, plusEnd),
|
|
423
|
+
prefix,
|
|
424
|
+
);
|
|
301
425
|
}
|
|
302
|
-
currentPlus = plusEnd;
|
|
426
|
+
this.currentPlus = plusEnd;
|
|
427
|
+
this.lastMinus = minusFirst;
|
|
303
428
|
}
|
|
304
|
-
if (currentPlus !== plus.length) {
|
|
305
|
-
|
|
429
|
+
if (this.currentPlus !== plus.length) {
|
|
430
|
+
if (this.prefixDue(plus)) this.writePrefix();
|
|
431
|
+
writeHelper(this.sink, style.ctx, style.newline, plus.subarray(this.currentPlus), prefix);
|
|
306
432
|
}
|
|
307
433
|
}
|
|
308
434
|
}
|
|
@@ -330,19 +456,14 @@ function concat(parts: Uint8Array[]): Uint8Array {
|
|
|
330
456
|
}
|
|
331
457
|
|
|
332
458
|
/** diff.c's `emit_line_0` without a sign: `set` before the text, the reset after it */
|
|
333
|
-
function emitLine(
|
|
459
|
+
function emitLine(set: string, reset: string, line: Uint8Array): Uint8Array {
|
|
334
460
|
let len = line.length;
|
|
335
461
|
const hasNewline = len > 0 && line[len - 1] === NEWLINE;
|
|
336
462
|
if (hasNewline) len--;
|
|
337
463
|
const hasCr = len > 0 && line[len - 1] === 0x0d;
|
|
338
464
|
if (hasCr) len--;
|
|
339
|
-
if (len
|
|
340
|
-
|
|
341
|
-
sink.push(line.subarray(0, len));
|
|
342
|
-
if (reset) sink.push(enc(reset));
|
|
343
|
-
}
|
|
344
|
-
if (hasCr) sink.push(Uint8Array.of(0x0d));
|
|
345
|
-
if (hasNewline) sink.push(Uint8Array.of(NEWLINE));
|
|
465
|
+
if (len === 0 || (!set && !reset)) return line;
|
|
466
|
+
return concat([enc(set), line.subarray(0, len), enc(reset), line.subarray(len)]);
|
|
346
467
|
}
|
|
347
468
|
|
|
348
469
|
/**
|
|
@@ -358,12 +479,17 @@ export function writeWordDiffHunks(
|
|
|
358
479
|
options: WordDiffOptions,
|
|
359
480
|
): void {
|
|
360
481
|
const colors = options.colors;
|
|
361
|
-
const
|
|
482
|
+
const outer = options.linePrefix;
|
|
483
|
+
const prefix = outer
|
|
484
|
+
? new Prefixes(sink === outer || sink instanceof MovedLineBuffer ? outer : undefined)
|
|
485
|
+
: undefined;
|
|
486
|
+
const state = new WordDiffState(sink, options.regex, options.mode, colors, prefix);
|
|
487
|
+
const emit = (bytes: Uint8Array) => (prefix ? prefix.pushLine(sink, bytes) : sink.push(bytes));
|
|
362
488
|
const context = colors?.context ?? "";
|
|
363
489
|
const reset = colors?.reset ?? "";
|
|
364
490
|
for (const hunk of hunks) {
|
|
365
491
|
state.flush();
|
|
366
|
-
|
|
492
|
+
emit(colors ? coloredHunkHeader(hunk.header, colors) : hunk.header);
|
|
367
493
|
for (const line of hunk.lines) {
|
|
368
494
|
const bytes = line.bytes;
|
|
369
495
|
// xdl_emit_diffrec: an incomplete line gets its LF (the marker after it is eaten)
|
|
@@ -376,11 +502,13 @@ export function writeWordDiffHunks(
|
|
|
376
502
|
state.flush();
|
|
377
503
|
if (options.mode === "porcelain") {
|
|
378
504
|
// DIFF_SYMBOL_WORDS_PORCELAIN: the line with its sign, then "~"
|
|
379
|
-
emitLine(
|
|
380
|
-
|
|
505
|
+
emit(emitLine(context, reset, concat([Uint8Array.of(0x20), text])));
|
|
506
|
+
// printed with fputs, without the line prefix
|
|
507
|
+
if (prefix) prefix.push(sink, TILDE_LINE.slice());
|
|
508
|
+
else sink.push(TILDE_LINE);
|
|
381
509
|
} else {
|
|
382
510
|
// DIFF_SYMBOL_WORDS: the line without its sign
|
|
383
|
-
emitLine(
|
|
511
|
+
emit(emitLine(context, reset, text));
|
|
384
512
|
}
|
|
385
513
|
}
|
|
386
514
|
}
|