@osdlc/typed-git 0.19.0 → 0.21.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/CHANGELOG.md +12 -0
- package/README.md +10 -7
- package/dist/async.d.ts +2 -2
- package/dist/async.js +11 -2
- package/dist/backend.d.ts +3 -3
- package/dist/backend.js +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/sync.d.ts +2 -2
- package/dist/sync.js +1 -1
- package/dist/verbs.d.ts +34 -9
- package/dist/verbs.js +40 -14
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @osdlc/typed-git
|
|
2
2
|
|
|
3
|
+
## 0.21.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 3f84b08: `update` rebases with `--fork-point` when it does not know the parent's old head. A child of a PR rebased in an earlier run, without `--restack`, now leaves the parent's old commits behind when the clone's reflog still holds them, instead of replaying them onto their new versions. A fresh clone has no such reflog and rebases as before. `git.rebase(onto, { forkPoint: true })` in typed-git passes `--fork-point`.
|
|
8
|
+
|
|
9
|
+
## 0.20.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- 1ba6088: `diffText` takes `context` (`--unified=<n>`, default 3) and `findRenames` (`-M`, off by default, so `diff.renames` still applies); `diffAddedFile` takes `context`. A negative or non-integer `context` throws a `TypeError`.
|
|
14
|
+
|
|
3
15
|
## 0.19.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -318,16 +318,19 @@ prints `-` there and a fabricated `0` would be worse than nothing.
|
|
|
318
318
|
## Diff output and the user's git configuration
|
|
319
319
|
|
|
320
320
|
`diffText` and `diffAddedFile` return a plain unified diff with `a/` and `b/`
|
|
321
|
-
prefixes and three lines of context. Both always pass `--no-color`,
|
|
321
|
+
prefixes and, by default, three lines of context. Both always pass `--no-color`,
|
|
322
322
|
`--no-ext-diff`, `--no-textconv`, `--src-prefix=a/`, `--dst-prefix=b/`,
|
|
323
|
-
`--no-relative`, `--submodule=short` and `--unified=3
|
|
323
|
+
`--no-relative`, `--submodule=short` and `--unified=3`; `context: n` (both
|
|
324
|
+
verbs) changes the last to `--unified=<n>`, so `context: 0` gives the changed
|
|
325
|
+
lines alone. `diffText` also takes `findRenames: true` (`-M`), which reads a
|
|
326
|
+
moved file as one rename patch whatever `diff.renames` says. So `color.ui`,
|
|
324
327
|
`color.diff`, `diff.external`, a `diff.<driver>.command` or textconv driver,
|
|
325
328
|
`diff.noprefix`, `diff.mnemonicPrefix`, `diff.srcPrefix`, `diff.dstPrefix`,
|
|
326
329
|
`diff.relative`, `diff.submodule` and `diff.context` do not change the text,
|
|
327
330
|
and none of them stops `git apply` taking it. Other settings still apply:
|
|
328
|
-
rename detection (`diff.renames`), `diff.ignoreSubmodules` and
|
|
331
|
+
rename detection (`diff.renames`, unless `findRenames` is set), `diff.ignoreSubmodules` and
|
|
329
332
|
`diff.algorithm`. The `GIT_DIFF_OPTS` environment variable also still applies:
|
|
330
|
-
`-u0` there overrides the
|
|
333
|
+
`-u0` there overrides the lines of context.
|
|
331
334
|
|
|
332
335
|
`diffNameStatus` passes `--no-relative`, so its paths are relative to the
|
|
333
336
|
repository root and cover the whole repository when the cwd is below the
|
|
@@ -763,8 +766,8 @@ exit throws the classified failure.
|
|
|
763
766
|
| `diffNameStatus({ cached, range, noRenames, paths })` | `diff --no-color --no-relative --name-status -z [--cached] [--no-renames] [range] [--] [paths]` | none — `--` is passed once, when there is a range or a path, so git never reads the range as a path |
|
|
764
767
|
| `diffStat({ rangeArgs, paths })` | `diff --stat` | none — raw stdout |
|
|
765
768
|
| `diffCheck({ paths })` | `diff --check` | `1`, `2` → `{ ok: false, output }` |
|
|
766
|
-
| `diffText(rev?, { staged, binary, paths })` | `diff --no-color --no-ext-diff --no-textconv --src-prefix=a/ --dst-prefix=b/ --no-relative --submodule=short --unified
|
|
767
|
-
| `diffAddedFile(relPath)` | `diff --no-color --no-ext-diff --no-textconv --src-prefix=a/ --dst-prefix=b/ --no-relative --submodule=short --unified
|
|
769
|
+
| `diffText(rev?, { staged, binary, context, findRenames, paths })` | `diff --no-color --no-ext-diff --no-textconv --src-prefix=a/ --dst-prefix=b/ --no-relative --submodule=short --unified=<context, default 3> [--cached] [--binary] [-M] [rev] [--] [paths]` | none — empty string only when nothing differs; a bad rev or a non-repository throws; `--` is passed once, when there is a rev or a path, so git never reads the rev as a path; the text is plain under the [settings the flags pin](#diff-output-and-the-users-git-configuration); `binary` writes a binary file's change as a patch `git apply` replays |
|
|
770
|
+
| `diffAddedFile(relPath, { context })` | `diff --no-color --no-ext-diff --no-textconv --src-prefix=a/ --dst-prefix=b/ --no-relative --submodule=short --unified=<context, default 3> --no-index -- /dev/null <path>` | none — exit 1 with output is success; exit 1 with no output, or exit 2, throws; the text is plain, as for `diffText` |
|
|
768
771
|
| `log(opts)` | `log` | none — raw stdout, unsplit |
|
|
769
772
|
| `logLines(opts)` | `log`, split and filtered | none |
|
|
770
773
|
| `lsTree(rev, { recursive, long, paths })` | `ls-tree -z` | none |
|
|
@@ -834,7 +837,7 @@ other non-zero exit throws.
|
|
|
834
837
|
| Method | git | Returns |
|
|
835
838
|
| --- | --- | --- |
|
|
836
839
|
| `merge(ref, { noFf, noCommit, ffOnly, message })` | `merge --no-edit` | `MergeOutcome` — with `ffOnly`, a merge that cannot fast-forward throws |
|
|
837
|
-
| `rebase(onto, { autostash, upstream })` | `rebase` (`--onto <onto> <upstream>` with `upstream`) | `RebaseOutcome` |
|
|
840
|
+
| `rebase(onto, { autostash, upstream, forkPoint })` | `rebase` (`--onto <onto> <upstream>` with `upstream`; `--fork-point` with `forkPoint`) | `RebaseOutcome` |
|
|
838
841
|
| `rebaseContinue()` | `-c core.editor=true rebase --continue` | `RebaseOutcome` |
|
|
839
842
|
| `mergeTree(ours, theirs, { mergeBase })` | `merge-tree --write-tree --name-only -z` | `MergeTreeOutcome` |
|
|
840
843
|
| `lsFilesUnmerged()` | `ls-files -u -z` | `UnmergedEntry[]` — mode, sha, stage, path |
|
package/dist/async.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ import { type GitBackend, type GitCallOptions } from './backend.ts';
|
|
|
18
18
|
import type { GitVersion } from './git-version.ts';
|
|
19
19
|
import { type Soft, type TriedAsync } from './outcome.ts';
|
|
20
20
|
import { type RemoteCoordinate } from './remote-url.ts';
|
|
21
|
-
import { type AddOptions, type AheadBehind, type CherryEntry, type CommitTreeOptions, type CommitOptions, type HashObjectOptions, type MktreeEntry, type UpdateRefOptions, type CheckoutOptions, type ConfigGetOptions, type CloneOptions, type ConflictSide, type MergeOptions, type MergeOutcome, type MergeTreeOptions, type MergeTreeOutcome, type RebaseOptions, type RebaseOutcome, type RemoteGetUrlOptions, type IndexSubmodule, type TaggedFile, type UnmergedEntry, type ConfigSetOptions, type DiffEntry, type DiffNameOnlyOptions, type DiffStatOptions, type DiffNameStatusOptions, type DiffTextOptions, type DiffTreeOptions, type FetchManyOptions, type FetchOptions, type ForEachRefOptions, type GrepOptions, type InitOptions, type LogOptions, type IgnoreMatch, type LsFilesOptions, type LsRemoteOptions, type LsTreeOptions, type NumstatEntry, type PushReport, type RemoteRef, type CleanOptions, type DiffCheckOptions, type DiffCheckResult, type StatusEntriesOptions, type StatusEntry, type StatusPorcelainOptions, type TreeEntry, type Worktree, type WorktreeAddOptions, type WorktreeMoveOptions, type GcOptions, type PushOptions, type RemoteSetBranchesOptions, type RemoteSetHeadOptions } from './verbs.ts';
|
|
21
|
+
import { type AddOptions, type AheadBehind, type CherryEntry, type CommitTreeOptions, type CommitOptions, type HashObjectOptions, type MktreeEntry, type UpdateRefOptions, type CheckoutOptions, type ConfigGetOptions, type CloneOptions, type ConflictSide, type MergeOptions, type MergeOutcome, type MergeTreeOptions, type MergeTreeOutcome, type RebaseOptions, type RebaseOutcome, type RemoteGetUrlOptions, type IndexSubmodule, type TaggedFile, type UnmergedEntry, type ConfigSetOptions, type DiffEntry, type DiffNameOnlyOptions, type DiffStatOptions, type DiffNameStatusOptions, type DiffAddedFileOptions, type DiffTextOptions, type DiffTreeOptions, type FetchManyOptions, type FetchOptions, type ForEachRefOptions, type GrepOptions, type InitOptions, type LogOptions, type IgnoreMatch, type LsFilesOptions, type LsRemoteOptions, type LsTreeOptions, type NumstatEntry, type PushReport, type RemoteRef, type CleanOptions, type DiffCheckOptions, type DiffCheckResult, type StatusEntriesOptions, type StatusEntry, type StatusPorcelainOptions, type TreeEntry, type Worktree, type WorktreeAddOptions, type WorktreeMoveOptions, type GcOptions, type PushOptions, type RemoteSetBranchesOptions, type RemoteSetHeadOptions } from './verbs.ts';
|
|
22
22
|
/** A typed, awaitable git client bound to one working directory. */
|
|
23
23
|
export declare class AsyncGit {
|
|
24
24
|
readonly cwd: string;
|
|
@@ -219,7 +219,7 @@ export declare class AsyncGit {
|
|
|
219
219
|
* One untracked file rendered as an all-added diff. A path git cannot read
|
|
220
220
|
* rejects. See {@link Git.diffAddedFile}.
|
|
221
221
|
*/
|
|
222
|
-
diffAddedFile(relPath: string, opts?: GitCallOptions): Promise<string>;
|
|
222
|
+
diffAddedFile(relPath: string, opts?: GitCallOptions & DiffAddedFileOptions): Promise<string>;
|
|
223
223
|
/** `for-each-ref` rows, one line each, in the caller's format. */
|
|
224
224
|
forEachRef(pattern: string | string[], opts?: GitCallOptions & ForEachRefOptions): Promise<string[]>;
|
|
225
225
|
/** Local refs matching `pattern` as `{ sha, ref }` rows. */
|
package/dist/async.js
CHANGED
|
@@ -348,14 +348,23 @@ export class AsyncGit {
|
|
|
348
348
|
*/
|
|
349
349
|
diffText(rev, opts = {}) {
|
|
350
350
|
const [call, req] = splitCallOptions(opts);
|
|
351
|
-
return this.backend.execute(this.cwd, {
|
|
351
|
+
return this.backend.execute(this.cwd, {
|
|
352
|
+
kind: 'diffText',
|
|
353
|
+
rev,
|
|
354
|
+
staged: req.staged,
|
|
355
|
+
binary: req.binary,
|
|
356
|
+
context: req.context,
|
|
357
|
+
findRenames: req.findRenames,
|
|
358
|
+
paths: req.paths,
|
|
359
|
+
}, call);
|
|
352
360
|
}
|
|
353
361
|
/**
|
|
354
362
|
* One untracked file rendered as an all-added diff. A path git cannot read
|
|
355
363
|
* rejects. See {@link Git.diffAddedFile}.
|
|
356
364
|
*/
|
|
357
365
|
diffAddedFile(relPath, opts = {}) {
|
|
358
|
-
|
|
366
|
+
const [call, req] = splitCallOptions(opts);
|
|
367
|
+
return this.backend.execute(this.cwd, { kind: 'diffAddedFile', relPath, context: req.context }, call);
|
|
359
368
|
}
|
|
360
369
|
/** `for-each-ref` rows, one line each, in the caller's format. */
|
|
361
370
|
forEachRef(pattern, opts = {}) {
|
package/dist/backend.d.ts
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
*/
|
|
20
20
|
import { type AsyncBytesCommandRunner, type AsyncCommandRunner, type CommandResult } from '@osdlc/command-seam';
|
|
21
21
|
import { type GitVersion } from './git-version.ts';
|
|
22
|
-
import { type AddOptions, type AheadBehind, type CherryEntry, type CommitTreeOptions, type HashObjectOptions, type MktreeEntry, type UpdateRefOptions, type CheckoutOptions, type CloneOptions, type CommitOptions, type ConfigGetOptions, type ConfigSetOptions, type ConflictSide, type DiffEntry, type DiffNameOnlyOptions, type DiffStatOptions, type DiffNameStatusOptions, type DiffTextOptions, type DiffTreeOptions, type FetchManyOptions, type FetchOptions, type ForEachRefOptions, type GcOptions, type GrepOptions, type InitOptions, type LogOptions, type IgnoreMatch, type LsFilesOptions, type LsRemoteOptions, type LsTreeOptions, type MergeOptions, type MergeOutcome, type MergeTreeOptions, type MergeTreeOutcome, type NumstatEntry, type PushOptions, type PushReport, type RemoteSetBranchesOptions, type RemoteSetHeadOptions, type WorktreeAddOptions, type RebaseOptions, type RebaseOutcome, type RemoteGetUrlOptions, type RemoteRef, type CleanOptions, type DiffCheckOptions, type DiffCheckResult, type StatusEntriesOptions, type StatusEntry, type StatusPorcelainOptions, type TreeEntry, type IndexSubmodule, type TaggedFile, type UnmergedEntry, type Worktree, type WorktreeMoveOptions } from './verbs.ts';
|
|
22
|
+
import { type AddOptions, type AheadBehind, type CherryEntry, type CommitTreeOptions, type HashObjectOptions, type MktreeEntry, type UpdateRefOptions, type CheckoutOptions, type CloneOptions, type CommitOptions, type ConfigGetOptions, type ConfigSetOptions, type ConflictSide, type DiffEntry, type DiffNameOnlyOptions, type DiffStatOptions, type DiffNameStatusOptions, type DiffAddedFileOptions, type DiffTextOptions, type DiffTreeOptions, type FetchManyOptions, type FetchOptions, type ForEachRefOptions, type GcOptions, type GrepOptions, type InitOptions, type LogOptions, type IgnoreMatch, type LsFilesOptions, type LsRemoteOptions, type LsTreeOptions, type MergeOptions, type MergeOutcome, type MergeTreeOptions, type MergeTreeOutcome, type NumstatEntry, type PushOptions, type PushReport, type RemoteSetBranchesOptions, type RemoteSetHeadOptions, type WorktreeAddOptions, type RebaseOptions, type RebaseOutcome, type RemoteGetUrlOptions, type RemoteRef, type CleanOptions, type DiffCheckOptions, type DiffCheckResult, type StatusEntriesOptions, type StatusEntry, type StatusPorcelainOptions, type TreeEntry, type IndexSubmodule, type TaggedFile, type UnmergedEntry, type Worktree, type WorktreeMoveOptions } from './verbs.ts';
|
|
23
23
|
/** Per-call concerns that are not part of the operation itself. */
|
|
24
24
|
export interface GitCallOptions {
|
|
25
25
|
/**
|
|
@@ -186,10 +186,10 @@ export type GitRequest = {
|
|
|
186
186
|
} & GrepOptions) | ({
|
|
187
187
|
kind: 'diffText';
|
|
188
188
|
rev?: string | undefined;
|
|
189
|
-
} & DiffTextOptions) | {
|
|
189
|
+
} & DiffTextOptions) | ({
|
|
190
190
|
kind: 'diffAddedFile';
|
|
191
191
|
relPath: string;
|
|
192
|
-
} | ({
|
|
192
|
+
} & DiffAddedFileOptions) | ({
|
|
193
193
|
kind: 'fetch';
|
|
194
194
|
remote: string;
|
|
195
195
|
refspec?: string | string[] | undefined;
|
package/dist/backend.js
CHANGED
|
@@ -121,7 +121,7 @@ function toVerb(request) {
|
|
|
121
121
|
case 'diffText':
|
|
122
122
|
return v.diffText(request.rev, request);
|
|
123
123
|
case 'diffAddedFile':
|
|
124
|
-
return v.diffAddedFile(request.relPath);
|
|
124
|
+
return v.diffAddedFile(request.relPath, request);
|
|
125
125
|
case 'fetch':
|
|
126
126
|
return v.fetch(request.remote, request.refspec, request);
|
|
127
127
|
case 'fetchMany':
|
package/dist/client.d.ts
CHANGED
|
@@ -22,6 +22,6 @@ export { classifyGitFailure, describeGitFailure, UnsupportedRequest, type GitFai
|
|
|
22
22
|
export { type Soft, type TriedAsync, type TriedSync } from './outcome.ts';
|
|
23
23
|
export { GIT_FEATURES, GIT_FLOOR, gitSupports, type GitFeature, type GitFeatureSpec, type GitRelease, type UnsupportedGit, } from './features.ts';
|
|
24
24
|
export { compareGitVersions, parseGitVersion, type GitVersion } from './git-version.ts';
|
|
25
|
-
export { forceWithLeaseArg, parseRefRows, PUSH_REJECTIONS, REF_FORMAT, type AddOptions, type AheadBehind, type CherryEntry, type CommitTreeOptions, type CheckoutOptions, type CleanOptions, type CloneOptions, type CommitFlags, type CommitOptions, type ConfigGetOptions, type ConfigScope, type ConfigSetOptions, type ConflictSide, type DiffCheckOptions, type DiffCheckResult, type DiffEntry, type DiffNameOnlyOptions, type DiffNameStatusOptions, type DiffStatOptions, type DiffTextOptions, type DiffTreeOptions, type FetchManyOptions, type FetchOptions, type ForEachRefOptions, type ForceLease, type GcOptions, type GrepOptions, type HashObjectOptions, type InitOptions, type IntegrationOutcome, type LogOptions, type IgnoreMatch, type LsFilesOptions, type LsRemoteOptions, type LsTreeOptions, type MergeOptions, type MergeOutcome, type MergeTreeOptions, type MergeTreeOutcome, type MktreeEntry, type NumstatEntry, type PushFlag, type PushOptions, type PushRefResult, type PushRejection, type PushRejectionInfo, type PushReport, type RebaseOptions, type RebaseOutcome, type RemoteGetUrlOptions, type RemoteRef, type RemoteSetBranchesOptions, type RemoteSetHeadOptions, type StatusEntriesOptions, type StatusEntry, type StatusPorcelainOptions, type IndexSubmodule, type TaggedFile, type TreeEntry, type UnmergedEntry, type UpdateRefOptions, type Worktree, type WorktreeAddOptions, type WorktreeMoveOptions, } from './verbs.ts';
|
|
25
|
+
export { forceWithLeaseArg, parseRefRows, PUSH_REJECTIONS, REF_FORMAT, type AddOptions, type AheadBehind, type CherryEntry, type CommitTreeOptions, type CheckoutOptions, type CleanOptions, type CloneOptions, type CommitFlags, type CommitOptions, type ConfigGetOptions, type ConfigScope, type ConfigSetOptions, type ConflictSide, type DiffCheckOptions, type DiffCheckResult, type DiffEntry, type DiffNameOnlyOptions, type DiffNameStatusOptions, type DiffStatOptions, type DiffAddedFileOptions, type DiffTextOptions, type DiffTreeOptions, type FetchManyOptions, type FetchOptions, type ForEachRefOptions, type ForceLease, type GcOptions, type GrepOptions, type HashObjectOptions, type InitOptions, type IntegrationOutcome, type LogOptions, type IgnoreMatch, type LsFilesOptions, type LsRemoteOptions, type LsTreeOptions, type MergeOptions, type MergeOutcome, type MergeTreeOptions, type MergeTreeOutcome, type MktreeEntry, type NumstatEntry, type PushFlag, type PushOptions, type PushRefResult, type PushRejection, type PushRejectionInfo, type PushReport, type RebaseOptions, type RebaseOutcome, type RemoteGetUrlOptions, type RemoteRef, type RemoteSetBranchesOptions, type RemoteSetHeadOptions, type StatusEntriesOptions, type StatusEntry, type StatusPorcelainOptions, type IndexSubmodule, type TaggedFile, type TreeEntry, type UnmergedEntry, type UpdateRefOptions, type Worktree, type WorktreeAddOptions, type WorktreeMoveOptions, } from './verbs.ts';
|
|
26
26
|
export { asAsync, CommandFailed, runChecked, runCheckedAsync, spawnRunner, spawnRunnerAsync, spawnRunnerBytes, spawnRunnerBytesAsync, type AsyncBytesCommandRunner, type AsyncCommandRunner, type AsyncCommandRunOptions, type BytesCommandRunner, type CommandResult, type CommandRunner, type CommandRunOptions, } from '@osdlc/command-seam';
|
|
27
27
|
export type { CatFileBatchOptions, CatFileEntry } from './cat-file.ts';
|
package/dist/sync.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ import { type CatFileBatchOptions, type CatFileEntry } from './cat-file.ts';
|
|
|
20
20
|
import { type GitVersion } from './git-version.ts';
|
|
21
21
|
import { type Soft, type TriedSync } from './outcome.ts';
|
|
22
22
|
import { type RemoteCoordinate } from './remote-url.ts';
|
|
23
|
-
import { type AddOptions, type AheadBehind, type CherryEntry, type CommitTreeOptions, type CommitOptions, type HashObjectOptions, type MktreeEntry, type UpdateRefOptions, type CheckoutOptions, type ConfigGetOptions, type CloneOptions, type ConflictSide, type MergeOptions, type MergeOutcome, type MergeTreeOptions, type MergeTreeOutcome, type RebaseOptions, type RebaseOutcome, type RemoteGetUrlOptions, type IndexSubmodule, type TaggedFile, type UnmergedEntry, type ConfigSetOptions, type DiffEntry, type DiffNameOnlyOptions, type DiffStatOptions, type DiffNameStatusOptions, type DiffTextOptions, type DiffTreeOptions, type FetchManyOptions, type FetchOptions, type ForEachRefOptions, type GrepOptions, type InitOptions, type LogOptions, type IgnoreMatch, type LsFilesOptions, type LsRemoteOptions, type LsTreeOptions, type NumstatEntry, type PushReport, type RemoteRef, type CleanOptions, type DiffCheckOptions, type DiffCheckResult, type StatusEntriesOptions, type StatusEntry, type StatusPorcelainOptions, type TreeEntry, type Worktree, type WorktreeAddOptions, type WorktreeMoveOptions, type GcOptions, type PushOptions, type RemoteSetBranchesOptions, type RemoteSetHeadOptions } from './verbs.ts';
|
|
23
|
+
import { type AddOptions, type AheadBehind, type CherryEntry, type CommitTreeOptions, type CommitOptions, type HashObjectOptions, type MktreeEntry, type UpdateRefOptions, type CheckoutOptions, type ConfigGetOptions, type CloneOptions, type ConflictSide, type MergeOptions, type MergeOutcome, type MergeTreeOptions, type MergeTreeOutcome, type RebaseOptions, type RebaseOutcome, type RemoteGetUrlOptions, type IndexSubmodule, type TaggedFile, type UnmergedEntry, type ConfigSetOptions, type DiffEntry, type DiffNameOnlyOptions, type DiffStatOptions, type DiffNameStatusOptions, type DiffAddedFileOptions, type DiffTextOptions, type DiffTreeOptions, type FetchManyOptions, type FetchOptions, type ForEachRefOptions, type GrepOptions, type InitOptions, type LogOptions, type IgnoreMatch, type LsFilesOptions, type LsRemoteOptions, type LsTreeOptions, type NumstatEntry, type PushReport, type RemoteRef, type CleanOptions, type DiffCheckOptions, type DiffCheckResult, type StatusEntriesOptions, type StatusEntry, type StatusPorcelainOptions, type TreeEntry, type Worktree, type WorktreeAddOptions, type WorktreeMoveOptions, type GcOptions, type PushOptions, type RemoteSetBranchesOptions, type RemoteSetHeadOptions } from './verbs.ts';
|
|
24
24
|
/**
|
|
25
25
|
* Per-call concerns that are not part of the operation itself.
|
|
26
26
|
*
|
|
@@ -343,7 +343,7 @@ export declare class Git {
|
|
|
343
343
|
* One untracked file rendered as an all-added diff. A path git cannot read
|
|
344
344
|
* throws. See `diffAddedFile` in `verbs.ts`.
|
|
345
345
|
*/
|
|
346
|
-
diffAddedFile(relPath: string, opts?: GitSyncCallOptions): string;
|
|
346
|
+
diffAddedFile(relPath: string, opts?: GitSyncCallOptions & DiffAddedFileOptions): string;
|
|
347
347
|
/** `for-each-ref` rows, one line each, in the caller's format. */
|
|
348
348
|
forEachRef(pattern: string | string[], opts?: GitSyncCallOptions & ForEachRefOptions): string[];
|
|
349
349
|
/**
|
package/dist/sync.js
CHANGED
|
@@ -503,7 +503,7 @@ export class Git {
|
|
|
503
503
|
* throws. See `diffAddedFile` in `verbs.ts`.
|
|
504
504
|
*/
|
|
505
505
|
diffAddedFile(relPath, opts = {}) {
|
|
506
|
-
return this.exec(v.diffAddedFile(relPath), opts);
|
|
506
|
+
return this.exec(v.diffAddedFile(relPath, opts), opts);
|
|
507
507
|
}
|
|
508
508
|
/** `for-each-ref` rows, one line each, in the caller's format. */
|
|
509
509
|
forEachRef(pattern, opts = {}) {
|
package/dist/verbs.d.ts
CHANGED
|
@@ -761,30 +761,48 @@ export interface DiffTextOptions {
|
|
|
761
761
|
* The patch is ASCII (base85), so the decode to a string keeps it intact.
|
|
762
762
|
*/
|
|
763
763
|
binary?: boolean | undefined;
|
|
764
|
+
/**
|
|
765
|
+
* `--unified=<n>`: lines of context around each change. Default 3, whatever
|
|
766
|
+
* `diff.context` says; 0 gives a patch of the changed lines alone. A
|
|
767
|
+
* non-negative integer, else the verb throws a `TypeError`.
|
|
768
|
+
*/
|
|
769
|
+
context?: number | undefined;
|
|
770
|
+
/**
|
|
771
|
+
* `-M`: detect renames, whatever `diff.renames` says, so a moved file reads
|
|
772
|
+
* as one `rename from`/`rename to` patch and not as a delete plus an add.
|
|
773
|
+
* Off by default: without it `diff.renames` applies (git's own default is
|
|
774
|
+
* on).
|
|
775
|
+
*/
|
|
776
|
+
findRenames?: boolean | undefined;
|
|
764
777
|
/** Pathspecs, passed after `--`. */
|
|
765
778
|
paths?: string[] | undefined;
|
|
766
779
|
}
|
|
780
|
+
/** Options for {@link diffAddedFile}. */
|
|
781
|
+
export interface DiffAddedFileOptions {
|
|
782
|
+
/** `--unified=<n>`: lines of context. As {@link DiffTextOptions.context}. */
|
|
783
|
+
context?: number | undefined;
|
|
784
|
+
}
|
|
767
785
|
/**
|
|
768
786
|
* The unified diff text (`git diff --no-color --no-ext-diff --no-textconv
|
|
769
787
|
* --src-prefix=a/ --dst-prefix=b/ --no-relative --submodule=short
|
|
770
|
-
* --unified
|
|
788
|
+
* --unified=<context> [--cached] [--binary] [-M] [rev] [--] [paths]`), for the same rev
|
|
771
789
|
* and staged shape {@link diffNameStatus} lists paths for. `--` is passed
|
|
772
790
|
* once, when there is a rev or a path. Empty when nothing differs.
|
|
773
791
|
* {@link diffNameOnly} selects the same paths except under `diff.relative`,
|
|
774
792
|
* which it still follows.
|
|
775
793
|
*
|
|
776
|
-
* The text is a plain unified diff with `a/` and `b/` prefixes
|
|
777
|
-
* lines of context. The flags that are always passed turn off colour codes
|
|
794
|
+
* The text is a plain unified diff with `a/` and `b/` prefixes. The flags that are always passed turn off colour codes
|
|
778
795
|
* (`color.ui`, `color.diff`), an external diff tool (`diff.external`, a
|
|
779
796
|
* `diff.<driver>.command`), textconv conversion, other prefixes
|
|
780
797
|
* (`diff.noprefix`, `diff.mnemonicPrefix`, `diff.srcPrefix`,
|
|
781
798
|
* `diff.dstPrefix`) and `diff.relative`, which with a cwd below the
|
|
782
799
|
* repository root would drop changes outside it. They also keep a submodule
|
|
783
800
|
* change as a `Subproject commit` patch, whatever `diff.submodule` says, and
|
|
784
|
-
* the context at
|
|
785
|
-
* still apply: rename detection (`diff.renames
|
|
786
|
-
* `
|
|
787
|
-
*
|
|
801
|
+
* the context at `context` lines (default three), whatever `diff.context`
|
|
802
|
+
* says. Other settings still apply: rename detection (`diff.renames`, unless
|
|
803
|
+
* `findRenames` pins it on), `diff.ignoreSubmodules` and `diff.algorithm`; so
|
|
804
|
+
* does the `GIT_DIFF_OPTS` environment variable, where `-u0` overrides the
|
|
805
|
+
* lines of context. The rev is followed by `--`, so git never reads it as a
|
|
788
806
|
* path: a rev that names a file but no revision throws, and a branch that
|
|
789
807
|
* shares its name with a file works.
|
|
790
808
|
*
|
|
@@ -801,7 +819,7 @@ export declare function diffText(rev?: string | undefined, opts?: DiffTextOption
|
|
|
801
819
|
/**
|
|
802
820
|
* One untracked file rendered as an all-added diff (`diff --no-color
|
|
803
821
|
* --no-ext-diff --no-textconv --src-prefix=a/ --dst-prefix=b/ --no-relative
|
|
804
|
-
* --submodule=short --unified
|
|
822
|
+
* --submodule=short --unified=<context> --no-index -- /dev/null <path>`), so a new
|
|
805
823
|
* file reaches a consumer in the same shape as a modified one: the flags are
|
|
806
824
|
* the ones {@link diffText} passes, and the text is as plain. An empty
|
|
807
825
|
* existing file still gives a diff header.
|
|
@@ -811,7 +829,7 @@ export declare function diffText(rev?: string | undefined, opts?: DiffTextOption
|
|
|
811
829
|
* for a path it cannot read; that throws the classified failure. Exit 2 (a usage or
|
|
812
830
|
* read error) throws too.
|
|
813
831
|
*/
|
|
814
|
-
export declare function diffAddedFile(relPath: string): GitVerb<string>;
|
|
832
|
+
export declare function diffAddedFile(relPath: string, opts?: DiffAddedFileOptions): GitVerb<string>;
|
|
815
833
|
/**
|
|
816
834
|
* The paths and statuses one commit changed (`git diff-tree --name-status -z`).
|
|
817
835
|
*
|
|
@@ -1627,6 +1645,13 @@ export interface RebaseOptions {
|
|
|
1627
1645
|
* base commits are left behind instead of replayed onto the new ones.
|
|
1628
1646
|
*/
|
|
1629
1647
|
upstream?: string | undefined;
|
|
1648
|
+
/**
|
|
1649
|
+
* `--fork-point`: take the branch's old base from the reflog of `onto`, so
|
|
1650
|
+
* commits the base held before it was rewritten are left behind. Where the
|
|
1651
|
+
* reflog lacks the old base (a fresh clone), git falls back to the merge
|
|
1652
|
+
* base, which is a plain `rebase`. `upstream` wins when both are set.
|
|
1653
|
+
*/
|
|
1654
|
+
forkPoint?: boolean | undefined;
|
|
1630
1655
|
}
|
|
1631
1656
|
/**
|
|
1632
1657
|
* Replay the current branch onto `onto` (`git rebase`, or
|
package/dist/verbs.js
CHANGED
|
@@ -233,7 +233,7 @@ function pushRevAndPaths(argv, rev, paths) {
|
|
|
233
233
|
* The `git diff` flags that pin patch text against the user's git settings:
|
|
234
234
|
* no colour codes, no external diff tool, no textconv conversion, the `a/`
|
|
235
235
|
* and `b/` prefixes, paths that are not cut to the cwd, a submodule change as
|
|
236
|
-
* a `Subproject commit` patch
|
|
236
|
+
* a `Subproject commit` patch. The context is {@link unifiedArg}'s.
|
|
237
237
|
*/
|
|
238
238
|
const PLAIN_PATCH = [
|
|
239
239
|
'--no-color',
|
|
@@ -243,8 +243,21 @@ const PLAIN_PATCH = [
|
|
|
243
243
|
'--dst-prefix=b/',
|
|
244
244
|
'--no-relative',
|
|
245
245
|
'--submodule=short',
|
|
246
|
-
'--unified=3',
|
|
247
246
|
];
|
|
247
|
+
/** The lines of context {@link diffText} and {@link diffAddedFile} print by default. */
|
|
248
|
+
const DEFAULT_CONTEXT = 3;
|
|
249
|
+
/**
|
|
250
|
+
* `--unified=<context>`, or the default when `context` is undefined. Throws
|
|
251
|
+
* `TypeError` when `context` is not a non-negative safe integer; `verb` names
|
|
252
|
+
* the caller in the message.
|
|
253
|
+
*/
|
|
254
|
+
function unifiedArg(verb, context) {
|
|
255
|
+
const n = context ?? DEFAULT_CONTEXT;
|
|
256
|
+
if (!Number.isSafeInteger(n) || n < 0) {
|
|
257
|
+
throw new TypeError(`typed-git: ${verb}: context must be a non-negative integer (got ${JSON.stringify(n)})`);
|
|
258
|
+
}
|
|
259
|
+
return `--unified=${n}`;
|
|
260
|
+
}
|
|
248
261
|
/** The child env that makes git print English, whatever the caller's locale. */
|
|
249
262
|
const C_LOCALE = Object.freeze({ LC_ALL: 'C' });
|
|
250
263
|
// ── queries ─────────────────────────────────────────────────────────────────
|
|
@@ -1030,24 +1043,24 @@ export function lsTree(rev, opts = {}) {
|
|
|
1030
1043
|
/**
|
|
1031
1044
|
* The unified diff text (`git diff --no-color --no-ext-diff --no-textconv
|
|
1032
1045
|
* --src-prefix=a/ --dst-prefix=b/ --no-relative --submodule=short
|
|
1033
|
-
* --unified
|
|
1046
|
+
* --unified=<context> [--cached] [--binary] [-M] [rev] [--] [paths]`), for the same rev
|
|
1034
1047
|
* and staged shape {@link diffNameStatus} lists paths for. `--` is passed
|
|
1035
1048
|
* once, when there is a rev or a path. Empty when nothing differs.
|
|
1036
1049
|
* {@link diffNameOnly} selects the same paths except under `diff.relative`,
|
|
1037
1050
|
* which it still follows.
|
|
1038
1051
|
*
|
|
1039
|
-
* The text is a plain unified diff with `a/` and `b/` prefixes
|
|
1040
|
-
* lines of context. The flags that are always passed turn off colour codes
|
|
1052
|
+
* The text is a plain unified diff with `a/` and `b/` prefixes. The flags that are always passed turn off colour codes
|
|
1041
1053
|
* (`color.ui`, `color.diff`), an external diff tool (`diff.external`, a
|
|
1042
1054
|
* `diff.<driver>.command`), textconv conversion, other prefixes
|
|
1043
1055
|
* (`diff.noprefix`, `diff.mnemonicPrefix`, `diff.srcPrefix`,
|
|
1044
1056
|
* `diff.dstPrefix`) and `diff.relative`, which with a cwd below the
|
|
1045
1057
|
* repository root would drop changes outside it. They also keep a submodule
|
|
1046
1058
|
* change as a `Subproject commit` patch, whatever `diff.submodule` says, and
|
|
1047
|
-
* the context at
|
|
1048
|
-
* still apply: rename detection (`diff.renames
|
|
1049
|
-
* `
|
|
1050
|
-
*
|
|
1059
|
+
* the context at `context` lines (default three), whatever `diff.context`
|
|
1060
|
+
* says. Other settings still apply: rename detection (`diff.renames`, unless
|
|
1061
|
+
* `findRenames` pins it on), `diff.ignoreSubmodules` and `diff.algorithm`; so
|
|
1062
|
+
* does the `GIT_DIFF_OPTS` environment variable, where `-u0` overrides the
|
|
1063
|
+
* lines of context. The rev is followed by `--`, so git never reads it as a
|
|
1051
1064
|
* path: a rev that names a file but no revision throws, and a branch that
|
|
1052
1065
|
* shares its name with a file works.
|
|
1053
1066
|
*
|
|
@@ -1061,18 +1074,20 @@ export function lsTree(rev, opts = {}) {
|
|
|
1061
1074
|
* "no diff". `git.try.diffText` reports them as `{ ok: false }`.
|
|
1062
1075
|
*/
|
|
1063
1076
|
export function diffText(rev, opts = {}) {
|
|
1064
|
-
const argv = ['diff', ...PLAIN_PATCH];
|
|
1077
|
+
const argv = ['diff', ...PLAIN_PATCH, unifiedArg('diffText', opts.context)];
|
|
1065
1078
|
if (opts.staged === true)
|
|
1066
1079
|
argv.push('--cached');
|
|
1067
1080
|
if (opts.binary === true)
|
|
1068
1081
|
argv.push('--binary');
|
|
1082
|
+
if (opts.findRenames === true)
|
|
1083
|
+
argv.push('-M');
|
|
1069
1084
|
pushRevAndPaths(argv, optionalPositional('diffText', 'rev', rev), opts.paths);
|
|
1070
1085
|
return { argv, absent: NONE, parse: (r) => r.stdout };
|
|
1071
1086
|
}
|
|
1072
1087
|
/**
|
|
1073
1088
|
* One untracked file rendered as an all-added diff (`diff --no-color
|
|
1074
1089
|
* --no-ext-diff --no-textconv --src-prefix=a/ --dst-prefix=b/ --no-relative
|
|
1075
|
-
* --submodule=short --unified
|
|
1090
|
+
* --submodule=short --unified=<context> --no-index -- /dev/null <path>`), so a new
|
|
1076
1091
|
* file reaches a consumer in the same shape as a modified one: the flags are
|
|
1077
1092
|
* the ones {@link diffText} passes, and the text is as plain. An empty
|
|
1078
1093
|
* existing file still gives a diff header.
|
|
@@ -1082,9 +1097,17 @@ export function diffText(rev, opts = {}) {
|
|
|
1082
1097
|
* for a path it cannot read; that throws the classified failure. Exit 2 (a usage or
|
|
1083
1098
|
* read error) throws too.
|
|
1084
1099
|
*/
|
|
1085
|
-
export function diffAddedFile(relPath) {
|
|
1100
|
+
export function diffAddedFile(relPath, opts = {}) {
|
|
1086
1101
|
return {
|
|
1087
|
-
argv: [
|
|
1102
|
+
argv: [
|
|
1103
|
+
'diff',
|
|
1104
|
+
...PLAIN_PATCH,
|
|
1105
|
+
unifiedArg('diffAddedFile', opts.context),
|
|
1106
|
+
'--no-index',
|
|
1107
|
+
'--',
|
|
1108
|
+
'/dev/null',
|
|
1109
|
+
relPath,
|
|
1110
|
+
],
|
|
1088
1111
|
absent: [1],
|
|
1089
1112
|
parse(r, ranArgv) {
|
|
1090
1113
|
if (r.exitCode !== 0 && r.stdout === '')
|
|
@@ -2259,8 +2282,11 @@ export function rebase(onto, opts = {}) {
|
|
|
2259
2282
|
const argv = ['rebase'];
|
|
2260
2283
|
if (opts.autostash)
|
|
2261
2284
|
argv.push('--autostash');
|
|
2262
|
-
if (opts.upstream === undefined)
|
|
2285
|
+
if (opts.upstream === undefined) {
|
|
2286
|
+
if (opts.forkPoint)
|
|
2287
|
+
argv.push('--fork-point');
|
|
2263
2288
|
argv.push(positional('rebase', 'onto', onto));
|
|
2289
|
+
}
|
|
2264
2290
|
else {
|
|
2265
2291
|
argv.push('--onto', positional('rebase', 'onto', onto), positional('rebase', 'upstream', opts.upstream));
|
|
2266
2292
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@osdlc/typed-git",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.0",
|
|
4
4
|
"description": "A typed git client for TypeScript, sync and awaitable. Each verb declares what absence means for it; every other failure throws. git.try.* inspects, raw() bypasses — over an injectable backend that drives the git CLI or any other implementation.",
|
|
5
5
|
"license": "MIT OR Apache-2.0",
|
|
6
6
|
"author": "sksizer",
|