@statewalker/vcs-commands 0.5.0 → 0.7.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/README.md +123 -8
- package/dist/commands/add-command.d.ts +265 -34
- package/dist/commands/add-command.d.ts.map +1 -1
- package/dist/commands/add-patch/add-interactive.d.ts +46 -0
- package/dist/commands/add-patch/add-interactive.d.ts.map +1 -0
- package/dist/commands/add-patch/add-patch.d.ts +139 -0
- package/dist/commands/add-patch/add-patch.d.ts.map +1 -0
- package/dist/commands/add-patch/index.d.ts +6 -0
- package/dist/commands/add-patch/index.d.ts.map +1 -0
- package/dist/commands/add-patch/patch-backend.d.ts +80 -0
- package/dist/commands/add-patch/patch-backend.d.ts.map +1 -0
- package/dist/commands/add-patch/patch-modes.d.ts +71 -0
- package/dist/commands/add-patch/patch-modes.d.ts.map +1 -0
- package/dist/commands/add-patch/patch-session.d.ts +49 -0
- package/dist/commands/add-patch/patch-session.d.ts.map +1 -0
- package/dist/commands/am/am-command.d.ts +175 -0
- package/dist/commands/am/am-command.d.ts.map +1 -0
- package/dist/commands/am/index.d.ts +3 -0
- package/dist/commands/am/index.d.ts.map +1 -0
- package/dist/commands/am/mailinfo.d.ts +58 -0
- package/dist/commands/am/mailinfo.d.ts.map +1 -0
- package/dist/commands/am/patch-format.d.ts +24 -0
- package/dist/commands/am/patch-format.d.ts.map +1 -0
- package/dist/commands/apply/apply-command.d.ts +153 -0
- package/dist/commands/apply/apply-command.d.ts.map +1 -0
- package/dist/commands/apply/apply-engine.d.ts +195 -0
- package/dist/commands/apply/apply-engine.d.ts.map +1 -0
- package/dist/commands/apply/apply-parse.d.ts +86 -0
- package/dist/commands/apply/apply-parse.d.ts.map +1 -0
- package/dist/commands/apply/apply-types.d.ts +70 -0
- package/dist/commands/apply/apply-types.d.ts.map +1 -0
- package/dist/commands/apply/index.d.ts +6 -0
- package/dist/commands/apply/index.d.ts.map +1 -0
- package/dist/commands/apply/latin1.d.ts +32 -0
- package/dist/commands/apply/latin1.d.ts.map +1 -0
- package/dist/commands/apply/whitespace.d.ts +58 -0
- package/dist/commands/apply/whitespace.d.ts.map +1 -0
- package/dist/commands/attributes-source.d.ts +26 -0
- package/dist/commands/attributes-source.d.ts.map +1 -0
- package/dist/commands/backfill-command.d.ts +110 -0
- package/dist/commands/backfill-command.d.ts.map +1 -0
- package/dist/commands/bisect/bisect-checkout.d.ts +64 -0
- package/dist/commands/bisect/bisect-checkout.d.ts.map +1 -0
- package/dist/commands/bisect/bisect-command.d.ts +201 -0
- package/dist/commands/bisect/bisect-command.d.ts.map +1 -0
- package/dist/commands/bisect/bisect-engine.d.ts +219 -0
- package/dist/commands/bisect/bisect-engine.d.ts.map +1 -0
- package/dist/commands/bisect/bisect-graph.d.ts +127 -0
- package/dist/commands/bisect/bisect-graph.d.ts.map +1 -0
- package/dist/commands/bisect/bisect-quote.d.ts +27 -0
- package/dist/commands/bisect/bisect-quote.d.ts.map +1 -0
- package/dist/commands/bisect/index.d.ts +5 -0
- package/dist/commands/bisect/index.d.ts.map +1 -0
- package/dist/commands/blame-command.d.ts +122 -131
- package/dist/commands/blame-command.d.ts.map +1 -1
- package/dist/commands/branch-command.d.ts +52 -2
- package/dist/commands/branch-command.d.ts.map +1 -1
- package/dist/commands/branch-tracking.d.ts +98 -0
- package/dist/commands/branch-tracking.d.ts.map +1 -0
- package/dist/commands/checkout-command.d.ts +300 -18
- package/dist/commands/checkout-command.d.ts.map +1 -1
- package/dist/commands/checkout-paths.d.ts +124 -0
- package/dist/commands/checkout-paths.d.ts.map +1 -0
- package/dist/commands/cherry-pick-command.d.ts +50 -42
- package/dist/commands/cherry-pick-command.d.ts.map +1 -1
- package/dist/commands/clean-command.d.ts +49 -16
- package/dist/commands/clean-command.d.ts.map +1 -1
- package/dist/commands/clone-command.d.ts +134 -0
- package/dist/commands/clone-command.d.ts.map +1 -1
- package/dist/commands/comment-char-config.d.ts +35 -0
- package/dist/commands/comment-char-config.d.ts.map +1 -0
- package/dist/commands/commit-command.d.ts +311 -17
- package/dist/commands/commit-command.d.ts.map +1 -1
- package/dist/commands/core-config.d.ts +78 -1
- package/dist/commands/core-config.d.ts.map +1 -1
- package/dist/commands/date-format.d.ts +58 -0
- package/dist/commands/date-format.d.ts.map +1 -0
- package/dist/commands/default-branch.d.ts +70 -0
- package/dist/commands/default-branch.d.ts.map +1 -0
- package/dist/commands/describe-command.d.ts.map +1 -1
- package/dist/commands/diff-command.d.ts +377 -30
- package/dist/commands/diff-command.d.ts.map +1 -1
- package/dist/commands/diff-textconv.d.ts +40 -0
- package/dist/commands/diff-textconv.d.ts.map +1 -0
- package/dist/commands/fetch-command.d.ts +149 -10
- package/dist/commands/fetch-command.d.ts.map +1 -1
- package/dist/commands/format-patch-command.d.ts +164 -0
- package/dist/commands/format-patch-command.d.ts.map +1 -0
- package/dist/commands/fsck/fetch-fsck.d.ts +60 -0
- package/dist/commands/fsck/fetch-fsck.d.ts.map +1 -0
- package/dist/commands/fsck/fsck-command.d.ts +227 -0
- package/dist/commands/fsck/fsck-command.d.ts.map +1 -0
- package/dist/commands/fsck/fsck-loose.d.ts +71 -0
- package/dist/commands/fsck/fsck-loose.d.ts.map +1 -0
- package/dist/commands/fsck/fsck-msg-ids.d.ts +122 -0
- package/dist/commands/fsck/fsck-msg-ids.d.ts.map +1 -0
- package/dist/commands/fsck/fsck-object-checks.d.ts +159 -0
- package/dist/commands/fsck/fsck-object-checks.d.ts.map +1 -0
- package/dist/commands/fsck/fsck-object-table.d.ts +140 -0
- package/dist/commands/fsck/fsck-object-table.d.ts.map +1 -0
- package/dist/commands/fsck/fsck-pack.d.ts +122 -0
- package/dist/commands/fsck/fsck-pack.d.ts.map +1 -0
- package/dist/commands/fsck/index.d.ts +6 -0
- package/dist/commands/fsck/index.d.ts.map +1 -0
- package/dist/commands/fsck/verify-pack-command.d.ts +81 -0
- package/dist/commands/fsck/verify-pack-command.d.ts.map +1 -0
- package/dist/commands/gc-command.d.ts +106 -39
- package/dist/commands/gc-command.d.ts.map +1 -1
- package/dist/commands/git-date.d.ts +2 -0
- package/dist/commands/git-date.d.ts.map +1 -0
- package/dist/commands/git-describe.d.ts +67 -0
- package/dist/commands/git-describe.d.ts.map +1 -0
- package/dist/commands/git-hooks.d.ts +424 -0
- package/dist/commands/git-hooks.d.ts.map +1 -0
- package/dist/commands/git-ident.d.ts +128 -0
- package/dist/commands/git-ident.d.ts.map +1 -0
- package/dist/commands/hook-command.d.ts +96 -0
- package/dist/commands/hook-command.d.ts.map +1 -0
- package/dist/commands/index-adder.d.ts +233 -0
- package/dist/commands/index-adder.d.ts.map +1 -0
- package/dist/commands/index-host.d.ts +86 -0
- package/dist/commands/index-host.d.ts.map +1 -0
- package/dist/commands/index.d.ts +56 -0
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +3 -2
- package/dist/commands/init-command.d.ts +62 -4
- package/dist/commands/init-command.d.ts.map +1 -1
- package/dist/commands/legacy-remotes.d.ts +55 -0
- package/dist/commands/legacy-remotes.d.ts.map +1 -0
- package/dist/commands/local-clone.d.ts +60 -0
- package/dist/commands/local-clone.d.ts.map +1 -0
- package/dist/commands/local-transport.d.ts +117 -0
- package/dist/commands/local-transport.d.ts.map +1 -0
- package/dist/commands/log-command.d.ts +216 -24
- package/dist/commands/log-command.d.ts.map +1 -1
- package/dist/commands/log-graph.d.ts +120 -0
- package/dist/commands/log-graph.d.ts.map +1 -0
- package/dist/commands/log-output.d.ts +323 -0
- package/dist/commands/log-output.d.ts.map +1 -0
- package/dist/commands/ls-remote-command.d.ts +23 -7
- package/dist/commands/ls-remote-command.d.ts.map +1 -1
- package/dist/commands/mailmap.d.ts +31 -0
- package/dist/commands/mailmap.d.ts.map +1 -0
- package/dist/commands/merge-bases.d.ts +85 -0
- package/dist/commands/merge-bases.d.ts.map +1 -0
- package/dist/commands/merge-command.d.ts +221 -74
- package/dist/commands/merge-command.d.ts.map +1 -1
- package/dist/commands/merge-config.d.ts +13 -0
- package/dist/commands/merge-config.d.ts.map +1 -0
- package/dist/commands/merge-drivers.d.ts +130 -0
- package/dist/commands/merge-drivers.d.ts.map +1 -0
- package/dist/commands/merge-support.d.ts +260 -0
- package/dist/commands/merge-support.d.ts.map +1 -0
- package/dist/commands/message-cleanup.d.ts +86 -0
- package/dist/commands/message-cleanup.d.ts.map +1 -0
- package/dist/commands/mv-command.d.ts +94 -0
- package/dist/commands/mv-command.d.ts.map +1 -0
- package/dist/commands/notes-command.d.ts +256 -0
- package/dist/commands/notes-command.d.ts.map +1 -0
- package/dist/commands/notes-commands.d.ts +41 -0
- package/dist/commands/notes-commands.d.ts.map +1 -0
- package/dist/commands/notes-merge-command.d.ts +105 -0
- package/dist/commands/notes-merge-command.d.ts.map +1 -0
- package/dist/commands/notes-support.d.ts +125 -0
- package/dist/commands/notes-support.d.ts.map +1 -0
- package/dist/commands/notes-tree.d.ts +116 -0
- package/dist/commands/notes-tree.d.ts.map +1 -0
- package/dist/commands/object-id-input.d.ts +20 -0
- package/dist/commands/object-id-input.d.ts.map +1 -0
- package/dist/commands/octopus-merge.d.ts +59 -0
- package/dist/commands/octopus-merge.d.ts.map +1 -0
- package/dist/commands/ort-merge.d.ts +126 -0
- package/dist/commands/ort-merge.d.ts.map +1 -0
- package/dist/commands/ort-recursive.d.ts +53 -0
- package/dist/commands/ort-recursive.d.ts.map +1 -0
- package/dist/commands/pack-refs-command.d.ts +20 -0
- package/dist/commands/pack-refs-command.d.ts.map +1 -1
- package/dist/commands/patch-id.d.ts +44 -0
- package/dist/commands/patch-id.d.ts.map +1 -0
- package/dist/commands/pathspec-attributes.d.ts +64 -0
- package/dist/commands/pathspec-attributes.d.ts.map +1 -0
- package/dist/commands/pathspec.d.ts +324 -0
- package/dist/commands/pathspec.d.ts.map +1 -0
- package/dist/commands/post-index-change.d.ts +33 -0
- package/dist/commands/post-index-change.d.ts.map +1 -0
- package/dist/commands/pretty-format.d.ts +222 -0
- package/dist/commands/pretty-format.d.ts.map +1 -0
- package/dist/commands/promisor-remote.d.ts +80 -0
- package/dist/commands/promisor-remote.d.ts.map +1 -0
- package/dist/commands/pull-command.d.ts +59 -8
- package/dist/commands/pull-command.d.ts.map +1 -1
- package/dist/commands/push-command.d.ts +24 -8
- package/dist/commands/push-command.d.ts.map +1 -1
- package/dist/commands/read-tree-command.d.ts +112 -0
- package/dist/commands/read-tree-command.d.ts.map +1 -0
- package/dist/commands/rebase-command.d.ts +507 -75
- package/dist/commands/rebase-command.d.ts.map +1 -1
- package/dist/commands/rebase-todo.d.ts +130 -0
- package/dist/commands/rebase-todo.d.ts.map +1 -0
- package/dist/commands/ref-decoration-filter.d.ts +53 -0
- package/dist/commands/ref-decoration-filter.d.ts.map +1 -0
- package/dist/commands/reflog-messages.d.ts +98 -0
- package/dist/commands/reflog-messages.d.ts.map +1 -0
- package/dist/commands/remote-command.d.ts +31 -0
- package/dist/commands/remote-command.d.ts.map +1 -1
- package/dist/commands/remote-transport.d.ts +120 -0
- package/dist/commands/remote-transport.d.ts.map +1 -0
- package/dist/commands/reset-command.d.ts +161 -7
- package/dist/commands/reset-command.d.ts.map +1 -1
- package/dist/commands/restore-command.d.ts +103 -0
- package/dist/commands/restore-command.d.ts.map +1 -0
- package/dist/commands/rev-list-command.d.ts +78 -0
- package/dist/commands/rev-list-command.d.ts.map +1 -0
- package/dist/commands/rev-parse-command.d.ts +89 -0
- package/dist/commands/rev-parse-command.d.ts.map +1 -0
- package/dist/commands/revert-command.d.ts +46 -38
- package/dist/commands/revert-command.d.ts.map +1 -1
- package/dist/commands/revision-filenames.d.ts +95 -0
- package/dist/commands/revision-filenames.d.ts.map +1 -0
- package/dist/commands/revision-range.d.ts +67 -0
- package/dist/commands/revision-range.d.ts.map +1 -0
- package/dist/commands/revision-resolver.d.ts +325 -0
- package/dist/commands/revision-resolver.d.ts.map +1 -0
- package/dist/commands/rm-command.d.ts +69 -7
- package/dist/commands/rm-command.d.ts.map +1 -1
- package/dist/commands/sequencer-pick.d.ts +191 -0
- package/dist/commands/sequencer-pick.d.ts.map +1 -0
- package/dist/commands/sequencer-support.d.ts +125 -0
- package/dist/commands/sequencer-support.d.ts.map +1 -0
- package/dist/commands/serve-repository.d.ts +52 -0
- package/dist/commands/serve-repository.d.ts.map +1 -0
- package/dist/commands/sparse-checkout-command.d.ts +190 -0
- package/dist/commands/sparse-checkout-command.d.ts.map +1 -0
- package/dist/commands/sparse-checkout-support.d.ts +268 -0
- package/dist/commands/sparse-checkout-support.d.ts.map +1 -0
- package/dist/commands/stash-apply-command.d.ts +42 -8
- package/dist/commands/stash-apply-command.d.ts.map +1 -1
- package/dist/commands/stash-create-command.d.ts +156 -2
- package/dist/commands/stash-create-command.d.ts.map +1 -1
- package/dist/commands/stash-drop-command.d.ts +2 -0
- package/dist/commands/stash-drop-command.d.ts.map +1 -1
- package/dist/commands/stash-working-tree.d.ts +23 -0
- package/dist/commands/stash-working-tree.d.ts.map +1 -1
- package/dist/commands/status-command.d.ts +300 -15
- package/dist/commands/status-command.d.ts.map +1 -1
- package/dist/commands/status-format.d.ts +155 -0
- package/dist/commands/status-format.d.ts.map +1 -0
- package/dist/commands/status-header.d.ts +64 -0
- package/dist/commands/status-header.d.ts.map +1 -0
- package/dist/commands/strerror.d.ts +7 -0
- package/dist/commands/strerror.d.ts.map +1 -0
- package/dist/commands/submodule-config.d.ts +38 -0
- package/dist/commands/submodule-config.d.ts.map +1 -0
- package/dist/commands/submodule-summary-command.d.ts +80 -0
- package/dist/commands/submodule-summary-command.d.ts.map +1 -0
- package/dist/commands/submodule-summary.d.ts +150 -0
- package/dist/commands/submodule-summary.d.ts.map +1 -0
- package/dist/commands/switch-command.d.ts +132 -0
- package/dist/commands/switch-command.d.ts.map +1 -0
- package/dist/commands/tag-command.d.ts +23 -2
- package/dist/commands/tag-command.d.ts.map +1 -1
- package/dist/commands/tracking-info.d.ts +64 -0
- package/dist/commands/tracking-info.d.ts.map +1 -0
- package/dist/commands/trailers.d.ts +73 -0
- package/dist/commands/trailers.d.ts.map +1 -0
- package/dist/commands/tree-restore.d.ts +85 -1
- package/dist/commands/tree-restore.d.ts.map +1 -1
- package/dist/commands/untracked-cache-support.d.ts +54 -0
- package/dist/commands/untracked-cache-support.d.ts.map +1 -0
- package/dist/commands/worktree-add-command.d.ts +108 -0
- package/dist/commands/worktree-add-command.d.ts.map +1 -0
- package/dist/commands/worktree-list-command.d.ts +69 -0
- package/dist/commands/worktree-list-command.d.ts.map +1 -0
- package/dist/commands/worktree-lock-command.d.ts +44 -0
- package/dist/commands/worktree-lock-command.d.ts.map +1 -0
- package/dist/commands/worktree-overwrite-checks.d.ts +146 -6
- package/dist/commands/worktree-overwrite-checks.d.ts.map +1 -1
- package/dist/commands/worktree-prune-command.d.ts +48 -0
- package/dist/commands/worktree-prune-command.d.ts.map +1 -0
- package/dist/commands/worktree-remove-command.d.ts +59 -0
- package/dist/commands/worktree-remove-command.d.ts.map +1 -0
- package/dist/commands/worktree-repair-command.d.ts +35 -0
- package/dist/commands/worktree-repair-command.d.ts.map +1 -0
- package/dist/commands/worktree-support.d.ts +64 -0
- package/dist/commands/worktree-support.d.ts.map +1 -0
- package/dist/commands-DIJ91NnD.js +62225 -0
- package/dist/core-commands/add.command.impl.d.ts.map +1 -1
- package/dist/errors/add-errors.d.ts +55 -0
- package/dist/errors/add-errors.d.ts.map +1 -1
- package/dist/errors/checkout-errors.d.ts +16 -0
- package/dist/errors/checkout-errors.d.ts.map +1 -1
- package/dist/errors/command-errors.d.ts +77 -0
- package/dist/errors/command-errors.d.ts.map +1 -1
- package/dist/errors/commit-errors.d.ts +9 -0
- package/dist/errors/commit-errors.d.ts.map +1 -1
- package/dist/errors/git-api-error.d.ts +59 -2
- package/dist/errors/git-api-error.d.ts.map +1 -1
- package/dist/errors/index.d.ts +1 -0
- package/dist/errors/index.d.ts.map +1 -1
- package/dist/errors/index.js +354 -19
- package/dist/errors/rebase-errors.d.ts +9 -0
- package/dist/errors/rebase-errors.d.ts.map +1 -1
- package/dist/errors/ref-errors.d.ts +32 -0
- package/dist/errors/ref-errors.d.ts.map +1 -1
- package/dist/errors/transport-errors.d.ts +12 -2
- package/dist/errors/transport-errors.d.ts.map +1 -1
- package/dist/errors/worktree-errors.d.ts +35 -0
- package/dist/errors/worktree-errors.d.ts.map +1 -0
- package/dist/git-command-BGiOJ8Zk.js +7246 -0
- package/dist/git-command.d.ts +428 -32
- package/dist/git-command.d.ts.map +1 -1
- package/dist/git.d.ts +315 -5
- package/dist/git.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -5
- package/dist/remote-config/index.d.ts +1 -1
- package/dist/remote-config/index.d.ts.map +1 -1
- package/dist/remote-config/remote-config-store.d.ts +167 -6
- package/dist/remote-config/remote-config-store.d.ts.map +1 -1
- package/dist/remote-config/remote-refs.d.ts +7 -3
- package/dist/remote-config/remote-refs.d.ts.map +1 -1
- package/dist/rename/detect-renames.d.ts +148 -0
- package/dist/rename/detect-renames.d.ts.map +1 -0
- package/dist/rename/git-similarity.d.ts +44 -0
- package/dist/rename/git-similarity.d.ts.map +1 -0
- package/dist/rename/index.d.ts +2 -0
- package/dist/rename/index.d.ts.map +1 -1
- package/dist/results/binary-patch.d.ts +11 -0
- package/dist/results/binary-patch.d.ts.map +1 -0
- package/dist/results/blame-format.d.ts +55 -0
- package/dist/results/blame-format.d.ts.map +1 -0
- package/dist/results/cherry-pick-result.d.ts +10 -0
- package/dist/results/cherry-pick-result.d.ts.map +1 -1
- package/dist/results/clone-result.d.ts +18 -0
- package/dist/results/clone-result.d.ts.map +1 -1
- package/dist/results/combined-diff.d.ts +77 -0
- package/dist/results/combined-diff.d.ts.map +1 -0
- package/dist/results/diff-entry.d.ts +32 -0
- package/dist/results/diff-entry.d.ts.map +1 -1
- package/dist/results/diff-formatter.d.ts +34 -60
- package/dist/results/diff-formatter.d.ts.map +1 -1
- package/dist/results/diff-order.d.ts +25 -0
- package/dist/results/diff-order.d.ts.map +1 -0
- package/dist/results/diff-output.d.ts +249 -0
- package/dist/results/diff-output.d.ts.map +1 -0
- package/dist/results/fetch-result.d.ts +15 -0
- package/dist/results/fetch-result.d.ts.map +1 -1
- package/dist/results/index.d.ts +5 -0
- package/dist/results/index.d.ts.map +1 -1
- package/dist/results/index.js +2 -252
- package/dist/results/init-result.d.ts +7 -0
- package/dist/results/init-result.d.ts.map +1 -1
- package/dist/results/merge-result.d.ts +15 -1
- package/dist/results/merge-result.d.ts.map +1 -1
- package/dist/results/pull-result.d.ts +17 -3
- package/dist/results/pull-result.d.ts.map +1 -1
- package/dist/results/push-result.d.ts +47 -0
- package/dist/results/push-result.d.ts.map +1 -1
- package/dist/results/quote-path.d.ts +27 -0
- package/dist/results/quote-path.d.ts.map +1 -0
- package/dist/results/rebase-result.d.ts +28 -1
- package/dist/results/rebase-result.d.ts.map +1 -1
- package/dist/results/revert-result.d.ts +10 -0
- package/dist/results/revert-result.d.ts.map +1 -1
- package/dist/results/stash-result.d.ts +5 -0
- package/dist/results/stash-result.d.ts.map +1 -1
- package/dist/results/status-result.d.ts +60 -6
- package/dist/results/status-result.d.ts.map +1 -1
- package/dist/results-WVlBhVb1.js +2935 -0
- package/dist/transport-command.d.ts +44 -1
- package/dist/transport-command.d.ts.map +1 -1
- package/package.json +15 -11
- package/src/commands/add-command.ts +1291 -226
- package/src/commands/add-patch/add-interactive.ts +941 -0
- package/src/commands/add-patch/add-patch.ts +1169 -0
- package/src/commands/add-patch/index.ts +5 -0
- package/src/commands/add-patch/patch-backend.ts +239 -0
- package/src/commands/add-patch/patch-modes.ts +249 -0
- package/src/commands/add-patch/patch-session.ts +159 -0
- package/src/commands/am/am-command.ts +1111 -0
- package/src/commands/am/index.ts +2 -0
- package/src/commands/am/mailinfo.ts +1015 -0
- package/src/commands/am/patch-format.ts +121 -0
- package/src/commands/apply/apply-command.ts +842 -0
- package/src/commands/apply/apply-engine.ts +1602 -0
- package/src/commands/apply/apply-parse.ts +1210 -0
- package/src/commands/apply/apply-types.ts +112 -0
- package/src/commands/apply/index.ts +5 -0
- package/src/commands/apply/latin1.ts +171 -0
- package/src/commands/apply/whitespace.ts +260 -0
- package/src/commands/attributes-source.ts +96 -0
- package/src/commands/backfill-command.ts +694 -0
- package/src/commands/bisect/bisect-checkout.ts +217 -0
- package/src/commands/bisect/bisect-command.ts +788 -0
- package/src/commands/bisect/bisect-engine.ts +1080 -0
- package/src/commands/bisect/bisect-graph.ts +595 -0
- package/src/commands/bisect/bisect-quote.ts +92 -0
- package/src/commands/bisect/index.ts +4 -0
- package/src/commands/blame-command.ts +711 -986
- package/src/commands/branch-command.ts +354 -32
- package/src/commands/branch-tracking.ts +331 -0
- package/src/commands/checkout-command.ts +1290 -243
- package/src/commands/checkout-paths.ts +784 -0
- package/src/commands/cherry-pick-command.ts +156 -396
- package/src/commands/clean-command.ts +504 -156
- package/src/commands/clone-command.ts +748 -69
- package/src/commands/comment-char-config.ts +160 -0
- package/src/commands/commit-command.ts +1782 -166
- package/src/commands/core-config.ts +166 -6
- package/src/commands/date-format.ts +668 -0
- package/src/commands/default-branch.ts +196 -0
- package/src/commands/describe-command.ts +2 -0
- package/src/commands/diff-command.ts +1916 -110
- package/src/commands/diff-textconv.ts +50 -0
- package/src/commands/fetch-command.ts +622 -68
- package/src/commands/format-patch-command.ts +974 -0
- package/src/commands/fsck/fetch-fsck.ts +229 -0
- package/src/commands/fsck/fsck-command.ts +3464 -0
- package/src/commands/fsck/fsck-loose.ts +297 -0
- package/src/commands/fsck/fsck-msg-ids.ts +176 -0
- package/src/commands/fsck/fsck-object-checks.ts +1085 -0
- package/src/commands/fsck/fsck-object-table.ts +373 -0
- package/src/commands/fsck/fsck-pack.ts +634 -0
- package/src/commands/fsck/index.ts +5 -0
- package/src/commands/fsck/verify-pack-command.ts +252 -0
- package/src/commands/gc-command.ts +324 -77
- package/src/commands/git-date.ts +9 -0
- package/src/commands/git-describe.ts +316 -0
- package/src/commands/git-hooks.ts +1483 -0
- package/src/commands/git-ident.ts +344 -0
- package/src/commands/hook-command.ts +247 -0
- package/src/commands/index-adder.ts +711 -0
- package/src/commands/index-host.ts +291 -0
- package/src/commands/index.ts +84 -0
- package/src/commands/init-command.ts +194 -14
- package/src/commands/legacy-remotes.ts +224 -0
- package/src/commands/local-clone.ts +183 -0
- package/src/commands/local-transport.ts +762 -0
- package/src/commands/log-command.ts +1930 -170
- package/src/commands/log-graph.ts +671 -0
- package/src/commands/log-output.ts +1359 -0
- package/src/commands/ls-remote-command.ts +105 -58
- package/src/commands/mailmap.ts +129 -0
- package/src/commands/merge-bases.ts +296 -0
- package/src/commands/merge-command.ts +1416 -491
- package/src/commands/merge-config.ts +25 -0
- package/src/commands/merge-drivers.ts +306 -0
- package/src/commands/merge-support.ts +1219 -0
- package/src/commands/message-cleanup.ts +275 -0
- package/src/commands/mv-command.ts +976 -0
- package/src/commands/notes-command.ts +890 -0
- package/src/commands/notes-commands.ts +87 -0
- package/src/commands/notes-merge-command.ts +777 -0
- package/src/commands/notes-support.ts +402 -0
- package/src/commands/notes-tree.ts +617 -0
- package/src/commands/object-id-input.ts +27 -0
- package/src/commands/octopus-merge.ts +378 -0
- package/src/commands/ort-merge.ts +1660 -0
- package/src/commands/ort-recursive.ts +160 -0
- package/src/commands/pack-refs-command.ts +39 -22
- package/src/commands/patch-id.ts +204 -0
- package/src/commands/pathspec-attributes.ts +162 -0
- package/src/commands/pathspec.ts +1199 -0
- package/src/commands/post-index-change.ts +62 -0
- package/src/commands/pretty-format.ts +1432 -0
- package/src/commands/promisor-remote.ts +298 -0
- package/src/commands/pull-command.ts +326 -33
- package/src/commands/push-command.ts +257 -29
- package/src/commands/read-tree-command.ts +861 -0
- package/src/commands/rebase-command.ts +3820 -372
- package/src/commands/rebase-todo.ts +584 -0
- package/src/commands/ref-decoration-filter.ts +118 -0
- package/src/commands/reflog-messages.ts +177 -0
- package/src/commands/remote-command.ts +124 -23
- package/src/commands/remote-transport.ts +383 -0
- package/src/commands/reset-command.ts +821 -104
- package/src/commands/restore-command.ts +350 -0
- package/src/commands/rev-list-command.ts +167 -0
- package/src/commands/rev-parse-command.ts +299 -0
- package/src/commands/revert-command.ts +152 -399
- package/src/commands/revision-filenames.ts +254 -0
- package/src/commands/revision-range.ts +222 -0
- package/src/commands/revision-resolver.ts +1397 -0
- package/src/commands/rm-command.ts +613 -67
- package/src/commands/sequencer-pick.ts +874 -0
- package/src/commands/sequencer-support.ts +876 -0
- package/src/commands/serve-repository.ts +125 -0
- package/src/commands/sparse-checkout-command.ts +1389 -0
- package/src/commands/sparse-checkout-support.ts +793 -0
- package/src/commands/stash-apply-command.ts +376 -343
- package/src/commands/stash-create-command.ts +625 -42
- package/src/commands/stash-drop-command.ts +15 -2
- package/src/commands/stash-working-tree.ts +168 -24
- package/src/commands/status-command.ts +1326 -105
- package/src/commands/status-format.ts +775 -0
- package/src/commands/status-header.ts +332 -0
- package/src/commands/strerror.ts +29 -0
- package/src/commands/submodule-config.ts +94 -0
- package/src/commands/submodule-summary-command.ts +333 -0
- package/src/commands/submodule-summary.ts +446 -0
- package/src/commands/switch-command.ts +402 -0
- package/src/commands/tag-command.ts +129 -41
- package/src/commands/tracking-info.ts +201 -0
- package/src/commands/trailers.ts +417 -0
- package/src/commands/tree-restore.ts +204 -4
- package/src/commands/untracked-cache-support.ts +198 -0
- package/src/commands/worktree-add-command.ts +458 -0
- package/src/commands/worktree-list-command.ts +206 -0
- package/src/commands/worktree-lock-command.ts +96 -0
- package/src/commands/worktree-overwrite-checks.ts +452 -26
- package/src/commands/worktree-prune-command.ts +99 -0
- package/src/commands/worktree-remove-command.ts +186 -0
- package/src/commands/worktree-repair-command.ts +59 -0
- package/src/commands/worktree-support.ts +214 -0
- package/src/core-commands/add.command.impl.ts +8 -2
- package/src/errors/add-errors.ts +45 -0
- package/src/errors/checkout-errors.ts +26 -2
- package/src/errors/command-errors.ts +101 -1
- package/src/errors/commit-errors.ts +18 -2
- package/src/errors/git-api-error.ts +82 -2
- package/src/errors/index.ts +1 -0
- package/src/errors/merge-errors.ts +2 -2
- package/src/errors/rebase-errors.ts +12 -0
- package/src/errors/ref-errors.ts +56 -2
- package/src/errors/remote-errors.ts +2 -2
- package/src/errors/stash-errors.ts +1 -1
- package/src/errors/transport-errors.ts +20 -4
- package/src/errors/worktree-errors.ts +49 -0
- package/src/git-command.ts +1207 -118
- package/src/git.ts +538 -12
- package/src/index.ts +1 -1
- package/src/remote-config/index.ts +2 -0
- package/src/remote-config/remote-config-store.ts +378 -18
- package/src/remote-config/remote-refs.ts +22 -6
- package/src/rename/detect-renames.ts +715 -0
- package/src/rename/git-similarity.ts +116 -0
- package/src/rename/index.ts +2 -0
- package/src/results/binary-patch.ts +401 -0
- package/src/results/blame-format.ts +239 -0
- package/src/results/cherry-pick-result.ts +10 -0
- package/src/results/clone-result.ts +21 -0
- package/src/results/combined-diff.ts +585 -0
- package/src/results/diff-entry.ts +35 -0
- package/src/results/diff-formatter.ts +152 -288
- package/src/results/diff-order.ts +64 -0
- package/src/results/diff-output.ts +1053 -0
- package/src/results/fetch-result.ts +15 -0
- package/src/results/index.ts +5 -0
- package/src/results/init-result.ts +9 -0
- package/src/results/merge-result.ts +15 -1
- package/src/results/pull-result.ts +17 -3
- package/src/results/push-result.ts +48 -0
- package/src/results/quote-path.ts +103 -0
- package/src/results/rebase-result.ts +37 -0
- package/src/results/revert-result.ts +10 -0
- package/src/results/stash-result.ts +6 -0
- package/src/results/status-result.ts +127 -46
- package/src/transport-command.ts +121 -2
- package/dist/commands-CsLNyvZ1.js +0 -12587
- package/dist/status-result-BpyUK1Sg.js +0 -519
|
@@ -0,0 +1,668 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* git's date modes (`--date=<mode>`, `log.date`): date.c's parse_date_format and show_date.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```typescript
|
|
6
|
+
* const mode = parseDateMode("iso");
|
|
7
|
+
* showDate(1112911993, "+0200", mode); // "2005-04-08 00:13:13 +0200"
|
|
8
|
+
* showDate(1112911993, "+0200", parseDateMode("format:%Y/%m/%d")); // "2005/04/08"
|
|
9
|
+
* showDate(1112911993, "+0200", parseDateMode("relative"), { now }); // "19 years ago"
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* The modes: `default` (`Thu Apr 7 22:13:13 2005 +0200`), `relative`, `local` (default in
|
|
13
|
+
* the local zone, without it), `iso`/`iso8601`, `iso-strict`/`iso8601-strict`, `rfc`/`rfc2822`,
|
|
14
|
+
* `short`, `raw`, `unix`, `human` and `format:<strftime>` (the C locale's names); each but
|
|
15
|
+
* `relative`, `raw`... may end in `-local` to be shown in the local zone. `auto:<mode>` is the
|
|
16
|
+
* default mode, as git without a terminal takes it.
|
|
17
|
+
*
|
|
18
|
+
* @module
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import { relativeDate } from "./pretty-format.js";
|
|
22
|
+
|
|
23
|
+
/** A parsed date mode (date.c's struct date_mode). */
|
|
24
|
+
export interface DateMode {
|
|
25
|
+
type:
|
|
26
|
+
| "normal"
|
|
27
|
+
| "relative"
|
|
28
|
+
| "short"
|
|
29
|
+
| "iso8601"
|
|
30
|
+
| "iso8601-strict"
|
|
31
|
+
| "rfc2822"
|
|
32
|
+
| "strftime"
|
|
33
|
+
| "raw"
|
|
34
|
+
| "unix"
|
|
35
|
+
| "human";
|
|
36
|
+
/** Shown in the local zone (`-local`, `local`) */
|
|
37
|
+
local: boolean;
|
|
38
|
+
/** The strftime format of `format:` */
|
|
39
|
+
strftime?: string;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** What {@link showDate} reads besides the date. */
|
|
43
|
+
export interface ShowDateContext {
|
|
44
|
+
/** Now, in seconds (`relative`, `human`); default the clock */
|
|
45
|
+
now?: number;
|
|
46
|
+
/** The local zone's offset east of UTC in minutes at a time (default the host's) */
|
|
47
|
+
localTzOffset?: (time: number) => number;
|
|
48
|
+
/**
|
|
49
|
+
* The local zone's name at a time, as `%Z` of a `format-local:` date shows it (default
|
|
50
|
+
* {@link hostZoneName})
|
|
51
|
+
*/
|
|
52
|
+
localTzName?: (time: number) => string;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** An error git reports for a date mode it does not know (`fatal: unknown date format`). */
|
|
56
|
+
export class DateModeError extends Error {}
|
|
57
|
+
|
|
58
|
+
const TYPES: [string, DateMode["type"]][] = [
|
|
59
|
+
["relative", "relative"],
|
|
60
|
+
["iso8601-strict", "iso8601-strict"],
|
|
61
|
+
["iso-strict", "iso8601-strict"],
|
|
62
|
+
["iso8601", "iso8601"],
|
|
63
|
+
["iso", "iso8601"],
|
|
64
|
+
["rfc2822", "rfc2822"],
|
|
65
|
+
["rfc", "rfc2822"],
|
|
66
|
+
["short", "short"],
|
|
67
|
+
["default", "normal"],
|
|
68
|
+
["human", "human"],
|
|
69
|
+
["raw", "raw"],
|
|
70
|
+
["unix", "unix"],
|
|
71
|
+
["format", "strftime"],
|
|
72
|
+
];
|
|
73
|
+
|
|
74
|
+
/** date.c's parse_date_format. */
|
|
75
|
+
export function parseDateMode(spec: string): DateMode {
|
|
76
|
+
let format = spec;
|
|
77
|
+
// "auto:foo": foo on a terminal, else the default
|
|
78
|
+
if (format.startsWith("auto:")) format = "default";
|
|
79
|
+
if (format === "local") format = "default-local";
|
|
80
|
+
const found = TYPES.find(([name]) => format.startsWith(name));
|
|
81
|
+
if (!found) throw new DateModeError(`fatal: unknown date format ${spec}`);
|
|
82
|
+
let rest = format.slice(found[0].length);
|
|
83
|
+
const mode: DateMode = { type: found[1], local: false };
|
|
84
|
+
if (rest.startsWith("-local")) {
|
|
85
|
+
mode.local = true;
|
|
86
|
+
rest = rest.slice(6);
|
|
87
|
+
}
|
|
88
|
+
if (mode.type === "strftime") {
|
|
89
|
+
if (!rest.startsWith(":")) {
|
|
90
|
+
throw new DateModeError(`fatal: date format missing colon separator: ${spec}`);
|
|
91
|
+
}
|
|
92
|
+
mode.strftime = rest.slice(1);
|
|
93
|
+
} else if (rest !== "") throw new DateModeError(`fatal: unknown date format ${spec}`);
|
|
94
|
+
return mode;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** The default date mode. */
|
|
98
|
+
export const DEFAULT_DATE_MODE: DateMode = { type: "normal", local: false };
|
|
99
|
+
|
|
100
|
+
const WEEKDAYS = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
|
|
101
|
+
const MONTHS = [
|
|
102
|
+
"January",
|
|
103
|
+
"February",
|
|
104
|
+
"March",
|
|
105
|
+
"April",
|
|
106
|
+
"May",
|
|
107
|
+
"June",
|
|
108
|
+
"July",
|
|
109
|
+
"August",
|
|
110
|
+
"September",
|
|
111
|
+
"October",
|
|
112
|
+
"November",
|
|
113
|
+
"December",
|
|
114
|
+
];
|
|
115
|
+
const pad = (n: number, width = 2, fill = "0") => String(n).padStart(width, fill);
|
|
116
|
+
|
|
117
|
+
/** A broken-down time (struct tm). */
|
|
118
|
+
interface Tm {
|
|
119
|
+
year: number;
|
|
120
|
+
mon: number;
|
|
121
|
+
mday: number;
|
|
122
|
+
hour: number;
|
|
123
|
+
min: number;
|
|
124
|
+
sec: number;
|
|
125
|
+
wday: number;
|
|
126
|
+
yday: number;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const isLeap = (y: number) => (y % 4 === 0 && y % 100 !== 0) || y % 400 === 0;
|
|
130
|
+
|
|
131
|
+
/** The first day of each month in a common year (date.c's mdays). */
|
|
132
|
+
const MDAYS = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334];
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* gmtime: the broken-down UTC time of `t` seconds, with integer arithmetic only (no `Date`,
|
|
136
|
+
* whose range ends in the year 275760: git shows `9999999999999 +0000` as the year 318857).
|
|
137
|
+
* Undefined when the year does not fit a C int (glibc's gmtime fails then).
|
|
138
|
+
*/
|
|
139
|
+
function gmtime(t: number): Tm | undefined {
|
|
140
|
+
let days = Math.floor(t / 86400);
|
|
141
|
+
const rem = t - days * 86400;
|
|
142
|
+
const hour = Math.floor(rem / 3600);
|
|
143
|
+
const min = Math.floor((rem % 3600) / 60);
|
|
144
|
+
const sec = rem % 60;
|
|
145
|
+
const wday = (((days + 4) % 7) + 7) % 7;
|
|
146
|
+
// civil from days (Howard Hinnant's algorithm), the era of 400 years first
|
|
147
|
+
days += 719468;
|
|
148
|
+
const era = Math.floor(days / 146097);
|
|
149
|
+
const doe = days - era * 146097;
|
|
150
|
+
const yoe = Math.floor(
|
|
151
|
+
(doe - Math.floor(doe / 1460) + Math.floor(doe / 36524) - Math.floor(doe / 146096)) / 365,
|
|
152
|
+
);
|
|
153
|
+
const doy = doe - (365 * yoe + Math.floor(yoe / 4) - Math.floor(yoe / 100));
|
|
154
|
+
const mp = Math.floor((5 * doy + 2) / 153);
|
|
155
|
+
const mday = doy - Math.floor((153 * mp + 2) / 5) + 1;
|
|
156
|
+
const mon = mp < 10 ? mp + 2 : mp - 10;
|
|
157
|
+
const year = yoe + era * 400 + (mon < 2 ? 1 : 0);
|
|
158
|
+
if (year - 1900 > 2147483647 || year - 1900 < -2147483648) return undefined;
|
|
159
|
+
const yday = (mon < 2 ? 0 : isLeap(year) ? 1 : 0) + (MDAYS[mon] as number) + mday - 1;
|
|
160
|
+
return { year, mon, mday, hour, min, sec, wday, yday };
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* git's "decimal parse of tz" (`-0130` is -130) as minutes east of UTC, as gm_time_t takes
|
|
165
|
+
* it: `+0060` is 60 minutes.
|
|
166
|
+
*/
|
|
167
|
+
function tzMinutes(tz: number): number {
|
|
168
|
+
const abs = Math.abs(tz);
|
|
169
|
+
const minutes = Math.trunc(abs / 100) * 60 + (abs % 100);
|
|
170
|
+
return tz < 0 ? -minutes : minutes;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/** Minutes east of UTC in git's decimal form (date.c's local_time_tzoffset). */
|
|
174
|
+
function tzDecimal(minutes: number): number {
|
|
175
|
+
const abs = Math.abs(minutes);
|
|
176
|
+
const value = (abs % 60) + Math.trunc(abs / 60) * 100;
|
|
177
|
+
return minutes < 0 ? -value : value;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/** An ident's zone as git reads it (show_ident_date's strtol): `+0200` is 200. */
|
|
181
|
+
function tzValue(tz: string): number {
|
|
182
|
+
const m = /^\s*([+-]?)(\d+)/.exec(tz);
|
|
183
|
+
if (!m) return 0;
|
|
184
|
+
const value = Number(m[2]) * (m[1] === "-" ? -1 : 1);
|
|
185
|
+
return value >= 2147483647 || value <= -2147483648 ? 0 : value;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/** printf's `%+05d` */
|
|
189
|
+
function tzText(tz: number): string {
|
|
190
|
+
return `${tz < 0 ? "-" : "+"}${pad(Math.abs(tz), 4)}`;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/** date.c's tm_to_time_t: only 1970..2099 (-1 elsewhere) */
|
|
194
|
+
function tmToTimeT(tm: Tm): number {
|
|
195
|
+
const year = tm.year - 1970;
|
|
196
|
+
if (year < 0 || year > 129) return -1;
|
|
197
|
+
let day = tm.mday;
|
|
198
|
+
if (tm.mon < 2 || (year + 2) % 4) day--;
|
|
199
|
+
return (
|
|
200
|
+
(year * 365 + Math.trunc((year + 1) / 4) + (MDAYS[tm.mon] as number) + day) * 86400 +
|
|
201
|
+
tm.hour * 3600 +
|
|
202
|
+
tm.min * 60 +
|
|
203
|
+
tm.sec
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/** The seconds of a broken-down time read as UTC (no range limit). */
|
|
208
|
+
function utcSeconds(tm: Tm): number {
|
|
209
|
+
const y = tm.mon < 2 ? tm.year - 1 : tm.year;
|
|
210
|
+
const era = Math.floor(y / 400);
|
|
211
|
+
const yoe = y - era * 400;
|
|
212
|
+
const mp = tm.mon < 2 ? tm.mon + 10 : tm.mon - 2;
|
|
213
|
+
const doy = Math.floor((153 * mp + 2) / 5) + tm.mday - 1;
|
|
214
|
+
const doe = yoe * 365 + Math.floor(yoe / 4) - Math.floor(yoe / 100) + doy;
|
|
215
|
+
const days = era * 146097 + doe - 719468;
|
|
216
|
+
return days * 86400 + tm.hour * 3600 + tm.min * 60 + tm.sec;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/** What strftime reads besides the broken-down time. */
|
|
220
|
+
interface StrftimeZone {
|
|
221
|
+
/** The zone's name (`tm_zone`: GMT for git's shifted times, the local zone's otherwise) */
|
|
222
|
+
name: string;
|
|
223
|
+
/** The local zone's offset east of UTC in minutes at a time (mktime, for `%s`) */
|
|
224
|
+
localTz: (time: number) => number;
|
|
225
|
+
/** `tm_gmtoff` in minutes (`%z` with flags): 0 for git's shifted times, local otherwise */
|
|
226
|
+
gmtoff: number;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/** glibc's iso_week_days */
|
|
230
|
+
function isoWeekDays(yday: number, wday: number): number {
|
|
231
|
+
const big = 378;
|
|
232
|
+
return yday - ((yday - wday + 4 + big) % 7) + 4 - 1;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* glibc's strftime in the C locale (time/strftime_l.c): the flags `_` `-` `0` `^` `#`, a
|
|
237
|
+
* field width, the `E` and `O` modifiers (no era or alternative digits in the C locale), and
|
|
238
|
+
* a conversion it does not know copied as written.
|
|
239
|
+
*/
|
|
240
|
+
function glibcStrftime(fmt: string, tm: Tm, zone: StrftimeZone): string {
|
|
241
|
+
let out = "";
|
|
242
|
+
const hour12 = tm.hour > 12 ? tm.hour - 12 : tm.hour === 0 ? 12 : tm.hour;
|
|
243
|
+
for (let f = 0; f < fmt.length; f++) {
|
|
244
|
+
if (fmt[f] !== "%") {
|
|
245
|
+
out += fmt[f];
|
|
246
|
+
continue;
|
|
247
|
+
}
|
|
248
|
+
const start = f;
|
|
249
|
+
let pad = "";
|
|
250
|
+
let toUpper = false;
|
|
251
|
+
let toLower = false;
|
|
252
|
+
let changeCase = false;
|
|
253
|
+
let width = -1;
|
|
254
|
+
for (;;) {
|
|
255
|
+
const c = fmt[++f];
|
|
256
|
+
if (c === "_" || c === "-" || c === "0") pad = c;
|
|
257
|
+
else if (c === "^") toUpper = true;
|
|
258
|
+
else if (c === "#") changeCase = true;
|
|
259
|
+
else break;
|
|
260
|
+
}
|
|
261
|
+
if (f < fmt.length && fmt[f] >= "0" && fmt[f] <= "9") {
|
|
262
|
+
width = 0;
|
|
263
|
+
while (f < fmt.length && fmt[f] >= "0" && fmt[f] <= "9") {
|
|
264
|
+
width = Math.min(2147483647, width * 10 + (fmt.charCodeAt(f) - 48));
|
|
265
|
+
f++;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
let modifier = "";
|
|
269
|
+
if (fmt[f] === "E" || fmt[f] === "O") modifier = fmt[f++] as string;
|
|
270
|
+
const add = (s: string) => {
|
|
271
|
+
const delta = width - s.length;
|
|
272
|
+
if (delta > 0) out += (pad === "0" ? "0" : " ").repeat(delta);
|
|
273
|
+
out += s;
|
|
274
|
+
};
|
|
275
|
+
const cpy = (s: string) => add(toLower ? s.toLowerCase() : toUpper ? s.toUpperCase() : s);
|
|
276
|
+
const subformat = (sub: string) => {
|
|
277
|
+
const text = glibcStrftime(sub, tm, zone);
|
|
278
|
+
add(toUpper ? text.toUpperCase() : text);
|
|
279
|
+
};
|
|
280
|
+
const badFormat = () => cpy(fmt.slice(start, f + 1));
|
|
281
|
+
/** do_number (`exact`: the digits not widened, as `%s` jumps past DO_NUMBER) */
|
|
282
|
+
const number = (d: number, value: number, spacepad = false, exact = false) => {
|
|
283
|
+
if (spacepad && pad !== "0" && pad !== "-") pad = "_";
|
|
284
|
+
const digits = exact || d > width ? d : width;
|
|
285
|
+
const negative = value < 0;
|
|
286
|
+
let buf = String(Math.abs(value));
|
|
287
|
+
if (negative) buf = `-${buf}`;
|
|
288
|
+
if (pad !== "-") {
|
|
289
|
+
const padding = digits - buf.length;
|
|
290
|
+
if (padding > 0) {
|
|
291
|
+
if (pad === "_") {
|
|
292
|
+
out += " ".repeat(padding);
|
|
293
|
+
width = width > padding ? width - padding : 0;
|
|
294
|
+
} else {
|
|
295
|
+
if (negative) {
|
|
296
|
+
out += "-";
|
|
297
|
+
buf = buf.slice(1);
|
|
298
|
+
}
|
|
299
|
+
out += "0".repeat(padding);
|
|
300
|
+
width = 0;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
cpy(buf);
|
|
305
|
+
};
|
|
306
|
+
const c = fmt[f];
|
|
307
|
+
switch (c) {
|
|
308
|
+
case "%":
|
|
309
|
+
if (modifier) badFormat();
|
|
310
|
+
else add("%");
|
|
311
|
+
break;
|
|
312
|
+
case "a":
|
|
313
|
+
case "A":
|
|
314
|
+
if (modifier) {
|
|
315
|
+
badFormat();
|
|
316
|
+
break;
|
|
317
|
+
}
|
|
318
|
+
if (changeCase) [toUpper, toLower] = [true, false];
|
|
319
|
+
cpy(c === "a" ? (WEEKDAYS[tm.wday] as string).slice(0, 3) : (WEEKDAYS[tm.wday] as string));
|
|
320
|
+
break;
|
|
321
|
+
case "b":
|
|
322
|
+
case "h":
|
|
323
|
+
case "B":
|
|
324
|
+
if (changeCase) [toUpper, toLower] = [true, false];
|
|
325
|
+
if (modifier === "E") badFormat();
|
|
326
|
+
else cpy(c === "B" ? (MONTHS[tm.mon] as string) : (MONTHS[tm.mon] as string).slice(0, 3));
|
|
327
|
+
break;
|
|
328
|
+
case "c":
|
|
329
|
+
if (modifier === "O") badFormat();
|
|
330
|
+
else subformat("%a %b %e %H:%M:%S %Y");
|
|
331
|
+
break;
|
|
332
|
+
case "C": {
|
|
333
|
+
const year = tm.year;
|
|
334
|
+
number(1, Math.trunc(year / 100) - (year % 100 < 0 ? 1 : 0));
|
|
335
|
+
break;
|
|
336
|
+
}
|
|
337
|
+
case "x":
|
|
338
|
+
if (modifier === "O") badFormat();
|
|
339
|
+
else subformat("%m/%d/%y");
|
|
340
|
+
break;
|
|
341
|
+
case "D":
|
|
342
|
+
if (modifier) badFormat();
|
|
343
|
+
else subformat("%m/%d/%y");
|
|
344
|
+
break;
|
|
345
|
+
case "d":
|
|
346
|
+
if (modifier === "E") badFormat();
|
|
347
|
+
else number(2, tm.mday);
|
|
348
|
+
break;
|
|
349
|
+
case "e":
|
|
350
|
+
if (modifier === "E") badFormat();
|
|
351
|
+
else number(2, tm.mday, true);
|
|
352
|
+
break;
|
|
353
|
+
case "F":
|
|
354
|
+
if (modifier) badFormat();
|
|
355
|
+
else subformat("%Y-%m-%d");
|
|
356
|
+
break;
|
|
357
|
+
case "H":
|
|
358
|
+
if (modifier === "E") badFormat();
|
|
359
|
+
else number(2, tm.hour);
|
|
360
|
+
break;
|
|
361
|
+
case "I":
|
|
362
|
+
if (modifier === "E") badFormat();
|
|
363
|
+
else number(2, hour12);
|
|
364
|
+
break;
|
|
365
|
+
case "k":
|
|
366
|
+
if (modifier === "E") badFormat();
|
|
367
|
+
else number(2, tm.hour, true);
|
|
368
|
+
break;
|
|
369
|
+
case "l":
|
|
370
|
+
if (modifier === "E") badFormat();
|
|
371
|
+
else number(2, hour12, true);
|
|
372
|
+
break;
|
|
373
|
+
case "j":
|
|
374
|
+
if (modifier === "E") badFormat();
|
|
375
|
+
else number(3, tm.yday + 1);
|
|
376
|
+
break;
|
|
377
|
+
case "M":
|
|
378
|
+
if (modifier === "E") badFormat();
|
|
379
|
+
else number(2, tm.min);
|
|
380
|
+
break;
|
|
381
|
+
case "m":
|
|
382
|
+
if (modifier === "E") badFormat();
|
|
383
|
+
else number(2, tm.mon + 1);
|
|
384
|
+
break;
|
|
385
|
+
case "n":
|
|
386
|
+
add("\n");
|
|
387
|
+
break;
|
|
388
|
+
case "t":
|
|
389
|
+
add("\t");
|
|
390
|
+
break;
|
|
391
|
+
case "P":
|
|
392
|
+
case "p":
|
|
393
|
+
if (c === "P") toLower = true;
|
|
394
|
+
if (changeCase) [toUpper, toLower] = [false, true];
|
|
395
|
+
cpy(tm.hour > 11 ? "PM" : "AM");
|
|
396
|
+
break;
|
|
397
|
+
case "R":
|
|
398
|
+
subformat("%H:%M");
|
|
399
|
+
break;
|
|
400
|
+
case "r":
|
|
401
|
+
subformat("%I:%M:%S %p");
|
|
402
|
+
break;
|
|
403
|
+
case "S":
|
|
404
|
+
if (modifier === "E") badFormat();
|
|
405
|
+
else number(2, tm.sec);
|
|
406
|
+
break;
|
|
407
|
+
case "s": {
|
|
408
|
+
// mktime: the broken-down time read in the local zone
|
|
409
|
+
const t = utcSeconds(tm);
|
|
410
|
+
const seconds = t - zone.localTz(t) * 60;
|
|
411
|
+
number(1, seconds, false, true);
|
|
412
|
+
break;
|
|
413
|
+
}
|
|
414
|
+
case "X":
|
|
415
|
+
if (modifier === "O") badFormat();
|
|
416
|
+
else subformat("%H:%M:%S");
|
|
417
|
+
break;
|
|
418
|
+
case "T":
|
|
419
|
+
subformat("%H:%M:%S");
|
|
420
|
+
break;
|
|
421
|
+
case "u":
|
|
422
|
+
number(1, ((tm.wday - 1 + 7) % 7) + 1);
|
|
423
|
+
break;
|
|
424
|
+
case "U":
|
|
425
|
+
if (modifier === "E") badFormat();
|
|
426
|
+
else number(2, Math.trunc((tm.yday - tm.wday + 7) / 7));
|
|
427
|
+
break;
|
|
428
|
+
case "V":
|
|
429
|
+
case "g":
|
|
430
|
+
case "G": {
|
|
431
|
+
if (modifier === "E") {
|
|
432
|
+
badFormat();
|
|
433
|
+
break;
|
|
434
|
+
}
|
|
435
|
+
let year = tm.year;
|
|
436
|
+
let days = isoWeekDays(tm.yday, tm.wday);
|
|
437
|
+
if (days < 0) {
|
|
438
|
+
year--;
|
|
439
|
+
days = isoWeekDays(tm.yday + (365 + (isLeap(year) ? 1 : 0)), tm.wday);
|
|
440
|
+
} else {
|
|
441
|
+
const d = isoWeekDays(tm.yday - (365 + (isLeap(year) ? 1 : 0)), tm.wday);
|
|
442
|
+
if (d >= 0) {
|
|
443
|
+
year++;
|
|
444
|
+
days = d;
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
if (c === "g") number(2, ((year % 100) + 100) % 100);
|
|
448
|
+
else if (c === "G") number(1, year);
|
|
449
|
+
else number(2, Math.trunc(days / 7) + 1);
|
|
450
|
+
break;
|
|
451
|
+
}
|
|
452
|
+
case "W":
|
|
453
|
+
if (modifier === "E") badFormat();
|
|
454
|
+
else number(2, Math.trunc((tm.yday - ((tm.wday - 1 + 7) % 7) + 7) / 7));
|
|
455
|
+
break;
|
|
456
|
+
case "w":
|
|
457
|
+
if (modifier === "E") badFormat();
|
|
458
|
+
else number(1, tm.wday);
|
|
459
|
+
break;
|
|
460
|
+
case "Y":
|
|
461
|
+
if (modifier === "O") badFormat();
|
|
462
|
+
else number(1, tm.year);
|
|
463
|
+
break;
|
|
464
|
+
case "y":
|
|
465
|
+
number(2, ((tm.year % 100) + 100) % 100);
|
|
466
|
+
break;
|
|
467
|
+
case "Z":
|
|
468
|
+
if (changeCase) [toUpper, toLower] = [false, true];
|
|
469
|
+
cpy(zone.name);
|
|
470
|
+
break;
|
|
471
|
+
case "z": {
|
|
472
|
+
// tm_gmtoff
|
|
473
|
+
let diff = zone.gmtoff;
|
|
474
|
+
if (diff < 0) {
|
|
475
|
+
add("-");
|
|
476
|
+
diff = -diff;
|
|
477
|
+
} else add("+");
|
|
478
|
+
number(4, Math.trunc(diff / 60) * 100 + (diff % 60));
|
|
479
|
+
break;
|
|
480
|
+
}
|
|
481
|
+
case undefined:
|
|
482
|
+
// a "%" at the end: copied with its flags
|
|
483
|
+
f--;
|
|
484
|
+
badFormat();
|
|
485
|
+
break;
|
|
486
|
+
default:
|
|
487
|
+
badFormat();
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
return out;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
/**
|
|
494
|
+
* git's strbuf_addftime: `%z` (the zone given), `%s` (from the time and that zone) and, when
|
|
495
|
+
* `suppressTz`, `%Z` handled before glibc's strftime gets the rest.
|
|
496
|
+
*/
|
|
497
|
+
function strftime(
|
|
498
|
+
fmt: string,
|
|
499
|
+
tm: Tm,
|
|
500
|
+
tz: number,
|
|
501
|
+
suppressTz: boolean,
|
|
502
|
+
zone: StrftimeZone,
|
|
503
|
+
): string {
|
|
504
|
+
let munged = "";
|
|
505
|
+
for (let i = 0; i < fmt.length; i++) {
|
|
506
|
+
const c = fmt[i];
|
|
507
|
+
if (c !== "%") {
|
|
508
|
+
munged += c;
|
|
509
|
+
continue;
|
|
510
|
+
}
|
|
511
|
+
const next = fmt[i + 1];
|
|
512
|
+
if (next === "%") {
|
|
513
|
+
munged += "%%";
|
|
514
|
+
i++;
|
|
515
|
+
} else if (next === "s") {
|
|
516
|
+
// timestamp_t arithmetic: unsigned (tm_to_time_t's -1 for a year past 2099 wraps)
|
|
517
|
+
const seconds = BigInt(3600 * Math.trunc(tz / 100) + 60 * (tz % 100));
|
|
518
|
+
munged += String(BigInt.asUintN(64, BigInt(tmToTimeT(tm)) - seconds));
|
|
519
|
+
i++;
|
|
520
|
+
} else if (next === "z") {
|
|
521
|
+
munged += tzText(tz);
|
|
522
|
+
i++;
|
|
523
|
+
} else if (suppressTz && next === "Z") {
|
|
524
|
+
i++;
|
|
525
|
+
} else munged += "%";
|
|
526
|
+
}
|
|
527
|
+
return glibcStrftime(munged, tm, zone);
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
/**
|
|
531
|
+
* The host's name for the local zone at a time (strftime's `%Z` of a local date): the
|
|
532
|
+
* abbreviation `Intl` knows (`PST`, `CEST`), else, for a zone tzdata only names by its offset
|
|
533
|
+
* (`Asia/Kathmandu`), the offset as glibc prints it (`+0545`).
|
|
534
|
+
*/
|
|
535
|
+
export function hostZoneName(time: number, localTz: (time: number) => number): string {
|
|
536
|
+
const date = new Date(time * 1000);
|
|
537
|
+
const named = (locale: string) => {
|
|
538
|
+
try {
|
|
539
|
+
return new Intl.DateTimeFormat(locale, { timeZoneName: "short" })
|
|
540
|
+
.formatToParts(date)
|
|
541
|
+
.find((p) => p.type === "timeZoneName")?.value;
|
|
542
|
+
} catch {
|
|
543
|
+
return undefined;
|
|
544
|
+
}
|
|
545
|
+
};
|
|
546
|
+
const isOffset = (name: string | undefined) => !name || /^(GMT|UTC)[+-]/.test(name);
|
|
547
|
+
let name = named("en-US");
|
|
548
|
+
if (isOffset(name)) name = isOffset(named("en-GB")) ? undefined : named("en-GB");
|
|
549
|
+
if (name) return name;
|
|
550
|
+
const minutes = localTz(time);
|
|
551
|
+
if (Number.isNaN(date.getTime())) return "";
|
|
552
|
+
return tzText(tzDecimal(minutes));
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
/** date.c's show_date_normal (with `human` the parts near now hidden). */
|
|
556
|
+
function showDateNormal(
|
|
557
|
+
time: number,
|
|
558
|
+
tm: Tm,
|
|
559
|
+
tz: number,
|
|
560
|
+
human: { tm: Tm; tz: number } | undefined,
|
|
561
|
+
local: boolean,
|
|
562
|
+
now: number,
|
|
563
|
+
): string {
|
|
564
|
+
const hide = { year: false, date: false, wday: false, time: false, seconds: false, tz: false };
|
|
565
|
+
// without `human`, git compares with a zeroed struct tm and a zone of -1: a date in the
|
|
566
|
+
// zone -0001 shows no zone (and one in 1900 no year)
|
|
567
|
+
const humanTm = human?.tm ?? { year: 1900, mon: 0, mday: 0 };
|
|
568
|
+
hide.tz = local || tz === (human ? human.tz : -1);
|
|
569
|
+
hide.year = tm.year === humanTm.year;
|
|
570
|
+
if (hide.year && tm.mon === humanTm.mon) {
|
|
571
|
+
if (tm.mday > humanTm.mday) {
|
|
572
|
+
// a future date: think time zones
|
|
573
|
+
} else if (tm.mday === humanTm.mday) {
|
|
574
|
+
hide.date = hide.wday = true;
|
|
575
|
+
} else if (tm.mday + 5 > humanTm.mday) {
|
|
576
|
+
hide.date = true;
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
if (hide.wday) return relativeDate(time, now);
|
|
580
|
+
if (human && human.tm.year !== 1900) {
|
|
581
|
+
hide.seconds = true;
|
|
582
|
+
hide.tz ||= !hide.date;
|
|
583
|
+
hide.wday = hide.time = !hide.year;
|
|
584
|
+
}
|
|
585
|
+
let out = "";
|
|
586
|
+
if (!hide.wday) out += `${(WEEKDAYS[tm.wday] as string).slice(0, 3)} `;
|
|
587
|
+
if (!hide.date) out += `${(MONTHS[tm.mon] as string).slice(0, 3)} ${tm.mday} `;
|
|
588
|
+
if (!hide.time) {
|
|
589
|
+
out += `${pad(tm.hour)}:${pad(tm.min)}`;
|
|
590
|
+
if (!hide.seconds) out += `:${pad(tm.sec)}`;
|
|
591
|
+
} else out = out.replace(/[ \t\n\r]+$/, "");
|
|
592
|
+
if (!hide.year) out += ` ${tm.year}`;
|
|
593
|
+
if (!hide.tz) out += ` ${tzText(tz)}`;
|
|
594
|
+
return out;
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
/**
|
|
598
|
+
* date.c's show_date: `time` (seconds) in its zone `tzOffset` (`+HHMM`, read as git reads
|
|
599
|
+
* it: `+0060` stays `+0060`) as the mode shows it.
|
|
600
|
+
*/
|
|
601
|
+
export function showDate(
|
|
602
|
+
time: number,
|
|
603
|
+
tzOffset: string,
|
|
604
|
+
mode: DateMode,
|
|
605
|
+
context: ShowDateContext = {},
|
|
606
|
+
): string {
|
|
607
|
+
if (mode.type === "unix") return String(time);
|
|
608
|
+
const now = context.now ?? Math.floor(Date.now() / 1000);
|
|
609
|
+
const localTz = context.localTzOffset ?? ((t: number) => -new Date(t * 1000).getTimezoneOffset());
|
|
610
|
+
const localMinutes = (t: number) => {
|
|
611
|
+
const m = localTz(t);
|
|
612
|
+
return Number.isFinite(m) ? m : 0;
|
|
613
|
+
};
|
|
614
|
+
let tz = tzValue(tzOffset);
|
|
615
|
+
let human: { tm: Tm; tz: number } | undefined;
|
|
616
|
+
if (mode.type === "human") {
|
|
617
|
+
const minutes = localMinutes(now);
|
|
618
|
+
human = { tm: gmtime(now + minutes * 60) ?? (gmtime(0) as Tm), tz: tzDecimal(minutes) };
|
|
619
|
+
}
|
|
620
|
+
if (mode.local) tz = tzDecimal(localMinutes(time));
|
|
621
|
+
if (mode.type === "raw") return `${time} ${tzText(tz)}`;
|
|
622
|
+
if (mode.type === "relative") return relativeDate(time, now);
|
|
623
|
+
let tm = gmtime(time + (mode.local ? localMinutes(time) : tzMinutes(tz)) * 60);
|
|
624
|
+
if (!tm) {
|
|
625
|
+
tm = gmtime(0) as Tm;
|
|
626
|
+
tz = 0;
|
|
627
|
+
}
|
|
628
|
+
switch (mode.type) {
|
|
629
|
+
case "short":
|
|
630
|
+
return `${pad(tm.year, 4)}-${pad(tm.mon + 1)}-${pad(tm.mday)}`;
|
|
631
|
+
case "iso8601":
|
|
632
|
+
return (
|
|
633
|
+
`${pad(tm.year, 4)}-${pad(tm.mon + 1)}-${pad(tm.mday)} ` +
|
|
634
|
+
`${pad(tm.hour)}:${pad(tm.min)}:${pad(tm.sec)} ${tzText(tz)}`
|
|
635
|
+
);
|
|
636
|
+
case "iso8601-strict": {
|
|
637
|
+
let out =
|
|
638
|
+
`${pad(tm.year, 4)}-${pad(tm.mon + 1)}-${pad(tm.mday)}T` +
|
|
639
|
+
`${pad(tm.hour)}:${pad(tm.min)}:${pad(tm.sec)}`;
|
|
640
|
+
if (tz === 0) out += "Z";
|
|
641
|
+
else {
|
|
642
|
+
const abs = Math.abs(tz);
|
|
643
|
+
out += `${tz >= 0 ? "+" : "-"}${pad(Math.trunc(abs / 100))}:${pad(abs % 100)}`;
|
|
644
|
+
}
|
|
645
|
+
return out;
|
|
646
|
+
}
|
|
647
|
+
case "rfc2822":
|
|
648
|
+
return (
|
|
649
|
+
`${(WEEKDAYS[tm.wday] as string).slice(0, 3)}, ${tm.mday} ` +
|
|
650
|
+
`${(MONTHS[tm.mon] as string).slice(0, 3)} ${tm.year} ` +
|
|
651
|
+
`${pad(tm.hour)}:${pad(tm.min)}:${pad(tm.sec)} ${tzText(tz)}`
|
|
652
|
+
);
|
|
653
|
+
case "strftime": {
|
|
654
|
+
if (!mode.strftime) return "";
|
|
655
|
+
const zone: StrftimeZone = {
|
|
656
|
+
// a shifted UTC time is GMT to strftime; a local one has the local zone's name
|
|
657
|
+
name: mode.local
|
|
658
|
+
? (context.localTzName ?? ((t: number) => hostZoneName(t, localMinutes)))(time)
|
|
659
|
+
: "GMT",
|
|
660
|
+
localTz: localMinutes,
|
|
661
|
+
gmtoff: mode.local ? localMinutes(time) : 0,
|
|
662
|
+
};
|
|
663
|
+
return strftime(mode.strftime, tm, tz, !mode.local, zone);
|
|
664
|
+
}
|
|
665
|
+
default:
|
|
666
|
+
return showDateNormal(time, tm, tz, human, mode.local, now);
|
|
667
|
+
}
|
|
668
|
+
}
|