@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
|
@@ -30,6 +30,7 @@ import {
|
|
|
30
30
|
} from "./merge-support.js";
|
|
31
31
|
import { resetMerge } from "./sequencer-support.js";
|
|
32
32
|
import { pushSparseWarnings, SparseUnpack } from "./sparse-checkout-support.js";
|
|
33
|
+
import { recursesIntoSubmodules, SubmoduleUnpack } from "./submodule-unpack.js";
|
|
33
34
|
import { restoreCaseOptions, writeTreeRestorePlan } from "./tree-restore.js";
|
|
34
35
|
import {
|
|
35
36
|
type CheckedEntry,
|
|
@@ -89,6 +90,9 @@ export class ReadTreeCommand extends GitCommand<ReadTreeResult> {
|
|
|
89
90
|
private trivial = false;
|
|
90
91
|
private aggressive = false;
|
|
91
92
|
private skipSparseCheckout = false;
|
|
93
|
+
private recurseSubmodules?: boolean;
|
|
94
|
+
private dryRun = false;
|
|
95
|
+
private superPrefix = "";
|
|
92
96
|
|
|
93
97
|
/** A tree-ish to read (up to eight). */
|
|
94
98
|
addTree(treeish: string): this {
|
|
@@ -162,6 +166,30 @@ export class ReadTreeCommand extends GitCommand<ReadTreeResult> {
|
|
|
162
166
|
return this;
|
|
163
167
|
}
|
|
164
168
|
|
|
169
|
+
/**
|
|
170
|
+
* `--[no-]recurse-submodules` (default `submodule.recurse`): the active submodules' worktrees
|
|
171
|
+
* are checked and moved with the superproject's (unpack-trees' `check_submodule_move_head`,
|
|
172
|
+
* entry.c's `submodule_move_head`).
|
|
173
|
+
*/
|
|
174
|
+
setRecurseSubmodules(recurse: boolean): this {
|
|
175
|
+
this.checkCallable();
|
|
176
|
+
this.recurseSubmodules = recurse;
|
|
177
|
+
return this;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/** `-n` / `--dry-run`: everything checked, neither the index nor the worktree written. */
|
|
181
|
+
setDryRun(dryRun: boolean): this {
|
|
182
|
+
this.checkCallable();
|
|
183
|
+
this.dryRun = dryRun;
|
|
184
|
+
return this;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/** @internal git's `--super-prefix`: the submodule's path in its superproject, in messages. */
|
|
188
|
+
setSuperPrefix(prefix: string): this {
|
|
189
|
+
this.superPrefix = prefix;
|
|
190
|
+
return this;
|
|
191
|
+
}
|
|
192
|
+
|
|
165
193
|
/** `--no-sparse-checkout`: the sparse-checkout patterns are not applied. */
|
|
166
194
|
setSkipSparseCheckout(skip: boolean): this {
|
|
167
195
|
this.checkCallable();
|
|
@@ -172,6 +200,18 @@ export class ReadTreeCommand extends GitCommand<ReadTreeResult> {
|
|
|
172
200
|
async call(): Promise<ReadTreeResult> {
|
|
173
201
|
// a tree entry the decoder refuses (`..`, `/` in a name, an empty name): git's message
|
|
174
202
|
const trees: ObjectId[] = [];
|
|
203
|
+
if (this.dryRun) {
|
|
204
|
+
// -n: nothing the run changed in memory outlives it
|
|
205
|
+
try {
|
|
206
|
+
return await this.callChecked(trees);
|
|
207
|
+
} finally {
|
|
208
|
+
await this.staging.read();
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
return this.callChecked(trees);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
private callChecked(trees: ObjectId[]): Promise<ReadTreeResult> {
|
|
175
215
|
return withTreePathRefusal(
|
|
176
216
|
this.trees,
|
|
177
217
|
() => trees,
|
|
@@ -252,8 +292,28 @@ export class ReadTreeCommand extends GitCommand<ReadTreeResult> {
|
|
|
252
292
|
sparseWarnings: result.warnings,
|
|
253
293
|
};
|
|
254
294
|
const refused = (message: string | undefined, paths: string[] = []) => {
|
|
255
|
-
if (message)
|
|
295
|
+
if (!message) return;
|
|
296
|
+
// --super-prefix: the paths as the superproject names them
|
|
297
|
+
let text = message;
|
|
298
|
+
if (this.superPrefix) {
|
|
299
|
+
for (const p of new Set(paths)) {
|
|
300
|
+
text = text.split(`'${p}'`).join(`'${this.superPrefix}${p}'`);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
throw new ReadTreeFailedError(text, paths);
|
|
256
304
|
};
|
|
305
|
+
// unpack-trees' submodule support (only for the merges that update or check the worktree)
|
|
306
|
+
const submodules =
|
|
307
|
+
merge && !prefixSet && treeIds.length <= 2 && !this.indexOnly
|
|
308
|
+
? await SubmoduleUnpack.start(this.workingCopy, {
|
|
309
|
+
recurse: recursesIntoSubmodules(this.workingCopy, this.recurseSubmodules),
|
|
310
|
+
reset: this.reset,
|
|
311
|
+
superPrefix: this.superPrefix,
|
|
312
|
+
})
|
|
313
|
+
: undefined;
|
|
314
|
+
// -n keeps o->update: the checks an update makes still run, nothing is written
|
|
315
|
+
const update = this.update;
|
|
316
|
+
const dryRunOptions = this.dryRun ? { writeIndex: false, checkOnly: true } : {};
|
|
257
317
|
|
|
258
318
|
if (!merge) {
|
|
259
319
|
await this.readWithoutMerge(treeIds);
|
|
@@ -264,7 +324,9 @@ export class ReadTreeCommand extends GitCommand<ReadTreeResult> {
|
|
|
264
324
|
const tree = treeIds[0] as ObjectId;
|
|
265
325
|
const refusal = await resetMerge(sequencerCtx, tree, tree, {
|
|
266
326
|
hard: this.reset,
|
|
267
|
-
update
|
|
327
|
+
update,
|
|
328
|
+
submodules,
|
|
329
|
+
...dryRunOptions,
|
|
268
330
|
overwriteUntracked: this.reset,
|
|
269
331
|
skipSparseCheckout: this.skipSparseCheckout,
|
|
270
332
|
targetTree: tree,
|
|
@@ -280,7 +342,9 @@ export class ReadTreeCommand extends GitCommand<ReadTreeResult> {
|
|
|
280
342
|
{
|
|
281
343
|
action: "merge",
|
|
282
344
|
operation: "read-tree",
|
|
283
|
-
update
|
|
345
|
+
update,
|
|
346
|
+
submodules,
|
|
347
|
+
...dryRunOptions,
|
|
284
348
|
skipSparseCheckout: this.skipSparseCheckout,
|
|
285
349
|
plainErrors: true,
|
|
286
350
|
initialCheckout: await isIndexUnborn(this.staging),
|
|
@@ -293,6 +357,7 @@ export class ReadTreeCommand extends GitCommand<ReadTreeResult> {
|
|
|
293
357
|
|
|
294
358
|
// read-tree starts from no cache-tree and resolve-undo (cache_tree_free,
|
|
295
359
|
// resolve_undo_clear_index); one tree read whole primes it
|
|
360
|
+
if (this.dryRun) return result;
|
|
296
361
|
this.staging.clearResolveUndo?.();
|
|
297
362
|
if (treeIds.length === 1 && !prefixSet) {
|
|
298
363
|
this.staging.setCacheTree?.(await cacheTreeOfTree(this.trees, treeIds[0] as ObjectId));
|
|
@@ -415,6 +480,7 @@ export class ReadTreeCommand extends GitCommand<ReadTreeResult> {
|
|
|
415
480
|
}
|
|
416
481
|
}
|
|
417
482
|
const checking = traversalOrder(target.keys());
|
|
483
|
+
// -n keeps o->update: the checks run, nothing is written
|
|
418
484
|
const worktree = this.update ? ctx.worktree : undefined;
|
|
419
485
|
const sparse = worktree && !this.skipSparseCheckout ? await SparseUnpack.start(ctx) : undefined;
|
|
420
486
|
const trust = worktree ? worktreeModeTrust(this.workingCopy, worktree) : undefined;
|
|
@@ -454,6 +520,8 @@ export class ReadTreeCommand extends GitCommand<ReadTreeResult> {
|
|
|
454
520
|
const stage0 = new Set<string>(paths);
|
|
455
521
|
for (const p of index.keys()) if (!dropped.has(p)) stage0.add(p);
|
|
456
522
|
assertNoStageZeroClash(stage0);
|
|
523
|
+
// -n: every check made, neither worktree nor index written
|
|
524
|
+
if (this.dryRun) return;
|
|
457
525
|
|
|
458
526
|
const writing = new Set(paths.filter((p) => !sparse || sparse.writes(p)));
|
|
459
527
|
if (worktree) {
|
|
@@ -555,6 +623,7 @@ export class ReadTreeCommand extends GitCommand<ReadTreeResult> {
|
|
|
555
623
|
const indexEntries = new Map<string, StagingEntry>();
|
|
556
624
|
for (const e of await this.entryList()) if (e.stage === 0) indexEntries.set(e.path, e);
|
|
557
625
|
const checkedWorktree = ctx.worktree;
|
|
626
|
+
// -n keeps o->update: the checks run, nothing is written
|
|
558
627
|
const worktree = this.update ? checkedWorktree : undefined;
|
|
559
628
|
const sparse = worktree && !this.skipSparseCheckout ? await SparseUnpack.start(ctx) : undefined;
|
|
560
629
|
const quiet = (p: string) => sparse?.leavesAlone(p) === true;
|
|
@@ -735,6 +804,8 @@ export class ReadTreeCommand extends GitCommand<ReadTreeResult> {
|
|
|
735
804
|
for (const p of indexEntries.keys()) if (!changes.has(p)) stage0.add(p);
|
|
736
805
|
for (const [p, list] of changes) if (list.some((e) => !e.stage)) stage0.add(p);
|
|
737
806
|
assertNoStageZeroClash(stage0);
|
|
807
|
+
// -n: every check made, neither worktree nor index written
|
|
808
|
+
if (this.dryRun) return;
|
|
738
809
|
|
|
739
810
|
// the worktree: removals first, then the files written
|
|
740
811
|
sparse?.conflict(conflicted);
|
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
import { GitCommand } from "../git-command.js";
|
|
24
24
|
import { RemoteConfigStore } from "../remote-config/index.js";
|
|
25
25
|
import {
|
|
26
|
-
|
|
26
|
+
ContentMergeStrategy,
|
|
27
27
|
FastForwardMode,
|
|
28
28
|
type MergeResult,
|
|
29
29
|
MergeStatus,
|
|
@@ -48,6 +48,7 @@ import { commitsBaseSource, MergeBaseGraph } from "./merge-bases.js";
|
|
|
48
48
|
import { favorOf, MergeCommand } from "./merge-command.js";
|
|
49
49
|
import { configBool, configValue, conflictStyleOf } from "./merge-config.js";
|
|
50
50
|
import { ortConfigOptions } from "./merge-drivers.js";
|
|
51
|
+
import { quoteStrategyOptions, splitStrategyOptions } from "./merge-strategy-options.js";
|
|
51
52
|
import {
|
|
52
53
|
conflictsComment,
|
|
53
54
|
FlatTreeCache,
|
|
@@ -64,8 +65,8 @@ import {
|
|
|
64
65
|
import { CleanupMode, commentPrefixOf, stripspace } from "./message-cleanup.js";
|
|
65
66
|
import { copyNotesForAmend, copyNotesForRebase } from "./notes-support.js";
|
|
66
67
|
import { ortResultEntries } from "./ort-merge.js";
|
|
67
|
-
import { mergeBaseTree, mergeStoredTrees
|
|
68
|
-
import { type PatchIdTrees
|
|
68
|
+
import { mergeBaseTree, mergeStoredTrees } from "./ort-recursive.js";
|
|
69
|
+
import { PatchIds, type PatchIdTrees } from "./patch-id.js";
|
|
69
70
|
import { formatCommitPretty, loadRefDecorations, type RefDecorations } from "./pretty-format.js";
|
|
70
71
|
import {
|
|
71
72
|
addExecCommands,
|
|
@@ -90,7 +91,7 @@ import {
|
|
|
90
91
|
} from "./rebase-todo.js";
|
|
91
92
|
import { reflogMessages, updateHeadExpecting } from "./reflog-messages.js";
|
|
92
93
|
import { revisionMergeBases } from "./rev-parse-command.js";
|
|
93
|
-
import { expandCommitId } from "./sequencer-pick.js";
|
|
94
|
+
import { expandCommitId, mergePickChange } from "./sequencer-pick.js";
|
|
94
95
|
import {
|
|
95
96
|
AUTOSTASH_SAVED_LINES,
|
|
96
97
|
applyAutostash,
|
|
@@ -309,7 +310,12 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
309
310
|
private upstreamCommit?: ObjectId;
|
|
310
311
|
private upstreamCommitName?: string;
|
|
311
312
|
private strategy = MergeStrategy.RECURSIVE;
|
|
313
|
+
private strategyGiven = false;
|
|
312
314
|
private contentStrategy?: ContentMergeStrategy;
|
|
315
|
+
/** `-X <option>`s */
|
|
316
|
+
private strategyOptions: string[] = [];
|
|
317
|
+
/** The run's `-s` and `-X` (rebase-merge/strategy, strategy_opts), once read */
|
|
318
|
+
private runStrategyState?: { strategy?: string; xopts: string[] };
|
|
313
319
|
private preserveMerges = false;
|
|
314
320
|
private interactiveHandler?: InteractiveHandler;
|
|
315
321
|
/** Whose messages to give where git 2.43 and 2.5x differ (default: the hooks') */
|
|
@@ -542,16 +548,70 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
542
548
|
}
|
|
543
549
|
|
|
544
550
|
/**
|
|
545
|
-
* Set the merge strategy (
|
|
551
|
+
* Set the merge strategy (`-s`): merge-ort (RECURSIVE, ORT), RESOLVE (git-merge-resolve)
|
|
552
|
+
* or SUBTREE (git merge-subtree) for each pick; kept in `rebase-merge/strategy`.
|
|
546
553
|
*
|
|
547
554
|
* @param strategy Merge strategy
|
|
548
555
|
*/
|
|
549
556
|
setStrategy(strategy: MergeStrategy): this {
|
|
550
557
|
this.checkCallable();
|
|
551
558
|
this.strategy = strategy;
|
|
559
|
+
this.strategyGiven = true;
|
|
552
560
|
return this;
|
|
553
561
|
}
|
|
554
562
|
|
|
563
|
+
/**
|
|
564
|
+
* The `-X <option>`s of each pick (see `MergeCommand.setStrategyOptions`), kept in
|
|
565
|
+
* `rebase-merge/strategy_opts`; with no `-s`, the strategy is `ort` (builtin/rebase.c).
|
|
566
|
+
*/
|
|
567
|
+
setStrategyOptions(options: readonly string[]): this {
|
|
568
|
+
this.checkCallable();
|
|
569
|
+
this.strategyOptions = [...options];
|
|
570
|
+
return this;
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
/** Adds one `-X <option>` (see {@link setStrategyOptions}). */
|
|
574
|
+
addStrategyOption(option: string): this {
|
|
575
|
+
this.checkCallable();
|
|
576
|
+
this.strategyOptions.push(option);
|
|
577
|
+
return this;
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
/** The `-X` options as given: `-X ours`/`-X theirs` of the content strategy first. */
|
|
581
|
+
private givenStrategyOptions(): string[] {
|
|
582
|
+
const favor =
|
|
583
|
+
this.contentStrategy === ContentMergeStrategy.OURS
|
|
584
|
+
? ["ours"]
|
|
585
|
+
: this.contentStrategy === ContentMergeStrategy.THEIRS
|
|
586
|
+
? ["theirs"]
|
|
587
|
+
: [];
|
|
588
|
+
return [...favor, ...this.strategyOptions];
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
/** The run's `-s` (`ort` when only `-X` was given) as builtin/rebase.c settles it. */
|
|
592
|
+
private givenStrategyName(): string | undefined {
|
|
593
|
+
if (this.strategyGiven) return this.strategy;
|
|
594
|
+
return this.givenStrategyOptions().length > 0 ? "ort" : undefined;
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
/** The run's `-s` and `-X`: read back from `rebase-merge/` (read_strategy_opts), else given. */
|
|
598
|
+
private async runStrategy(
|
|
599
|
+
state: OperationState,
|
|
600
|
+
): Promise<{ strategy: string | undefined; xopts: string[] }> {
|
|
601
|
+
if (!this.runStrategyState) {
|
|
602
|
+
const strategy = (await state.read(`${DIR}/strategy`))?.trim();
|
|
603
|
+
const opts = await state.read(`${DIR}/strategy_opts`);
|
|
604
|
+
this.runStrategyState =
|
|
605
|
+
strategy !== undefined || opts !== undefined
|
|
606
|
+
? {
|
|
607
|
+
...(strategy ? { strategy } : {}),
|
|
608
|
+
xopts: opts !== undefined ? splitStrategyOptions(opts.trim()) : [],
|
|
609
|
+
}
|
|
610
|
+
: { strategy: this.givenStrategyName(), xopts: this.givenStrategyOptions() };
|
|
611
|
+
}
|
|
612
|
+
return { strategy: this.runStrategyState.strategy, xopts: this.runStrategyState.xopts };
|
|
613
|
+
}
|
|
614
|
+
|
|
555
615
|
/**
|
|
556
616
|
* Get the merge strategy.
|
|
557
617
|
*/
|
|
@@ -1431,6 +1491,13 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
1431
1491
|
await state.write(`${DIR}/head-name`, `${headName}\n`);
|
|
1432
1492
|
await state.write(`${DIR}/onto`, `${onto}\n`);
|
|
1433
1493
|
await state.write(`${DIR}/orig-head`, `${origHead}\n`);
|
|
1494
|
+
// write_basic_state: strategy, strategy_opts
|
|
1495
|
+
const strategyName = this.givenStrategyName();
|
|
1496
|
+
if (strategyName) await state.write(`${DIR}/strategy`, `${strategyName}\n`);
|
|
1497
|
+
const xopts = this.givenStrategyOptions();
|
|
1498
|
+
if (xopts.length > 0) {
|
|
1499
|
+
await state.write(`${DIR}/strategy_opts`, `${quoteStrategyOptions(xopts)}\n`);
|
|
1500
|
+
}
|
|
1434
1501
|
// write_basic_state: gpg_sign_opt (`-S<key>`) when the run signs
|
|
1435
1502
|
const sign = signRequestOf(this.workingCopy, this.sign);
|
|
1436
1503
|
this.runSign = { key: sign };
|
|
@@ -1989,34 +2056,48 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
1989
2056
|
const short = await this.abbreviateObjectId(item.id);
|
|
1990
2057
|
const label = `${short} (${subject})`;
|
|
1991
2058
|
const baseLabel = parentId ? `parent of ${label}` : "(empty tree)";
|
|
1992
|
-
// the trees as merge-ort reads them: what all three hold alike is never read
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
headTreeId,
|
|
1997
|
-
commit.tree,
|
|
2059
|
+
// the trees as merge-ort reads them: what all three hold alike is never read; `-s`
|
|
2060
|
+
// and `-X` as the sequencer gives them to the pick
|
|
2061
|
+
const { strategy, xopts } = await this.runStrategy(state);
|
|
2062
|
+
const merge = await mergePickChange(
|
|
1998
2063
|
{
|
|
1999
|
-
|
|
2000
|
-
|
|
2064
|
+
...this.context(worktree),
|
|
2065
|
+
commits: this.commits,
|
|
2066
|
+
flats,
|
|
2067
|
+
abbreviate: (id) => this.abbreviateObjectId(id),
|
|
2068
|
+
},
|
|
2069
|
+
{
|
|
2070
|
+
action: "pick",
|
|
2071
|
+
headId,
|
|
2072
|
+
headTreeId,
|
|
2073
|
+
base: parentTreeId,
|
|
2074
|
+
theirs: commit.tree,
|
|
2001
2075
|
baseLabel,
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2076
|
+
theirsLabel: label,
|
|
2077
|
+
pickId: item.id,
|
|
2078
|
+
parentId,
|
|
2079
|
+
strategy,
|
|
2080
|
+
xopts,
|
|
2081
|
+
oursLabel: "HEAD",
|
|
2082
|
+
favor: this.contentStrategy === ContentMergeStrategy.UNION ? "union" : undefined,
|
|
2083
|
+
compatibility: this.compatibility ?? this.hooks.compatibility ?? "2.56",
|
|
2006
2084
|
},
|
|
2007
|
-
(id) => flats.get(id),
|
|
2008
2085
|
);
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2086
|
+
if ("failed" in merge) {
|
|
2087
|
+
output.push(...(merge.output ?? []));
|
|
2088
|
+
return {
|
|
2089
|
+
kind: "reschedule",
|
|
2090
|
+
result: { status: RebaseStatus.FAILED, currentCommit: item.id, message: merge.failed },
|
|
2091
|
+
};
|
|
2092
|
+
}
|
|
2093
|
+
const { treeId, conflicts } = merge;
|
|
2013
2094
|
// only the paths HEAD and the result differ on are switched
|
|
2014
|
-
const delta = await treeDelta(this.trees, headTreeId, treeId);
|
|
2095
|
+
const delta = merge.delta ?? (await treeDelta(this.trees, headTreeId, treeId));
|
|
2015
2096
|
const refused = await switchTrees(this.context(worktree), delta.from, delta.to, {
|
|
2016
2097
|
action: "merge",
|
|
2017
2098
|
operation: "rebase",
|
|
2018
2099
|
conflicts,
|
|
2019
|
-
targetTree: treeId,
|
|
2100
|
+
...(merge.delta ? {} : { targetTree: treeId }),
|
|
2020
2101
|
});
|
|
2021
2102
|
if (refused) {
|
|
2022
2103
|
// nothing written: the pick is rescheduled (git keeps the author and REBASE_HEAD)
|
|
@@ -2031,13 +2112,18 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
2031
2112
|
},
|
|
2032
2113
|
};
|
|
2033
2114
|
}
|
|
2034
|
-
// the sequencer shows merge-ort's messages of a rebase only when the pick conflicts
|
|
2035
|
-
|
|
2036
|
-
|
|
2115
|
+
// the sequencer shows merge-ort's messages of a rebase only when the pick conflicts (an
|
|
2116
|
+
// external strategy prints its own)
|
|
2117
|
+
if (merge.external || conflicts.length > 0 || !merge.clean) output.push(...merge.messages);
|
|
2118
|
+
if (merge.autoMerge) await state.setRef("AUTO_MERGE", treeId);
|
|
2037
2119
|
const merged = pickedMessage.endsWith("\n") ? pickedMessage : `${pickedMessage}\n`;
|
|
2038
2120
|
if (conflicts.length > 0 || !merge.clean) {
|
|
2039
2121
|
const paths = [...new Set(conflicts.map((c) => c.stagePath))].sort(compareGitPaths);
|
|
2040
|
-
|
|
2122
|
+
// do_recursive_merge adds the conflicts hint; another strategy's MERGE_MSG has none
|
|
2123
|
+
await state.write(
|
|
2124
|
+
"MERGE_MSG",
|
|
2125
|
+
merge.external ? merged : `${merged}${conflictsComment(paths, true)}`,
|
|
2126
|
+
);
|
|
2041
2127
|
if (!fixup) {
|
|
2042
2128
|
// do_pick_commit writes CHERRY_PICK_HEAD after a conflicted merge too; the rebase
|
|
2043
2129
|
// stopping there deletes it again (REBASE_HEAD names the commit instead)
|
|
@@ -2045,9 +2131,13 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
2045
2131
|
}
|
|
2046
2132
|
return {
|
|
2047
2133
|
kind: "conflicts",
|
|
2048
|
-
conflicts: [...new Set(merge.
|
|
2049
|
-
// git 2.43 writes the message and a blank line (2.5x the conflict list after it
|
|
2050
|
-
|
|
2134
|
+
conflicts: [...new Set(merge.conflictPaths)].sort(),
|
|
2135
|
+
// git 2.43 writes the message and a blank line (2.5x the conflict list after it, which
|
|
2136
|
+
// another strategy than merge-ort does not add)
|
|
2137
|
+
message:
|
|
2138
|
+
!merge.external || (this.compatibility ?? this.hooks.compatibility) === "2.43"
|
|
2139
|
+
? `${merged}\n`
|
|
2140
|
+
: merged,
|
|
2051
2141
|
lines: [`error: could not apply ${short}... ${subject}`, ...this.mergeConflictAdvice()],
|
|
2052
2142
|
};
|
|
2053
2143
|
}
|
|
@@ -4605,41 +4695,27 @@ export class RebaseCommand extends GitCommand<RebaseResult> {
|
|
|
4605
4695
|
},
|
|
4606
4696
|
};
|
|
4607
4697
|
const loadTree = (id: ObjectId) => this.trees.loadTree(id);
|
|
4608
|
-
|
|
4609
|
-
|
|
4610
|
-
|
|
4611
|
-
|
|
4612
|
-
|
|
4613
|
-
|
|
4614
|
-
|
|
4615
|
-
|
|
4616
|
-
|
|
4617
|
-
|
|
4618
|
-
|
|
4619
|
-
|
|
4620
|
-
|
|
4621
|
-
|
|
4622
|
-
|
|
4623
|
-
|
|
4624
|
-
|
|
4625
|
-
const
|
|
4626
|
-
for (const id of range) {
|
|
4627
|
-
const header = await patchIdOf(id, true);
|
|
4628
|
-
if (!header) continue;
|
|
4629
|
-
const list = byHeader.get(header) ?? [];
|
|
4630
|
-
list.push(id);
|
|
4631
|
-
byHeader.set(header, list);
|
|
4632
|
-
}
|
|
4633
|
-
if (byHeader.size === 0) return skipped;
|
|
4698
|
+
// HEAD's side added, upstream's looked up (patch-ids.c)
|
|
4699
|
+
const ids = new PatchIds<ObjectId>({
|
|
4700
|
+
trees,
|
|
4701
|
+
blobs: this.blobs,
|
|
4702
|
+
objectFormat: this.objectFormat,
|
|
4703
|
+
change: async (id) => {
|
|
4704
|
+
const commit = await this.loadCommit(id);
|
|
4705
|
+
if (!commit || commit.parents.length > 1) return undefined;
|
|
4706
|
+
const parentTree = commit.parents[0]
|
|
4707
|
+
? (await this.loadCommit(commit.parents[0]))?.tree
|
|
4708
|
+
: undefined;
|
|
4709
|
+
return { ...(parentTree ? { parentTree } : {}), tree: commit.tree };
|
|
4710
|
+
},
|
|
4711
|
+
});
|
|
4712
|
+
let added = 0;
|
|
4713
|
+
for (const id of range) if (await ids.add(id)) added++;
|
|
4714
|
+
if (added === 0) return skipped;
|
|
4715
|
+
const empty = this.objectFormat.nullId;
|
|
4634
4716
|
for (const id of left) {
|
|
4635
|
-
|
|
4636
|
-
const
|
|
4637
|
-
if (!candidates) continue;
|
|
4638
|
-
const mine = await fullOf(id);
|
|
4639
|
-
if (!mine) continue;
|
|
4640
|
-
for (const c of candidates) {
|
|
4641
|
-
if (!skipped.has(c) && (await fullOf(c)) === mine) skipped.add(c);
|
|
4642
|
-
}
|
|
4717
|
+
// make_script never skips a commit empty from the start
|
|
4718
|
+
for (const c of await ids.matches(id)) if ((await ids.fullId(c)) !== empty) skipped.add(c);
|
|
4643
4719
|
}
|
|
4644
4720
|
return skipped;
|
|
4645
4721
|
}
|