@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
|
@@ -18,6 +18,10 @@ import {
|
|
|
18
18
|
type WorktreeEntry,
|
|
19
19
|
} from "@statewalker/vcs-working-tree";
|
|
20
20
|
import {
|
|
21
|
+
EMPTY_AMEND_ADVICE,
|
|
22
|
+
EMPTY_CHERRY_PICK_ADVICE,
|
|
23
|
+
EMPTY_CHERRY_PICK_ADVICE_SINGLE,
|
|
24
|
+
EMPTY_REBASE_PICK_ADVICE,
|
|
21
25
|
EmptyCommitError,
|
|
22
26
|
GitApiError,
|
|
23
27
|
HookFailedError,
|
|
@@ -66,6 +70,7 @@ import { reencodedCommitParts } from "./log-output.js";
|
|
|
66
70
|
import {
|
|
67
71
|
flatTree,
|
|
68
72
|
OperationState,
|
|
73
|
+
peelMergeHeads,
|
|
69
74
|
rewriteIndex,
|
|
70
75
|
updateIndexCacheTree,
|
|
71
76
|
writeIndexAsTree,
|
|
@@ -128,6 +133,11 @@ export interface CommitResult extends Commit {
|
|
|
128
133
|
* when it said nothing
|
|
129
134
|
*/
|
|
130
135
|
rerereOutput?: string[];
|
|
136
|
+
/**
|
|
137
|
+
* What git printed on stderr as it started, line by line: git 2.5x's
|
|
138
|
+
* `core.commentChar=auto` deprecation warning and its advice. Absent when it said nothing.
|
|
139
|
+
*/
|
|
140
|
+
warnings?: string[];
|
|
131
141
|
}
|
|
132
142
|
|
|
133
143
|
/**
|
|
@@ -598,7 +608,11 @@ export class CommitCommand extends GitCommand<CommitResult> {
|
|
|
598
608
|
return this;
|
|
599
609
|
}
|
|
600
610
|
|
|
601
|
-
/**
|
|
611
|
+
/**
|
|
612
|
+
* The git version followed (default 2.56): {@link setPatch}'s patch-mode prompts, and
|
|
613
|
+
* {@link callDryRun}'s status colors (2.43 knows no `#rgb` and leaves `-s -z`'s `??`
|
|
614
|
+
* uncolored).
|
|
615
|
+
*/
|
|
602
616
|
setCompatibility(version: PatchCompatibility): this {
|
|
603
617
|
this.checkCallable();
|
|
604
618
|
this.patchCompatibility = version;
|
|
@@ -951,15 +965,7 @@ export class CommitCommand extends GitCommand<CommitResult> {
|
|
|
951
965
|
this.message !== undefined || this.reused || this.fixup
|
|
952
966
|
? undefined
|
|
953
967
|
: await this.readTemplate(config);
|
|
954
|
-
const
|
|
955
|
-
const whence: CommitWhence =
|
|
956
|
-
ctx.mergeHeads.length > 0
|
|
957
|
-
? "merge"
|
|
958
|
-
: ctx.pickHead
|
|
959
|
-
? rebasing && (await state.ref("REBASE_HEAD")) === ctx.pickHead
|
|
960
|
-
? "rebase-pick"
|
|
961
|
-
: "cherry-pick"
|
|
962
|
-
: "commit";
|
|
968
|
+
const whence = await this.commitWhence(state, ctx.mergeHeads, ctx.pickHead);
|
|
963
969
|
// the message so far
|
|
964
970
|
let sb = "";
|
|
965
971
|
let cutLineAdded = false;
|
|
@@ -1076,7 +1082,7 @@ export class CommitCommand extends GitCommand<CommitResult> {
|
|
|
1076
1082
|
template = await this.withTrailers(template, state, comment);
|
|
1077
1083
|
const isMerge = (ctx.previousCommit?.parents.length ?? 0) > 1;
|
|
1078
1084
|
if (!committable && whence !== "merge" && !this.allowEmpty && !(this.amend && isMerge)) {
|
|
1079
|
-
throw
|
|
1085
|
+
throw await this.emptyCommitError(ctx.partialTree, whence);
|
|
1080
1086
|
}
|
|
1081
1087
|
// prepare-commit-msg, the editor over what it left, then commit-msg
|
|
1082
1088
|
let text = "";
|
|
@@ -1261,7 +1267,7 @@ export class CommitCommand extends GitCommand<CommitResult> {
|
|
|
1261
1267
|
const head = await this.commits.load(headId);
|
|
1262
1268
|
status.setReferenceCommit(head?.parents[0] ?? null);
|
|
1263
1269
|
}
|
|
1264
|
-
return status.callText(options);
|
|
1270
|
+
return status.callText({ colorCompatibility: this.patchCompatibility, ...options });
|
|
1265
1271
|
}
|
|
1266
1272
|
|
|
1267
1273
|
/** {@link withFalseIndex} with the files of `tree` (a partial commit's stored tree). */
|
|
@@ -1314,6 +1320,11 @@ export class CommitCommand extends GitCommand<CommitResult> {
|
|
|
1314
1320
|
return this;
|
|
1315
1321
|
}
|
|
1316
1322
|
|
|
1323
|
+
/** git sets `warn_on_auto_comment_char`: 2.5x warns of `core.commentChar=auto` here. */
|
|
1324
|
+
protected override autoCommentCharWarningEntryPoints(): readonly string[] {
|
|
1325
|
+
return ["call", "callDryRun"];
|
|
1326
|
+
}
|
|
1327
|
+
|
|
1317
1328
|
/**
|
|
1318
1329
|
* Execute the commit.
|
|
1319
1330
|
*
|
|
@@ -2147,7 +2158,10 @@ export class CommitCommand extends GitCommand<CommitResult> {
|
|
|
2147
2158
|
await state.write("COMMIT_EDITMSG", sb);
|
|
2148
2159
|
// amend_file_with_trailers over COMMIT_EDITMSG
|
|
2149
2160
|
sb = await this.withTrailers(sb, state, undefined);
|
|
2150
|
-
await this.refuseNothingToCommit(treeId, parents, mergeHeads, previousCommit
|
|
2161
|
+
await this.refuseNothingToCommit(treeId, parents, mergeHeads, previousCommit, partialTree, {
|
|
2162
|
+
state,
|
|
2163
|
+
pickHead,
|
|
2164
|
+
});
|
|
2151
2165
|
// prepare-commit-msg and commit-msg, which may rewrite COMMIT_EDITMSG: the commit
|
|
2152
2166
|
// takes the file's text (cmd_commit reads it back)
|
|
2153
2167
|
// (git's hook arguments: read only when hooks can run)
|
|
@@ -2218,18 +2232,75 @@ export class CommitCommand extends GitCommand<CommitResult> {
|
|
|
2218
2232
|
parents: ObjectId[],
|
|
2219
2233
|
mergeHeads: ObjectId[],
|
|
2220
2234
|
previousCommit: Commit | undefined,
|
|
2235
|
+
partialTree: ObjectId | undefined,
|
|
2236
|
+
pick: { state: OperationState; pickHead: ObjectId | undefined },
|
|
2221
2237
|
): Promise<void> {
|
|
2222
2238
|
if (this.allowEmpty || mergeHeads.length > 0) return;
|
|
2239
|
+
const refusal = async () =>
|
|
2240
|
+
this.emptyCommitError(
|
|
2241
|
+
partialTree,
|
|
2242
|
+
await this.commitWhence(pick.state, mergeHeads, pick.pickHead),
|
|
2243
|
+
);
|
|
2223
2244
|
if (parents.length === 0) {
|
|
2224
2245
|
// no first parent (an initial commit, or --amend of a root commit): git counts the
|
|
2225
2246
|
// index, `cache_nr - ita_nr > 0`; only intent-to-add entries (or none) leave the tree
|
|
2226
2247
|
// empty
|
|
2227
|
-
if (treeId === this.objectFormat.emptyTreeId) throw
|
|
2248
|
+
if (treeId === this.objectFormat.emptyTreeId) throw await refusal();
|
|
2228
2249
|
return;
|
|
2229
2250
|
}
|
|
2230
2251
|
if (this.amend && (previousCommit?.parents.length ?? 0) > 1) return;
|
|
2231
2252
|
const parentCommit = await this.commits.load(parents[0] as ObjectId);
|
|
2232
|
-
if (parentCommit && parentCommit.tree === treeId) throw
|
|
2253
|
+
if (parentCommit && parentCommit.tree === treeId) throw await refusal();
|
|
2254
|
+
}
|
|
2255
|
+
|
|
2256
|
+
/**
|
|
2257
|
+
* prepare_to_commit's refusal of an empty commit: run_status on stdout (the status of the
|
|
2258
|
+
* index the commit would record, against HEAD^1 when amending: `git commit --dry-run`'s
|
|
2259
|
+
* text), then on stderr `empty_amend_advice` when amending, else `empty_cherry_pick_advice`
|
|
2260
|
+
* and its sequel for a cherry-pick or rebase-pick whence; exit status 1, nothing written.
|
|
2261
|
+
*/
|
|
2262
|
+
private async emptyCommitError(
|
|
2263
|
+
partialTree: ObjectId | undefined,
|
|
2264
|
+
whence?: CommitWhence,
|
|
2265
|
+
): Promise<EmptyCommitError> {
|
|
2266
|
+
const run = () =>
|
|
2267
|
+
this.commitStatus({
|
|
2268
|
+
format: "long",
|
|
2269
|
+
...(this.showBranch !== undefined ? { branch: this.showBranch } : {}),
|
|
2270
|
+
...(this.aheadBehind !== undefined ? { aheadBehind: this.aheadBehind } : {}),
|
|
2271
|
+
verbose: this.verboseLevel(),
|
|
2272
|
+
commitTemplate: true,
|
|
2273
|
+
amend: this.amend,
|
|
2274
|
+
...(whence ? { whence } : {}),
|
|
2275
|
+
});
|
|
2276
|
+
const status = partialTree ? await this.withIndexOfTree(partialTree, run) : await run();
|
|
2277
|
+
const stderr = this.amend
|
|
2278
|
+
? EMPTY_AMEND_ADVICE
|
|
2279
|
+
: whence === "cherry-pick"
|
|
2280
|
+
? EMPTY_CHERRY_PICK_ADVICE + EMPTY_CHERRY_PICK_ADVICE_SINGLE
|
|
2281
|
+
: whence === "rebase-pick"
|
|
2282
|
+
? EMPTY_CHERRY_PICK_ADVICE + EMPTY_REBASE_PICK_ADVICE
|
|
2283
|
+
: "";
|
|
2284
|
+
return new EmptyCommitError(undefined, { stdout: status.text, stderr });
|
|
2285
|
+
}
|
|
2286
|
+
|
|
2287
|
+
/**
|
|
2288
|
+
* git's whence (builtin/commit.c `determine_whence`, sequencer_determine_whence): a merge
|
|
2289
|
+
* (MERGE_HEAD), a rebase stopped at a pick (CHERRY_PICK_HEAD the commit REBASE_HEAD names),
|
|
2290
|
+
* a cherry-pick (CHERRY_PICK_HEAD; git's `FROM_CHERRY_PICK_MULTI` is overwritten by its
|
|
2291
|
+
* `else`, so a sequence of picks is a single one), else a plain commit.
|
|
2292
|
+
*/
|
|
2293
|
+
private async commitWhence(
|
|
2294
|
+
state: OperationState,
|
|
2295
|
+
mergeHeads: ObjectId[],
|
|
2296
|
+
pickHead: ObjectId | undefined,
|
|
2297
|
+
): Promise<CommitWhence> {
|
|
2298
|
+
if (mergeHeads.length > 0) return "merge";
|
|
2299
|
+
if (!pickHead) return "commit";
|
|
2300
|
+
const rebasing = (await state.read("rebase-merge/head-name")) !== undefined;
|
|
2301
|
+
return rebasing && (await state.ref("REBASE_HEAD")) === pickHead
|
|
2302
|
+
? "rebase-pick"
|
|
2303
|
+
: "cherry-pick";
|
|
2233
2304
|
}
|
|
2234
2305
|
|
|
2235
2306
|
/** The commit of `treeId` made, HEAD moved to it, and what was in progress ended. */
|
|
@@ -2426,17 +2497,21 @@ export class CommitCommand extends GitCommand<CommitResult> {
|
|
|
2426
2497
|
return ran;
|
|
2427
2498
|
}
|
|
2428
2499
|
|
|
2429
|
-
/**
|
|
2500
|
+
/**
|
|
2501
|
+
* The commits MERGE_HEAD names (one per line, a merged tag peeled as git's
|
|
2502
|
+
* `lookup_commit_reference`), none without a merge in progress.
|
|
2503
|
+
*/
|
|
2430
2504
|
private async mergeHeads(state: OperationState): Promise<ObjectId[]> {
|
|
2431
2505
|
const text = await state.read("MERGE_HEAD");
|
|
2432
2506
|
if (text !== undefined) {
|
|
2433
|
-
|
|
2507
|
+
const ids = text
|
|
2434
2508
|
.split("\n")
|
|
2435
2509
|
.map((l) => l.trim())
|
|
2436
2510
|
.filter((l) => /^[0-9a-f]{40,64}$/.test(l));
|
|
2511
|
+
return peelMergeHeads(this.revisionResolver(), ids);
|
|
2437
2512
|
}
|
|
2438
2513
|
const id = await state.ref("MERGE_HEAD");
|
|
2439
|
-
return id ? [id] : [];
|
|
2514
|
+
return id ? peelMergeHeads(this.revisionResolver(), [id]) : [];
|
|
2440
2515
|
}
|
|
2441
2516
|
|
|
2442
2517
|
/** The heads none of the others reaches (git's reduce_heads), in their order. */
|
|
@@ -425,6 +425,34 @@ export class ConfigCommand extends GitCommand<ConfigCommandResult> {
|
|
|
425
425
|
}
|
|
426
426
|
}
|
|
427
427
|
|
|
428
|
+
/**
|
|
429
|
+
* The values of the key {@link get} names, as git's `git_configset_get_string_multi` reads
|
|
430
|
+
* them before checking them: in order, `undefined` for a key written without a value. Reads
|
|
431
|
+
* what `get` reads (the scope's file or `--file`, else the whole configuration); a file it
|
|
432
|
+
* cannot open has no values.
|
|
433
|
+
*
|
|
434
|
+
* @example
|
|
435
|
+
* ```typescript
|
|
436
|
+
* const repos = await new ConfigCommand(wc).setScope("global").get("maintenance.repo").callValues();
|
|
437
|
+
* ```
|
|
438
|
+
*/
|
|
439
|
+
async callValues(): Promise<(string | undefined)[]> {
|
|
440
|
+
this.checkCallable();
|
|
441
|
+
this.setCallable(false);
|
|
442
|
+
const action = this.action;
|
|
443
|
+
if (action?.kind !== "get") throw new GitApiError("callValues() needs a key: call get()");
|
|
444
|
+
const parsed = parseConfigKey(action.key);
|
|
445
|
+
if ("status" in parsed) throw new GitApiError(parsed.error);
|
|
446
|
+
try {
|
|
447
|
+
return (await this.readEntries(false)).filter((e) => e.key === parsed.key).map((e) => e.text);
|
|
448
|
+
} catch (error) {
|
|
449
|
+
if (error instanceof Refusal) {
|
|
450
|
+
throw new GitApiError(error.lines.join("\n"), { exitCode: error.exitCode });
|
|
451
|
+
}
|
|
452
|
+
throw error;
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
|
|
428
456
|
private async run(action: ConfigAction): Promise<ConfigCommandResult> {
|
|
429
457
|
if (this.type !== undefined && !CONFIG_VALUE_TYPES.includes(this.type)) {
|
|
430
458
|
throw fatal(`unrecognized --type argument, ${this.type}`);
|