@statewalker/vcs-commands 0.8.0 → 0.9.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 +32 -0
- package/dist/commands/add-command.d.ts.map +1 -1
- package/dist/commands/add-patch/add-patch.d.ts +7 -0
- package/dist/commands/add-patch/add-patch.d.ts.map +1 -1
- package/dist/commands/add-patch/patch-backend.d.ts.map +1 -1
- package/dist/commands/am/am-command.d.ts +47 -0
- package/dist/commands/am/am-command.d.ts.map +1 -1
- package/dist/commands/apply/apply-command.d.ts +2 -0
- package/dist/commands/apply/apply-command.d.ts.map +1 -1
- package/dist/commands/apply/apply-parse.d.ts +7 -0
- package/dist/commands/apply/apply-parse.d.ts.map +1 -1
- package/dist/commands/apply/index.d.ts +1 -1
- package/dist/commands/apply/index.d.ts.map +1 -1
- package/dist/commands/blame-command.d.ts +303 -8
- package/dist/commands/blame-command.d.ts.map +1 -1
- package/dist/commands/blame-ignore.d.ts +48 -0
- package/dist/commands/blame-ignore.d.ts.map +1 -0
- package/dist/commands/check-mailmap-command.d.ts +49 -0
- package/dist/commands/check-mailmap-command.d.ts.map +1 -0
- package/dist/commands/checkout-command.d.ts +7 -0
- package/dist/commands/checkout-command.d.ts.map +1 -1
- package/dist/commands/checkout-paths.d.ts +4 -0
- package/dist/commands/checkout-paths.d.ts.map +1 -1
- package/dist/commands/cherry-command.d.ts +61 -0
- package/dist/commands/cherry-command.d.ts.map +1 -0
- package/dist/commands/cherry-pick-command.d.ts +23 -1
- package/dist/commands/cherry-pick-command.d.ts.map +1 -1
- package/dist/commands/clean-command.d.ts +32 -0
- package/dist/commands/clean-command.d.ts.map +1 -1
- package/dist/commands/clean-interactive.d.ts +56 -0
- package/dist/commands/clean-interactive.d.ts.map +1 -0
- package/dist/commands/clone-command.d.ts +116 -2
- package/dist/commands/clone-command.d.ts.map +1 -1
- package/dist/commands/commit-command.d.ts +50 -2
- package/dist/commands/commit-command.d.ts.map +1 -1
- package/dist/commands/describe-command.d.ts +71 -64
- package/dist/commands/describe-command.d.ts.map +1 -1
- package/dist/commands/diff-command.d.ts +118 -6
- package/dist/commands/diff-command.d.ts.map +1 -1
- package/dist/commands/fetch-command.d.ts +60 -0
- package/dist/commands/fetch-command.d.ts.map +1 -1
- package/dist/commands/fetch-multiple-command.d.ts +193 -0
- package/dist/commands/fetch-multiple-command.d.ts.map +1 -0
- package/dist/commands/format-patch-command.d.ts +28 -2
- package/dist/commands/format-patch-command.d.ts.map +1 -1
- package/dist/commands/git-describe.d.ts +77 -4
- package/dist/commands/git-describe.d.ts.map +1 -1
- package/dist/commands/git-hooks.d.ts +15 -1
- package/dist/commands/git-hooks.d.ts.map +1 -1
- package/dist/commands/index.d.ts +12 -0
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +5 -3
- package/dist/commands/init-command.d.ts +89 -0
- package/dist/commands/init-command.d.ts.map +1 -1
- package/dist/commands/line-log.d.ts +161 -0
- package/dist/commands/line-log.d.ts.map +1 -0
- package/dist/commands/log-command.d.ts +235 -6
- package/dist/commands/log-command.d.ts.map +1 -1
- package/dist/commands/log-graph.d.ts +4 -2
- package/dist/commands/log-graph.d.ts.map +1 -1
- package/dist/commands/log-output.d.ts +66 -1
- package/dist/commands/log-output.d.ts.map +1 -1
- package/dist/commands/mailmap.d.ts +24 -1
- package/dist/commands/mailmap.d.ts.map +1 -1
- package/dist/commands/merge-command.d.ts +51 -1
- package/dist/commands/merge-command.d.ts.map +1 -1
- package/dist/commands/merge-drivers.d.ts +2 -0
- package/dist/commands/merge-drivers.d.ts.map +1 -1
- package/dist/commands/merge-strategy-options.d.ts +69 -0
- package/dist/commands/merge-strategy-options.d.ts.map +1 -0
- package/dist/commands/merge-support.d.ts +10 -0
- package/dist/commands/merge-support.d.ts.map +1 -1
- package/dist/commands/message-cleanup.d.ts +2 -0
- package/dist/commands/message-cleanup.d.ts.map +1 -1
- package/dist/commands/name-rev-command.d.ts +65 -0
- package/dist/commands/name-rev-command.d.ts.map +1 -0
- package/dist/commands/name-rev.d.ts +110 -22
- package/dist/commands/name-rev.d.ts.map +1 -1
- package/dist/commands/octopus-merge.d.ts +26 -1
- package/dist/commands/octopus-merge.d.ts.map +1 -1
- package/dist/commands/ort-merge.d.ts +16 -0
- package/dist/commands/ort-merge.d.ts.map +1 -1
- package/dist/commands/ort-recursive.d.ts.map +1 -1
- package/dist/commands/patch-id.d.ts +58 -0
- package/dist/commands/patch-id.d.ts.map +1 -1
- package/dist/commands/pull-command.d.ts +182 -38
- package/dist/commands/pull-command.d.ts.map +1 -1
- package/dist/commands/push-command.d.ts +65 -0
- package/dist/commands/push-command.d.ts.map +1 -1
- package/dist/commands/range-diff/index.d.ts +4 -0
- package/dist/commands/range-diff/index.d.ts.map +1 -0
- package/dist/commands/range-diff/linear-assignment.d.ts +27 -0
- package/dist/commands/range-diff/linear-assignment.d.ts.map +1 -0
- package/dist/commands/range-diff/range-diff-command.d.ts +121 -0
- package/dist/commands/range-diff/range-diff-command.d.ts.map +1 -0
- package/dist/commands/range-diff/range-diff.d.ts +106 -0
- package/dist/commands/range-diff/range-diff.d.ts.map +1 -0
- package/dist/commands/read-tree-command.d.ts +14 -0
- package/dist/commands/read-tree-command.d.ts.map +1 -1
- package/dist/commands/rebase-command.d.ts +21 -2
- package/dist/commands/rebase-command.d.ts.map +1 -1
- package/dist/commands/remerge-diff.d.ts +59 -0
- package/dist/commands/remerge-diff.d.ts.map +1 -0
- package/dist/commands/remote-command.d.ts +41 -0
- package/dist/commands/remote-command.d.ts.map +1 -1
- package/dist/commands/remote-show-command.d.ts +204 -0
- package/dist/commands/remote-show-command.d.ts.map +1 -0
- package/dist/commands/reset-command.d.ts +19 -1
- package/dist/commands/reset-command.d.ts.map +1 -1
- package/dist/commands/restore-command.d.ts +7 -0
- package/dist/commands/restore-command.d.ts.map +1 -1
- package/dist/commands/rev-list-command.d.ts +75 -3
- package/dist/commands/rev-list-command.d.ts.map +1 -1
- package/dist/commands/revert-command.d.ts +22 -1
- package/dist/commands/revert-command.d.ts.map +1 -1
- package/dist/commands/revision-range.d.ts +2 -0
- package/dist/commands/revision-range.d.ts.map +1 -1
- package/dist/commands/sequencer-pick.d.ts +102 -1
- package/dist/commands/sequencer-pick.d.ts.map +1 -1
- package/dist/commands/sequencer-support.d.ts +10 -1
- package/dist/commands/sequencer-support.d.ts.map +1 -1
- package/dist/commands/shortlog-command.d.ts +109 -0
- package/dist/commands/shortlog-command.d.ts.map +1 -0
- package/dist/commands/shortlog.d.ts +151 -0
- package/dist/commands/shortlog.d.ts.map +1 -0
- package/dist/commands/status-command.d.ts +31 -2
- package/dist/commands/status-command.d.ts.map +1 -1
- package/dist/commands/submodule-commands.d.ts +90 -2
- package/dist/commands/submodule-commands.d.ts.map +1 -1
- package/dist/commands/submodule-fetch.d.ts +149 -0
- package/dist/commands/submodule-fetch.d.ts.map +1 -0
- package/dist/commands/submodule-model.d.ts +8 -0
- package/dist/commands/submodule-model.d.ts.map +1 -1
- package/dist/commands/submodule-unpack.d.ts +120 -0
- package/dist/commands/submodule-unpack.d.ts.map +1 -0
- package/dist/commands/submodule-update-command.d.ts +8 -0
- package/dist/commands/submodule-update-command.d.ts.map +1 -1
- package/dist/commands/subtree-shift.d.ts +27 -0
- package/dist/commands/subtree-shift.d.ts.map +1 -0
- package/dist/commands/switch-command.d.ts +3 -0
- package/dist/commands/switch-command.d.ts.map +1 -1
- package/dist/commands/tree-restore.d.ts.map +1 -1
- package/dist/commands/worktree-overwrite-checks.d.ts +2 -0
- package/dist/commands/worktree-overwrite-checks.d.ts.map +1 -1
- package/dist/{commands-ISM52N0n.js → commands-CNvli5bl.js} +39426 -61169
- package/dist/errors/command-errors.d.ts +25 -0
- package/dist/errors/command-errors.d.ts.map +1 -1
- package/dist/errors/index.js +29 -1
- package/dist/fsck-CPeDh9fh.js +5138 -0
- package/dist/git-command.d.ts +31 -1
- package/dist/git-command.d.ts.map +1 -1
- package/dist/git.d.ts +97 -1
- package/dist/git.d.ts.map +1 -1
- package/dist/guarded-transport-command.d.ts +82 -0
- package/dist/guarded-transport-command.d.ts.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -5
- package/dist/remote-transport-CCmBadm-.js +1606 -0
- package/dist/rename/detect-renames.d.ts +20 -0
- package/dist/rename/detect-renames.d.ts.map +1 -1
- package/dist/rename/diffcore-break.d.ts +51 -0
- package/dist/rename/diffcore-break.d.ts.map +1 -0
- package/dist/rename/index.d.ts +1 -0
- package/dist/rename/index.d.ts.map +1 -1
- package/dist/results/blame-format.d.ts +62 -1
- package/dist/results/blame-format.d.ts.map +1 -1
- package/dist/results/clone-result.d.ts +9 -0
- package/dist/results/clone-result.d.ts.map +1 -1
- package/dist/results/diff-dirstat.d.ts +36 -0
- package/dist/results/diff-dirstat.d.ts.map +1 -0
- package/dist/results/diff-entry.d.ts +10 -0
- package/dist/results/diff-entry.d.ts.map +1 -1
- package/dist/results/diff-formatter.d.ts.map +1 -1
- package/dist/results/diff-output.d.ts +18 -0
- package/dist/results/diff-output.d.ts.map +1 -1
- package/dist/results/fetch-result.d.ts +12 -1
- package/dist/results/fetch-result.d.ts.map +1 -1
- package/dist/results/index.d.ts +2 -0
- package/dist/results/index.d.ts.map +1 -1
- package/dist/results/index.js +2 -2
- package/dist/results/init-result.d.ts +8 -1
- package/dist/results/init-result.d.ts.map +1 -1
- package/dist/results/line-range-hunks.d.ts +27 -0
- package/dist/results/line-range-hunks.d.ts.map +1 -0
- package/dist/results/merge-result.d.ts +8 -1
- package/dist/results/merge-result.d.ts.map +1 -1
- package/dist/results/pull-result.d.ts +11 -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 +1 -1
- package/dist/results/status-result.d.ts.map +1 -1
- package/dist/results-BDuEgdLU.js +46847 -0
- package/dist/transport-command.d.ts +14 -0
- package/dist/transport-command.d.ts.map +1 -1
- package/package.json +12 -12
- package/src/commands/add-command.ts +115 -0
- package/src/commands/add-patch/add-patch.ts +8 -0
- package/src/commands/add-patch/patch-backend.ts +20 -2
- package/src/commands/am/am-command.ts +138 -4
- package/src/commands/apply/apply-command.ts +52 -9
- package/src/commands/apply/apply-parse.ts +10 -0
- package/src/commands/apply/index.ts +8 -1
- package/src/commands/blame-command.ts +1450 -51
- package/src/commands/blame-ignore.ts +307 -0
- package/src/commands/check-mailmap-command.ts +129 -0
- package/src/commands/checkout-command.ts +97 -12
- package/src/commands/checkout-paths.ts +28 -0
- package/src/commands/cherry-command.ts +187 -0
- package/src/commands/cherry-pick-command.ts +42 -1
- package/src/commands/clean-command.ts +92 -12
- package/src/commands/clean-interactive.ts +522 -0
- package/src/commands/clone-command.ts +596 -44
- package/src/commands/commit-command.ts +180 -47
- package/src/commands/describe-command.ts +341 -254
- package/src/commands/diff-command.ts +616 -56
- package/src/commands/fetch-command.ts +353 -6
- package/src/commands/fetch-multiple-command.ts +665 -0
- package/src/commands/format-patch-command.ts +189 -77
- package/src/commands/git-describe.ts +456 -217
- package/src/commands/git-hooks.ts +42 -3
- package/src/commands/index.ts +17 -0
- package/src/commands/init-command.ts +603 -49
- package/src/commands/line-log.ts +931 -0
- package/src/commands/log-command.ts +1414 -177
- package/src/commands/log-graph.ts +6 -3
- package/src/commands/log-output.ts +173 -10
- package/src/commands/mailmap.ts +41 -5
- package/src/commands/merge-command.ts +274 -16
- package/src/commands/merge-drivers.ts +3 -0
- package/src/commands/merge-strategy-options.ts +224 -0
- package/src/commands/merge-support.ts +101 -21
- package/src/commands/message-cleanup.ts +1 -1
- package/src/commands/name-rev-command.ts +184 -0
- package/src/commands/name-rev.ts +700 -109
- package/src/commands/octopus-merge.ts +35 -11
- package/src/commands/ort-merge.ts +41 -7
- package/src/commands/ort-recursive.ts +40 -2
- package/src/commands/patch-id.ts +109 -0
- package/src/commands/pull-command.ts +718 -224
- package/src/commands/push-command.ts +353 -3
- package/src/commands/range-diff/index.ts +3 -0
- package/src/commands/range-diff/linear-assignment.ts +203 -0
- package/src/commands/range-diff/range-diff-command.ts +433 -0
- package/src/commands/range-diff/range-diff.ts +617 -0
- package/src/commands/read-tree-command.ts +74 -3
- package/src/commands/rebase-command.ts +141 -65
- package/src/commands/remerge-diff.ts +241 -0
- package/src/commands/remote-command.ts +98 -10
- package/src/commands/remote-show-command.ts +836 -0
- package/src/commands/reset-command.ts +78 -3
- package/src/commands/restore-command.ts +15 -0
- package/src/commands/rev-list-command.ts +187 -11
- package/src/commands/revert-command.ts +41 -1
- package/src/commands/revision-range.ts +3 -1
- package/src/commands/sequencer-pick.ts +323 -29
- package/src/commands/sequencer-support.ts +164 -2
- package/src/commands/shortlog-command.ts +354 -0
- package/src/commands/shortlog.ts +361 -0
- package/src/commands/show-command.ts +2 -1
- package/src/commands/status-command.ts +115 -25
- package/src/commands/status-format.ts +1 -1
- package/src/commands/submodule-commands.ts +321 -3
- package/src/commands/submodule-fetch.ts +789 -0
- package/src/commands/submodule-model.ts +9 -1
- package/src/commands/submodule-unpack.ts +265 -0
- package/src/commands/submodule-update-command.ts +39 -5
- package/src/commands/subtree-shift.ts +215 -0
- package/src/commands/switch-command.ts +9 -0
- package/src/commands/tree-restore.ts +6 -1
- package/src/commands/worktree-overwrite-checks.ts +5 -0
- package/src/errors/command-errors.ts +35 -0
- package/src/git-command.ts +87 -1
- package/src/git.ts +146 -0
- package/src/guarded-transport-command.ts +171 -0
- package/src/index.ts +1 -0
- package/src/rename/detect-renames.ts +42 -8
- package/src/rename/diffcore-break.ts +166 -0
- package/src/rename/index.ts +1 -0
- package/src/results/blame-format.ts +268 -43
- package/src/results/clone-result.ts +6 -0
- package/src/results/diff-dirstat.ts +117 -0
- package/src/results/diff-entry.ts +12 -0
- package/src/results/diff-formatter.ts +1 -0
- package/src/results/diff-output.ts +127 -2
- package/src/results/fetch-result.ts +12 -1
- package/src/results/index.ts +2 -0
- package/src/results/init-result.ts +10 -1
- package/src/results/line-range-hunks.ts +126 -0
- package/src/results/merge-result.ts +9 -0
- package/src/results/pull-result.ts +7 -0
- package/src/results/push-result.ts +5 -0
- package/src/results/status-result.ts +2 -2
- package/src/transport-command.ts +34 -3
- package/dist/fsck-DLRpbwTj.js +0 -13405
- package/dist/results-TB2IJ64h.js +0 -4700
|
@@ -47,6 +47,15 @@ export declare abstract class TransportCommand<T> extends GitCommand<T> {
|
|
|
47
47
|
/** The transports remote URLs are reached through (undefined: the defaults) */
|
|
48
48
|
private transportRegistry?;
|
|
49
49
|
constructor(workingCopy: WorkingCopy);
|
|
50
|
+
/**
|
|
51
|
+
* What a lazy fetch during the call reaches the promisor remote with: this command's
|
|
52
|
+
* transports, credentials and headers.
|
|
53
|
+
*/
|
|
54
|
+
protected promisorFetcherAuth(): {
|
|
55
|
+
transports?: GitTransportRegistry;
|
|
56
|
+
credentials?: Credentials;
|
|
57
|
+
headers?: Record<string, string>;
|
|
58
|
+
};
|
|
50
59
|
/**
|
|
51
60
|
* Set the transports non-local remotes are reached through: the registry's connector for a
|
|
52
61
|
* URL opens the session (default `createDefaultTransports()`: smart HTTP over the global
|
|
@@ -130,6 +139,11 @@ export declare abstract class TransportCommand<T> extends GitCommand<T> {
|
|
|
130
139
|
* unset.
|
|
131
140
|
*/
|
|
132
141
|
protected remoteProgram(remote: string, key: "uploadpack" | "receivepack"): string | undefined;
|
|
142
|
+
/**
|
|
143
|
+
* Gives a command this one runs (git's child `git fetch`) this command's transports,
|
|
144
|
+
* credentials, headers, timeout, progress callbacks and hook session.
|
|
145
|
+
*/
|
|
146
|
+
protected configureChild<C extends TransportCommand<unknown>>(child: C): C;
|
|
133
147
|
/**
|
|
134
148
|
* Get transport options for passing to transport operations.
|
|
135
149
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport-command.d.ts","sourceRoot":"","sources":["../src/transport-command.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,WAAW,EAEhB,KAAK,o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gB,GAAG,IAAI,CAInD;IAED;;;;OAIG;IACH,0BAA0B,CAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,GAAG,IAAI,CAIpE;IAED;;;;OAIG;IACH,SAAS,CAAC,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAE5D;IAED;;;OAGG;IACH,SAAS,CAAC,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,CAEnD;IAED,6EAA6E;IAC7E,SAAS,CAAC,UAAU,CAAC,QAAQ,EAAE,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC,CAEtE;IAED,iGAAiG;IACjG,SAAS,CAAC,oBAAoB,IAAI,oBAAoB,CAQrD;IAED;;;;OAIG;IACH,SAAS,CAAC,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,YAAY,GAAG,aAAa,GAAG,MAAM,GAAG,SAAS,CAI7F;IAED;;;OAGG;IACH,SAAS,CAAC,cAAc,CAAC,CAAC,SAAS,gBAAgB,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAWzE;IAED;;OAEG;IACH,SAAS,CAAC,mBAAmB,IAAI,gBAAgB,CAShD;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@statewalker/vcs-commands",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "Git-like VCS commands (commit, checkout, merge, diff, log)",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/statewalker/webrun-vcs/issues"
|
|
@@ -46,12 +46,12 @@
|
|
|
46
46
|
"src"
|
|
47
47
|
],
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@statewalker/vcs-
|
|
50
|
-
"@statewalker/vcs-store-
|
|
51
|
-
"@statewalker/vcs-
|
|
52
|
-
"@statewalker/vcs-
|
|
53
|
-
"@statewalker/vcs-
|
|
54
|
-
"@statewalker/vcs-working-tree": "^0.
|
|
49
|
+
"@statewalker/vcs-store-files": "^0.9.0",
|
|
50
|
+
"@statewalker/vcs-store-mem": "^0.9.0",
|
|
51
|
+
"@statewalker/vcs-core": "^0.9.0",
|
|
52
|
+
"@statewalker/vcs-utils": "^0.9.0",
|
|
53
|
+
"@statewalker/vcs-transport": "^0.9.0",
|
|
54
|
+
"@statewalker/vcs-working-tree": "^0.9.0"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@statewalker/webrun-rpc": "^0.15.0",
|
|
@@ -61,11 +61,11 @@
|
|
|
61
61
|
"typescript": "^7.0.2",
|
|
62
62
|
"vitest": "^5.1.0",
|
|
63
63
|
"ws": "^8.22.0",
|
|
64
|
-
"@statewalker/vcs-store-
|
|
65
|
-
"@statewalker/vcs-store-
|
|
66
|
-
"@statewalker/vcs-transport-
|
|
67
|
-
"@statewalker/vcs-
|
|
68
|
-
"@statewalker/vcs-
|
|
64
|
+
"@statewalker/vcs-store-sql": "^0.9.0",
|
|
65
|
+
"@statewalker/vcs-store-kv": "^0.9.0",
|
|
66
|
+
"@statewalker/vcs-transport-adapters": "^0.9.0",
|
|
67
|
+
"@statewalker/vcs-transport-lfs": "^0.8.0",
|
|
68
|
+
"@statewalker/vcs-utils-node": "^0.9.0"
|
|
69
69
|
},
|
|
70
70
|
"scripts": {
|
|
71
71
|
"build": "rm -rf dist && rolldown -c && tsc --emitDeclarationOnly --declaration",
|
|
@@ -33,7 +33,15 @@ import {
|
|
|
33
33
|
runAddInteractive,
|
|
34
34
|
runPatchSelection,
|
|
35
35
|
} from "./add-patch/index.js";
|
|
36
|
+
import {
|
|
37
|
+
ApplyCommand,
|
|
38
|
+
bytesToLatin1,
|
|
39
|
+
latin1ToBytes,
|
|
40
|
+
latin1ToText,
|
|
41
|
+
textToLatin1,
|
|
42
|
+
} from "./apply/index.js";
|
|
36
43
|
import { coreBool, worktreeModeTrust } from "./core-config.js";
|
|
44
|
+
import { DiffCommand } from "./diff-command.js";
|
|
37
45
|
import {
|
|
38
46
|
AddToIndexError,
|
|
39
47
|
chmodIndexEntries,
|
|
@@ -102,8 +110,20 @@ export interface AddResult {
|
|
|
102
110
|
|
|
103
111
|
/** With {@link AddCommand.setInteractive}: what `git add -i` printed and did */
|
|
104
112
|
readonly interactive?: AddInteractiveResult;
|
|
113
|
+
|
|
114
|
+
/** With {@link AddCommand.setEdit}: what `git apply` printed on standard error (warnings) */
|
|
115
|
+
readonly edit?: { errors: string };
|
|
105
116
|
}
|
|
106
117
|
|
|
118
|
+
/**
|
|
119
|
+
* The editor of `git add -e`: given the patch file's path (from the worktree top) and its
|
|
120
|
+
* text, the edited text; undefined when the editor failed.
|
|
121
|
+
*/
|
|
122
|
+
export type AddPatchEditor = (
|
|
123
|
+
path: string,
|
|
124
|
+
text: string,
|
|
125
|
+
) => string | undefined | Promise<string | undefined>;
|
|
126
|
+
|
|
107
127
|
/**
|
|
108
128
|
* Command to stage files from working tree to index.
|
|
109
129
|
*
|
|
@@ -142,6 +162,8 @@ export class AddCommand extends GitCommand<AddResult> {
|
|
|
142
162
|
private patch = false;
|
|
143
163
|
private interactive = false;
|
|
144
164
|
private patchSelector?: PatchSelector;
|
|
165
|
+
private edit = false;
|
|
166
|
+
private editor?: AddPatchEditor;
|
|
145
167
|
private patchOptions: PatchOptions = {};
|
|
146
168
|
|
|
147
169
|
/**
|
|
@@ -504,6 +526,98 @@ export class AddCommand extends GitCommand<AddResult> {
|
|
|
504
526
|
return this;
|
|
505
527
|
}
|
|
506
528
|
|
|
529
|
+
/**
|
|
530
|
+
* `git add -e` (`--edit`): builtin/add.c's `edit_patch`. The changes between the index and
|
|
531
|
+
* the worktree (`diff-files -p` with seven lines of context, limited to the pathspec) are
|
|
532
|
+
* written to `.git/ADD_EDIT.patch`, the editor ({@link setEditor}; without one the patch
|
|
533
|
+
* is taken as it is) edits them, and the result is applied to the index with
|
|
534
|
+
* `git apply --cached --recount`; the file is removed after. An editor failing ("editing
|
|
535
|
+
* patch failed"), an empty patch ("empty patch. aborted") and a patch that does not apply
|
|
536
|
+
* ("could not apply '.git/ADD_EDIT.patch'", after apply's errors) reject with a
|
|
537
|
+
* `GitApiError` of exit code 128, the file left in place as git leaves it.
|
|
538
|
+
*
|
|
539
|
+
* @example
|
|
540
|
+
* ```typescript
|
|
541
|
+
* await git.add().setEdit(true)
|
|
542
|
+
* .setEditor((_path, patch) => patch.replace(/^\+debug.*\n/gm, "")).call();
|
|
543
|
+
* ```
|
|
544
|
+
*/
|
|
545
|
+
setEdit(edit: boolean): this {
|
|
546
|
+
this.checkCallable();
|
|
547
|
+
this.edit = edit;
|
|
548
|
+
return this;
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
/** The editor of {@link setEdit} (git's `GIT_EDITOR` over `ADD_EDIT.patch`). */
|
|
552
|
+
setEditor(editor: AddPatchEditor): this {
|
|
553
|
+
this.checkCallable();
|
|
554
|
+
this.editor = editor;
|
|
555
|
+
return this;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
/** `git add -e`: the diff edited and applied to the index (`edit_patch`). */
|
|
559
|
+
private async callEdit(): Promise<AddResult> {
|
|
560
|
+
if (this.pathspecFile.given) {
|
|
561
|
+
throw new IncompatibleOptionsError(
|
|
562
|
+
["--pathspec-from-file", "--edit"],
|
|
563
|
+
"fatal: options '--pathspec-from-file' and '--edit' cannot be used together",
|
|
564
|
+
);
|
|
565
|
+
}
|
|
566
|
+
const diff = new DiffCommand(this.workingCopy)
|
|
567
|
+
.setRenames(false)
|
|
568
|
+
.setIgnoreSubmodules("dirty")
|
|
569
|
+
.setCombineMerges(false)
|
|
570
|
+
// run_diff_files without ita_invisible_in_index: an intent-to-add entry is the empty
|
|
571
|
+
// blob it holds
|
|
572
|
+
.setIntentToAddVisible(true);
|
|
573
|
+
if (this.filepatterns.length > 0) diff.setPathspec(this.filepatterns);
|
|
574
|
+
const bytes = await diff
|
|
575
|
+
.setOptions({
|
|
576
|
+
defaultPrefix: true,
|
|
577
|
+
ignoreConfigNoPrefix: true,
|
|
578
|
+
textconv: false,
|
|
579
|
+
uiConfig: false,
|
|
580
|
+
submoduleFormat: "short",
|
|
581
|
+
orderFile: "",
|
|
582
|
+
context: 7,
|
|
583
|
+
})
|
|
584
|
+
.callBytes("patch");
|
|
585
|
+
const name = "ADD_EDIT.patch";
|
|
586
|
+
const shown = await this.hooks.gitPath(name);
|
|
587
|
+
const checkout = this.workingCopy.checkout;
|
|
588
|
+
await checkout.writeStateFile?.(name, bytes);
|
|
589
|
+
let edited = bytesToLatin1(bytes);
|
|
590
|
+
if (this.editor) {
|
|
591
|
+
const text = await this.editor(shown, latin1ToText(edited));
|
|
592
|
+
if (text === undefined)
|
|
593
|
+
throw new GitApiError("fatal: editing patch failed", { exitCode: 128 });
|
|
594
|
+
edited = textToLatin1(text);
|
|
595
|
+
await checkout.writeStateFile?.(name, latin1ToBytes(edited));
|
|
596
|
+
}
|
|
597
|
+
if (edited.length === 0)
|
|
598
|
+
throw new GitApiError("fatal: empty patch. aborted", { exitCode: 128 });
|
|
599
|
+
const apply = await new ApplyCommand(this.workingCopy)
|
|
600
|
+
.shareHooksOf(this)
|
|
601
|
+
.addPatch(latin1ToBytes(edited), shown)
|
|
602
|
+
.setCached(true)
|
|
603
|
+
.setRecount(true)
|
|
604
|
+
.call();
|
|
605
|
+
if (apply.exitCode !== 0) {
|
|
606
|
+
throw new GitApiError(`${apply.errors}fatal: could not apply '${shown}'`, { exitCode: 128 });
|
|
607
|
+
}
|
|
608
|
+
await checkout.removeStateFile?.(name);
|
|
609
|
+
return {
|
|
610
|
+
added: [],
|
|
611
|
+
skipped: [],
|
|
612
|
+
ignored: [],
|
|
613
|
+
removed: [],
|
|
614
|
+
totalProcessed: 0,
|
|
615
|
+
warnings: [],
|
|
616
|
+
output: [],
|
|
617
|
+
edit: { errors: apply.errors },
|
|
618
|
+
};
|
|
619
|
+
}
|
|
620
|
+
|
|
507
621
|
/** Answers the prompts of {@link setPatch} (git's reads from standard input and its editor). */
|
|
508
622
|
setPatchSelector(selector: PatchSelector): this {
|
|
509
623
|
this.checkCallable();
|
|
@@ -628,6 +742,7 @@ export class AddCommand extends GitCommand<AddResult> {
|
|
|
628
742
|
await this.readCurrentIndex();
|
|
629
743
|
if (this.patch) return this.callPatch();
|
|
630
744
|
if (this.interactive) return this.callInteractive();
|
|
745
|
+
if (this.edit) return this.callEdit();
|
|
631
746
|
this.sparsePatterns = await this.sparseCheckoutPatterns();
|
|
632
747
|
// a sparse index as git holds it once read: expanded at once when a sparse directory is
|
|
633
748
|
// on disk (with 2.5x's hint), else its sparse directories stay single entries
|
|
@@ -63,6 +63,14 @@ export type PatchRequest =
|
|
|
63
63
|
type: "search";
|
|
64
64
|
prompt: string;
|
|
65
65
|
}
|
|
66
|
+
| {
|
|
67
|
+
/** A line of free text: `git clean -i`'s "Input ignore patterns>> " */
|
|
68
|
+
type: "line";
|
|
69
|
+
/** The prompt as git prints it */
|
|
70
|
+
prompt: string;
|
|
71
|
+
/** What git would have printed so far */
|
|
72
|
+
output: string;
|
|
73
|
+
}
|
|
66
74
|
| {
|
|
67
75
|
/**
|
|
68
76
|
* `git add -i`'s menus (add-interactive.c's `list_and_choose`): the main loop's
|
|
@@ -135,7 +135,20 @@ export function createPatchBackend(options: PatchBackendOptions): PatchBackend {
|
|
|
135
135
|
if (args.reverse) apply.setReverse(true);
|
|
136
136
|
if (args.check) apply.setCheck(true);
|
|
137
137
|
const temporary = options.temporaryIndex;
|
|
138
|
-
if (temporary && args.cached)
|
|
138
|
+
if (temporary && args.cached) {
|
|
139
|
+
apply.setTemporaryIndex(
|
|
140
|
+
new Map(
|
|
141
|
+
[...temporary].map(([path, e]) => [
|
|
142
|
+
path,
|
|
143
|
+
{
|
|
144
|
+
mode: e.mode,
|
|
145
|
+
objectId: e.objectId,
|
|
146
|
+
...(e.carried?.intentToAdd ? { intentToAdd: true } : {}),
|
|
147
|
+
},
|
|
148
|
+
]),
|
|
149
|
+
),
|
|
150
|
+
);
|
|
151
|
+
}
|
|
139
152
|
const result = await apply.call();
|
|
140
153
|
if (temporary && args.cached && !args.check && result.exitCode === 0 && result.index) {
|
|
141
154
|
// the paths apply rewrote get new entries (no stat data, no flags); the others stay
|
|
@@ -143,7 +156,12 @@ export function createPatchBackend(options: PatchBackendOptions): PatchBackend {
|
|
|
143
156
|
temporary.clear();
|
|
144
157
|
for (const [path, entry] of result.index) {
|
|
145
158
|
const old = before.get(path);
|
|
146
|
-
|
|
159
|
+
// the same blob staged over an intent-to-add entry (an empty file) is a new entry
|
|
160
|
+
const same =
|
|
161
|
+
old &&
|
|
162
|
+
old.mode === entry.mode &&
|
|
163
|
+
old.objectId === entry.objectId &&
|
|
164
|
+
!!old.carried?.intentToAdd === !!entry.intentToAdd;
|
|
147
165
|
temporary.set(path, same ? old : { mode: entry.mode, objectId: entry.objectId });
|
|
148
166
|
}
|
|
149
167
|
}
|
|
@@ -34,6 +34,7 @@ import {
|
|
|
34
34
|
textToLatin1,
|
|
35
35
|
} from "../apply/latin1.js";
|
|
36
36
|
import { coreBool } from "../core-config.js";
|
|
37
|
+
import { DiffCommand } from "../diff-command.js";
|
|
37
38
|
import { localTimezoneOffset, parseGitDate } from "../git-date.js";
|
|
38
39
|
import { withoutCrud } from "../git-ident.js";
|
|
39
40
|
import { configValue, conflictStyleOf } from "../merge-config.js";
|
|
@@ -196,6 +197,8 @@ export class AmCommand extends GitCommand<AmResult> {
|
|
|
196
197
|
private emptyMode: "stop" | "drop" | "keep" = "stop";
|
|
197
198
|
private applyOptions: AmApplyOptions = {};
|
|
198
199
|
private legacyMessages = false;
|
|
200
|
+
private interactive?: AmInteractiveReader;
|
|
201
|
+
private editor?: AmMessageEditor;
|
|
199
202
|
private out = "";
|
|
200
203
|
private err = "";
|
|
201
204
|
|
|
@@ -386,6 +389,100 @@ export class AmCommand extends GitCommand<AmResult> {
|
|
|
386
389
|
return this;
|
|
387
390
|
}
|
|
388
391
|
|
|
392
|
+
/**
|
|
393
|
+
* `git am -i` (`--interactive`): before each patch is applied (and before a resolved one
|
|
394
|
+
* is committed), builtin/am.c's `do_interactive` shows its message and asks "Apply?
|
|
395
|
+
* [y]es/[n]o/[e]dit/[v]iew patch/[a]ccept all: ". `reader` answers each such read of
|
|
396
|
+
* standard input with the line typed (only its first letter counts, either case; others
|
|
397
|
+
* ask again), or undefined at the end of input, which stops the am as git dies ("unable to
|
|
398
|
+
* read from stdin; aborting"). `y` applies, `n` skips the patch, `a` applies this one and
|
|
399
|
+
* the rest without asking, `e` hands `final-commit` to {@link setEditor} and asks again
|
|
400
|
+
* with its result, `v` prints the patch (`rebase-apply/patch`, as git's pager shows it).
|
|
401
|
+
* Give it again with `setResume("continue")` to be asked about a resolved patch (git's
|
|
402
|
+
* `am -i --resolved`, which shows the index's diff from HEAD as the patch).
|
|
403
|
+
*
|
|
404
|
+
* @example
|
|
405
|
+
* ```typescript
|
|
406
|
+
* const answers = ["y", "n"];
|
|
407
|
+
* const { output } = await git.am().addMbox(mbox, "mbox")
|
|
408
|
+
* .setInteractive(() => answers.shift()).call();
|
|
409
|
+
* ```
|
|
410
|
+
*/
|
|
411
|
+
setInteractive(reader: AmInteractiveReader | undefined): this {
|
|
412
|
+
this.checkCallable();
|
|
413
|
+
this.interactive = reader;
|
|
414
|
+
return this;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* The editor of `git am -i`'s `e`: given the path of `final-commit` and the message, the
|
|
419
|
+
* edited message (taken as it stands), or undefined when it failed (the message is kept).
|
|
420
|
+
*/
|
|
421
|
+
setEditor(editor: AmMessageEditor): this {
|
|
422
|
+
this.checkCallable();
|
|
423
|
+
this.editor = editor;
|
|
424
|
+
return this;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* `do_interactive`: true when the patch is to be skipped (`n`); `a` turns the questions
|
|
429
|
+
* off for the rest of this run.
|
|
430
|
+
*/
|
|
431
|
+
private async doInteractive(st: AmState): Promise<boolean> {
|
|
432
|
+
const reader = this.interactive as AmInteractiveReader;
|
|
433
|
+
for (;;) {
|
|
434
|
+
this.out += `Commit Body is:\n--------------------------\n${st.msg ?? ""}--------------------------\n`;
|
|
435
|
+
const prompt = "Apply? [y]es/[n]o/[e]dit/[v]iew patch/[a]ccept all: ";
|
|
436
|
+
this.out += prompt;
|
|
437
|
+
const reply = await reader({
|
|
438
|
+
prompt,
|
|
439
|
+
message: latin1ToText(st.msg ?? ""),
|
|
440
|
+
output: latin1ToText(this.out),
|
|
441
|
+
});
|
|
442
|
+
if (reply === undefined) this.fatal("unable to read from stdin; aborting");
|
|
443
|
+
const c = reply.charAt(0).toLowerCase();
|
|
444
|
+
if (c === "y") return false;
|
|
445
|
+
if (c === "a") {
|
|
446
|
+
this.interactive = undefined;
|
|
447
|
+
return false;
|
|
448
|
+
}
|
|
449
|
+
if (c === "n") return true;
|
|
450
|
+
if (c === "e") {
|
|
451
|
+
if (!this.editor) continue;
|
|
452
|
+
const path = await this.hooks.gitPath(`${DIR}/final-commit`);
|
|
453
|
+
const edited = await this.editor(
|
|
454
|
+
path,
|
|
455
|
+
latin1ToText((await this.read("final-commit")) ?? ""),
|
|
456
|
+
);
|
|
457
|
+
if (edited !== undefined) {
|
|
458
|
+
const text = textToLatin1(edited);
|
|
459
|
+
await this.write("final-commit", text);
|
|
460
|
+
st.msg = text;
|
|
461
|
+
}
|
|
462
|
+
} else if (c === "v") {
|
|
463
|
+
this.out += (await this.read("patch")) ?? "";
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
/** `write_index_patch`: the index's diff from HEAD's tree into `patch`. */
|
|
469
|
+
private async writeIndexPatch(): Promise<void> {
|
|
470
|
+
const head = await this.headId();
|
|
471
|
+
const diff = new DiffCommand(this.workingCopy)
|
|
472
|
+
.setCached(true)
|
|
473
|
+
.setOldTree(head ?? this.objectFormat.emptyTreeId)
|
|
474
|
+
.setRenames(false)
|
|
475
|
+
.setOptions({
|
|
476
|
+
defaultPrefix: true,
|
|
477
|
+
ignoreConfigNoPrefix: true,
|
|
478
|
+
textconv: false,
|
|
479
|
+
uiConfig: false,
|
|
480
|
+
submoduleFormat: "short",
|
|
481
|
+
orderFile: "",
|
|
482
|
+
});
|
|
483
|
+
await this.write("patch", bytesToLatin1(await diff.callBytes("patch")));
|
|
484
|
+
}
|
|
485
|
+
|
|
389
486
|
private state(): OperationState {
|
|
390
487
|
return new OperationState(this.workingCopy.checkout, this.refsStore);
|
|
391
488
|
}
|
|
@@ -472,6 +569,9 @@ export class AmCommand extends GitCommand<AmResult> {
|
|
|
472
569
|
this.fatal(`Stray .git/${DIR} directory found.\nUse "git am --abort" to remove it.`);
|
|
473
570
|
}
|
|
474
571
|
if (this.resume) this.fatal("Resolve operation not in progress, we are not resuming.");
|
|
572
|
+
if (this.interactive && !this.mboxes.length) {
|
|
573
|
+
this.fatal("interactive mode requires patches on the command line");
|
|
574
|
+
}
|
|
475
575
|
return this.setup();
|
|
476
576
|
}
|
|
477
577
|
|
|
@@ -676,13 +776,14 @@ export class AmCommand extends GitCommand<AmResult> {
|
|
|
676
776
|
(await this.patchIsEmpty()) &&
|
|
677
777
|
(await this.indexHasChanges()).length === 0;
|
|
678
778
|
if (bool("advice.mergeConflict") === false && !this.legacyMessages) throw new AmStop(128);
|
|
779
|
+
const cmd = this.interactive ? "git am -i" : "git am";
|
|
679
780
|
const lines = [
|
|
680
|
-
|
|
681
|
-
|
|
781
|
+
`When you have resolved this problem, run "${cmd} --continue".`,
|
|
782
|
+
`If you prefer to skip this patch, run "${cmd} --skip" instead.`,
|
|
682
783
|
...(patchEmptyAndClean
|
|
683
|
-
? [
|
|
784
|
+
? [`To record the empty patch as an empty commit, run "${cmd} --allow-empty".`]
|
|
684
785
|
: []),
|
|
685
|
-
|
|
786
|
+
`To restore the original branch and stop patching, run "${cmd} --abort".`,
|
|
686
787
|
];
|
|
687
788
|
if (this.legacyMessages) this.out += `${lines.join("\n")}\n`;
|
|
688
789
|
else {
|
|
@@ -759,6 +860,11 @@ export class AmCommand extends GitCommand<AmResult> {
|
|
|
759
860
|
);
|
|
760
861
|
await this.write("final-commit", msg);
|
|
761
862
|
}
|
|
863
|
+
if (this.interactive && (await this.doInteractive(st))) {
|
|
864
|
+
await this.next(st);
|
|
865
|
+
resume = false;
|
|
866
|
+
continue;
|
|
867
|
+
}
|
|
762
868
|
let msg = st.msg as string;
|
|
763
869
|
let toKeep = false;
|
|
764
870
|
if (await this.patchIsEmpty()) {
|
|
@@ -1182,6 +1288,13 @@ export class AmCommand extends GitCommand<AmResult> {
|
|
|
1182
1288
|
"You still have unmerged paths in your index.\nYou should 'git add' each file with resolved conflicts to mark them as such.\nYou might run `git rm` on a file to accept \"deleted by them\" for it.\n";
|
|
1183
1289
|
await this.dieUserResolve();
|
|
1184
1290
|
}
|
|
1291
|
+
if (this.interactive) {
|
|
1292
|
+
await this.writeIndexPatch();
|
|
1293
|
+
if (await this.doInteractive(st)) {
|
|
1294
|
+
await this.next(st);
|
|
1295
|
+
return this.amRun(await this.load(), false);
|
|
1296
|
+
}
|
|
1297
|
+
}
|
|
1185
1298
|
await this.doCommit(st);
|
|
1186
1299
|
await this.next(st);
|
|
1187
1300
|
return this.amRun(await this.load(), false);
|
|
@@ -1244,6 +1357,27 @@ export class AmCommand extends GitCommand<AmResult> {
|
|
|
1244
1357
|
}
|
|
1245
1358
|
}
|
|
1246
1359
|
|
|
1360
|
+
/** A read of `git am -i`'s "Apply?" prompt (see `AmCommand.setInteractive`). */
|
|
1361
|
+
export interface AmInteractiveRequest {
|
|
1362
|
+
/** The prompt as git prints it */
|
|
1363
|
+
prompt: string;
|
|
1364
|
+
/** The commit message shown ("Commit Body is:") */
|
|
1365
|
+
message: string;
|
|
1366
|
+
/** What `git am` printed so far on standard output */
|
|
1367
|
+
output: string;
|
|
1368
|
+
}
|
|
1369
|
+
|
|
1370
|
+
/** Answers `git am -i`'s question: the line typed, or undefined at the end of input. */
|
|
1371
|
+
export type AmInteractiveReader = (
|
|
1372
|
+
request: AmInteractiveRequest,
|
|
1373
|
+
) => string | undefined | Promise<string | undefined>;
|
|
1374
|
+
|
|
1375
|
+
/** The editor of `git am -i`'s `e`: the edited message, or undefined when it failed. */
|
|
1376
|
+
export type AmMessageEditor = (
|
|
1377
|
+
path: string,
|
|
1378
|
+
message: string,
|
|
1379
|
+
) => string | undefined | Promise<string | undefined>;
|
|
1380
|
+
|
|
1247
1381
|
interface AmState {
|
|
1248
1382
|
cur: number;
|
|
1249
1383
|
last: number;
|
|
@@ -8,6 +8,8 @@ import { FileMode, isValidWorktreePath } from "@statewalker/vcs-core";
|
|
|
8
8
|
import { mergeLines } from "@statewalker/vcs-utils";
|
|
9
9
|
import { bytesToHex, sha1Of } from "@statewalker/vcs-utils/hash";
|
|
10
10
|
import {
|
|
11
|
+
type AttributesIndex,
|
|
12
|
+
type ContentAttributesContext,
|
|
11
13
|
compareWithWorktree,
|
|
12
14
|
type IndexEntry,
|
|
13
15
|
modeFromWorktree,
|
|
@@ -54,7 +56,7 @@ export interface ApplyResult {
|
|
|
54
56
|
/** Paths left with conflicts by `--3way` */
|
|
55
57
|
conflicts: string[];
|
|
56
58
|
/** With {@link ApplyCommand.setTemporaryIndex}: that index after the patches */
|
|
57
|
-
index?: Map<string, { mode: number; objectId: string }>;
|
|
59
|
+
index?: Map<string, { mode: number; objectId: string; intentToAdd?: boolean }>;
|
|
58
60
|
}
|
|
59
61
|
|
|
60
62
|
/** One patch to apply. */
|
|
@@ -102,7 +104,7 @@ export class ApplyCommand extends GitCommand<ApplyResult> {
|
|
|
102
104
|
private verbosity: ApplyVerbosity = 0;
|
|
103
105
|
private mergeVariant?: "ours" | "theirs" | "union";
|
|
104
106
|
private legacyMessages = false;
|
|
105
|
-
private temporaryIndex?: Map<string, { mode: number; objectId: string }>;
|
|
107
|
+
private temporaryIndex?: Map<string, { mode: number; objectId: string; intentToAdd?: boolean }>;
|
|
106
108
|
|
|
107
109
|
/**
|
|
108
110
|
* Adds a patch. `name` is the patch file's name as git shows it in messages (the file
|
|
@@ -303,7 +305,9 @@ export class ApplyCommand extends GitCommand<ApplyResult> {
|
|
|
303
305
|
* Applies to this index instead of the repository's (`--cached` with git's
|
|
304
306
|
* `index_file`, as `git am --3way` applies to its fake ancestor); the result has it.
|
|
305
307
|
*/
|
|
306
|
-
setTemporaryIndex(
|
|
308
|
+
setTemporaryIndex(
|
|
309
|
+
index: Map<string, { mode: number; objectId: string; intentToAdd?: boolean }>,
|
|
310
|
+
): this {
|
|
307
311
|
this.temporaryIndex = new Map(index);
|
|
308
312
|
this.cached = true;
|
|
309
313
|
return this;
|
|
@@ -360,6 +364,7 @@ export class ApplyCommand extends GitCommand<ApplyResult> {
|
|
|
360
364
|
attributes?: (
|
|
361
365
|
path: string,
|
|
362
366
|
names?: readonly string[],
|
|
367
|
+
context?: ContentAttributesContext,
|
|
363
368
|
) => Promise<Map<string, true | false | string | undefined>>;
|
|
364
369
|
checkin?: (path: string) => Promise<
|
|
365
370
|
| {
|
|
@@ -384,6 +389,7 @@ export class ApplyCommand extends GitCommand<ApplyResult> {
|
|
|
384
389
|
mode: e.mode,
|
|
385
390
|
objectId: e.objectId,
|
|
386
391
|
stage: 0,
|
|
392
|
+
...(e.intentToAdd ? { intentToAdd: true } : {}),
|
|
387
393
|
} as IndexEntry);
|
|
388
394
|
return indexEntries;
|
|
389
395
|
}
|
|
@@ -406,7 +412,14 @@ export class ApplyCommand extends GitCommand<ApplyResult> {
|
|
|
406
412
|
async (name) => {
|
|
407
413
|
let attr: true | false | string | undefined;
|
|
408
414
|
try {
|
|
409
|
-
|
|
415
|
+
// whitespace_rule's own attribute check: its stack is not convert.c's, which is
|
|
416
|
+
// built on the first conversion (a racy entry's check, else the first write)
|
|
417
|
+
attr = (
|
|
418
|
+
await filter?.attributes?.(toPath(name), ["whitespace"], {
|
|
419
|
+
direction: "checkin",
|
|
420
|
+
check: "whitespace",
|
|
421
|
+
})
|
|
422
|
+
)?.get("whitespace");
|
|
410
423
|
} catch {
|
|
411
424
|
attr = undefined;
|
|
412
425
|
}
|
|
@@ -502,13 +515,34 @@ export class ApplyCommand extends GitCommand<ApplyResult> {
|
|
|
502
515
|
name: p.name ?? "<stdin>",
|
|
503
516
|
fromFile: p.name !== undefined,
|
|
504
517
|
}));
|
|
505
|
-
|
|
518
|
+
// the attributes files of the index as apply.c's istate holds them while it writes:
|
|
519
|
+
// remove_file_from_index in the first phase, add_index_entry after each file written
|
|
520
|
+
const editedIndex: AttributesIndex | undefined = this.temporaryIndex
|
|
521
|
+
? undefined
|
|
522
|
+
: {
|
|
523
|
+
attributesBlob: async (path) => {
|
|
524
|
+
const changed = engine.indexChanges.get(pathToLatin1(path));
|
|
525
|
+
if (changed)
|
|
526
|
+
return (changed.find((e) => !e.stage) ?? changed.find((e) => e.stage === 2))?.oid;
|
|
527
|
+
const entry = (await staging.getEntry(path, 0)) ?? (await staging.getEntry(path, 2));
|
|
528
|
+
return entry?.objectId;
|
|
529
|
+
},
|
|
530
|
+
};
|
|
531
|
+
const { status, writeIndex } = await this.inOneOperation(
|
|
532
|
+
() => engine.applyAll(inputs),
|
|
533
|
+
editedIndex ? { keepAttributes: true, index: editedIndex } : { keepAttributes: true },
|
|
534
|
+
);
|
|
506
535
|
if (writeIndex && this.temporaryIndex) {
|
|
507
536
|
for (const [name, entries] of engine.indexChanges) {
|
|
508
537
|
const path = toPath(name);
|
|
509
538
|
const e = entries.find((x) => !x.stage);
|
|
510
|
-
if (e)
|
|
511
|
-
|
|
539
|
+
if (e) {
|
|
540
|
+
this.temporaryIndex.set(path, {
|
|
541
|
+
mode: e.mode,
|
|
542
|
+
objectId: e.oid,
|
|
543
|
+
...(e.intentToAdd ? { intentToAdd: true } : {}),
|
|
544
|
+
});
|
|
545
|
+
} else this.temporaryIndex.delete(path);
|
|
512
546
|
}
|
|
513
547
|
} else if (writeIndex && engine.indexChanges.size) {
|
|
514
548
|
const changes = new Map<string, IndexEntryInput[]>();
|
|
@@ -541,7 +575,8 @@ export class ApplyCommand extends GitCommand<ApplyResult> {
|
|
|
541
575
|
|
|
542
576
|
private makeIO(
|
|
543
577
|
worktree: Worktree | undefined,
|
|
544
|
-
|
|
578
|
+
/** worktreeModeTrust: modes, and what ce_match_stat_basic compares (ctime, fullStat) */
|
|
579
|
+
trust: { executable?: boolean; symlinks?: boolean; ctime?: boolean; fullStat?: boolean },
|
|
545
580
|
filter:
|
|
546
581
|
| {
|
|
547
582
|
checkin?: (path: string) => Promise<
|
|
@@ -644,8 +679,16 @@ export class ApplyCommand extends GitCommand<ApplyResult> {
|
|
|
644
679
|
if (isGitlink(entry.mode)) return st !== undefined && (st.mode & 0o170000) === S_IFDIR;
|
|
645
680
|
const staged = await this.staging.getEntry(toPath(name));
|
|
646
681
|
if (!staged) return false;
|
|
682
|
+
// ie_match_stat: a file whose stat matches an entry older than the index is clean
|
|
683
|
+
// unread; only a racy one is read (and converted, building convert.c's stack). The
|
|
684
|
+
// stat compared is core.trustctime's and core.checkStat's (ctime, inode and owner)
|
|
647
685
|
const cmp = await compareWithWorktree(worktree, staged, {
|
|
648
|
-
trust: {
|
|
686
|
+
trust: {
|
|
687
|
+
...trust,
|
|
688
|
+
executable: trust.executable !== false,
|
|
689
|
+
symlinks: trust.symlinks !== false,
|
|
690
|
+
},
|
|
691
|
+
indexTime: this.staging.getUpdateTime(),
|
|
649
692
|
});
|
|
650
693
|
return cmp.kind === undefined;
|
|
651
694
|
},
|
|
@@ -632,6 +632,16 @@ export class ApplyParser {
|
|
|
632
632
|
return 1;
|
|
633
633
|
}
|
|
634
634
|
|
|
635
|
+
/**
|
|
636
|
+
* `parse_git_diff_header` for a reader of `git log -p` output (range-diff's
|
|
637
|
+
* `read_patches`): the header starting with the `diff --git` line at `at` (`len` bytes)
|
|
638
|
+
* read into `patch`, with at most `size` bytes left; its length, or a negative number when
|
|
639
|
+
* git refuses it. Names are taken whole (`p_value` 0, no root).
|
|
640
|
+
*/
|
|
641
|
+
readGitDiffHeader(buf: string, at: number, len: number, size: number, patch: FilePatch): number {
|
|
642
|
+
return this.parseGitDiffHeader(buf, at, len, size, patch);
|
|
643
|
+
}
|
|
644
|
+
|
|
635
645
|
/** `parse_git_diff_header`: the header's length, or -128. */
|
|
636
646
|
private parseGitDiffHeader(
|
|
637
647
|
buf: string,
|
|
@@ -2,4 +2,11 @@ export * from "./apply-command.js";
|
|
|
2
2
|
export type { ApplyIndexEntry, ApplyInput, ApplyIO } from "./apply-engine.js";
|
|
3
3
|
export { ApplyEngine } from "./apply-engine.js";
|
|
4
4
|
export type { FilePatch, PatchFragment, WsErrorAction } from "./apply-types.js";
|
|
5
|
-
export {
|
|
5
|
+
export {
|
|
6
|
+
bytesToLatin1,
|
|
7
|
+
latin1ToBytes,
|
|
8
|
+
latin1ToPath,
|
|
9
|
+
latin1ToText,
|
|
10
|
+
pathToLatin1,
|
|
11
|
+
textToLatin1,
|
|
12
|
+
} from "./latin1.js";
|