@osdlc/typed-git 0.21.0 → 0.22.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 +6 -0
- package/README.md +41 -13
- package/dist/verbs.d.ts +46 -16
- package/dist/verbs.js +53 -14
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @osdlc/typed-git
|
|
2
2
|
|
|
3
|
+
## 0.22.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- ebdb5ad: `diffText` and `diffAddedFile` pass `--inter-hunk-context=0` and remove `GIT_DIFF_OPTS` from git's environment, so `diff.interHunkContext` and a `-u<n>` in `GIT_DIFF_OPTS` no longer change the lines of context: `diffText(rev, { context: 0 })` gives the changed lines alone. `GitVerb.env` values may be `undefined`, which removes the variable from the child's environment, as command-seam's `env` does. The docs now list every git setting that still changes the patch text (`diff.algorithm`, `diff.indentHeuristic`, `diff.renames` without `findRenames`, `diff.renameLimit`, `diff.ignoreSubmodules`, `core.quotePath`, `diff.orderFile`, `diff.suppressBlankEmpty`, `core.abbrev`, a funcname driver and binary attributes), say that `findRenames` also overrides `diff.renames=copies`, and say that `context` does not change `diffAddedFile`'s text. A bad `context`, `depth` or `jobs` of `NaN` or `Infinity` now names that value in the `TypeError`, not `null`.
|
|
8
|
+
|
|
3
9
|
## 0.21.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -320,17 +320,45 @@ prints `-` there and a fabricated `0` would be worse than nothing.
|
|
|
320
320
|
`diffText` and `diffAddedFile` return a plain unified diff with `a/` and `b/`
|
|
321
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
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
`
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
323
|
+
`--no-relative`, `--submodule=short`, `--inter-hunk-context=0` and
|
|
324
|
+
`--unified=3`, and both remove `GIT_DIFF_OPTS` from git's environment.
|
|
325
|
+
`context: n` changes the last flag to `--unified=<n>`, so `diffText` with
|
|
326
|
+
`context: 0` gives the changed lines alone. `diffAddedFile` takes `context` too,
|
|
327
|
+
so a caller can pass the same options to both verbs, but it changes nothing
|
|
328
|
+
there: a diff from `/dev/null` is one all-added hunk with no context lines.
|
|
329
|
+
`diffText` also takes `findRenames: true` (`-M`), which reads a moved file as
|
|
330
|
+
one rename patch whatever `diff.renames` says. It also turns
|
|
331
|
+
`diff.renames=copies` off, so a new file that copies a changed one is a plain
|
|
332
|
+
add, not a `copy from`/`copy to` patch.
|
|
333
|
+
|
|
334
|
+
So `color.ui`, `color.diff`, `diff.external`, a `diff.<driver>.command` or
|
|
335
|
+
textconv driver, `diff.noprefix`, `diff.mnemonicPrefix`, `diff.srcPrefix`,
|
|
336
|
+
`diff.dstPrefix`, `diff.relative`, `diff.submodule`, `diff.context`,
|
|
337
|
+
`diff.interHunkContext` and `GIT_DIFF_OPTS` do not change the text, and none
|
|
338
|
+
of them stops `git apply` taking it.
|
|
339
|
+
|
|
340
|
+
Other settings still change the text:
|
|
341
|
+
|
|
342
|
+
- rename detection: `diff.renames`, unless `findRenames` is set, and
|
|
343
|
+
`diff.renameLimit`, past which git stops looking for renames and only warns
|
|
344
|
+
on stderr;
|
|
345
|
+
- `diff.algorithm`, which changes which lines read as changed, and so the line
|
|
346
|
+
counts, not just the layout;
|
|
347
|
+
- `diff.indentHeuristic`, which moves where a hunk starts;
|
|
348
|
+
- `diff.ignoreSubmodules` and `submodule.<name>.ignore`, which can hide a
|
|
349
|
+
submodule change;
|
|
350
|
+
- `core.quotePath`: with `false`, a non-ASCII path is printed raw, not
|
|
351
|
+
C-quoted;
|
|
352
|
+
- `diff.orderFile`, which changes the order of the files;
|
|
353
|
+
- `diff.suppressBlankEmpty`, under which a blank context line loses its
|
|
354
|
+
leading space;
|
|
355
|
+
- `core.abbrev`, which changes the length of the hashes on the `index` line;
|
|
356
|
+
- a `diff.<driver>.xfuncname`, which changes the function name after `@@`;
|
|
357
|
+
- a `-diff` or `binary` attribute, which prints `Binary files … differ` in
|
|
358
|
+
place of a patch (`binary: true` writes a binary patch instead);
|
|
359
|
+
- clean filters and end-of-line conversion (`core.autocrlf`, and the `text`,
|
|
360
|
+
`eol` and `filter` attributes), which change the working-tree content git
|
|
361
|
+
compares.
|
|
334
362
|
|
|
335
363
|
`diffNameStatus` passes `--no-relative`, so its paths are relative to the
|
|
336
364
|
repository root and cover the whole repository when the cwd is below the
|
|
@@ -766,8 +794,8 @@ exit throws the classified failure.
|
|
|
766
794
|
| `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 |
|
|
767
795
|
| `diffStat({ rangeArgs, paths })` | `diff --stat` | none — raw stdout |
|
|
768
796
|
| `diffCheck({ paths })` | `diff --check` | `1`, `2` → `{ ok: false, output }` |
|
|
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
|
|
797
|
+
| `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 --inter-hunk-context=0 --unified=<context, default 3> [--cached] [--binary] [-M] [rev] [--] [paths]`, without `GIT_DIFF_OPTS` | 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 |
|
|
798
|
+
| `diffAddedFile(relPath, { context })` | `diff --no-color --no-ext-diff --no-textconv --src-prefix=a/ --dst-prefix=b/ --no-relative --submodule=short --inter-hunk-context=0 --unified=<context, default 3> --no-index -- /dev/null <path>`, without `GIT_DIFF_OPTS` | none — exit 1 with output is success; exit 1 with no output, or exit 2, throws; the text is plain, as for `diffText`; `context` is checked but changes nothing |
|
|
771
799
|
| `log(opts)` | `log` | none — raw stdout, unsplit |
|
|
772
800
|
| `logLines(opts)` | `log`, split and filtered | none |
|
|
773
801
|
| `lsTree(rev, { recursive, long, paths })` | `ls-tree -z` | none |
|
package/dist/verbs.d.ts
CHANGED
|
@@ -25,9 +25,11 @@ export interface GitVerb<T> {
|
|
|
25
25
|
/**
|
|
26
26
|
* Environment entries the verb needs, set over the client's and the call's
|
|
27
27
|
* `env`. The integration verbs set `LC_ALL=C` here so their parsers read
|
|
28
|
-
* English git output.
|
|
28
|
+
* English git output. An `undefined` value removes the variable from the
|
|
29
|
+
* child's environment (see `CommandRunOptions.env` in @osdlc/command-seam):
|
|
30
|
+
* `diffText` and `diffAddedFile` remove `GIT_DIFF_OPTS` this way.
|
|
29
31
|
*/
|
|
30
|
-
env?: Readonly<Record<string, string>> | undefined;
|
|
32
|
+
env?: Readonly<Record<string, string | undefined>> | undefined;
|
|
31
33
|
/**
|
|
32
34
|
* Exit codes that mean "asked and answered: not there" for this verb — not
|
|
33
35
|
* "git failed". `config --get` exits 1 for an unset key, `cat-file -e` exits
|
|
@@ -763,15 +765,20 @@ export interface DiffTextOptions {
|
|
|
763
765
|
binary?: boolean | undefined;
|
|
764
766
|
/**
|
|
765
767
|
* `--unified=<n>`: lines of context around each change. Default 3, whatever
|
|
766
|
-
* `diff.context` says; 0 gives a patch of the changed
|
|
767
|
-
*
|
|
768
|
+
* `diff.context` or `GIT_DIFF_OPTS` says; 0 gives a patch of the changed
|
|
769
|
+
* lines alone (`--inter-hunk-context=0` keeps `diff.interHunkContext` from
|
|
770
|
+
* merging nearby hunks with the lines between them). A non-negative
|
|
771
|
+
* integer, else the verb throws a `TypeError`.
|
|
768
772
|
*/
|
|
769
773
|
context?: number | undefined;
|
|
770
774
|
/**
|
|
771
775
|
* `-M`: detect renames, whatever `diff.renames` says, so a moved file reads
|
|
772
776
|
* as one `rename from`/`rename to` patch and not as a delete plus an add.
|
|
773
|
-
*
|
|
774
|
-
*
|
|
777
|
+
* It also overrides `diff.renames=copies`, under which a new file that
|
|
778
|
+
* copies a changed one reads as `copy from`/`copy to`: with `-M` it is a
|
|
779
|
+
* plain add. Off by default: without it `diff.renames` applies (git's own
|
|
780
|
+
* default is on). `diff.renameLimit` still applies: past it git stops
|
|
781
|
+
* looking for renames and only warns on stderr.
|
|
775
782
|
*/
|
|
776
783
|
findRenames?: boolean | undefined;
|
|
777
784
|
/** Pathspecs, passed after `--`. */
|
|
@@ -779,13 +786,19 @@ export interface DiffTextOptions {
|
|
|
779
786
|
}
|
|
780
787
|
/** Options for {@link diffAddedFile}. */
|
|
781
788
|
export interface DiffAddedFileOptions {
|
|
782
|
-
/**
|
|
789
|
+
/**
|
|
790
|
+
* `--unified=<n>`, checked as {@link DiffTextOptions.context}. It does not
|
|
791
|
+
* change the text: a diff from `/dev/null` is one all-added hunk with no
|
|
792
|
+
* context lines, whatever the number. It is accepted so a caller can pass
|
|
793
|
+
* the same options to both verbs.
|
|
794
|
+
*/
|
|
783
795
|
context?: number | undefined;
|
|
784
796
|
}
|
|
785
797
|
/**
|
|
786
798
|
* The unified diff text (`git diff --no-color --no-ext-diff --no-textconv
|
|
787
799
|
* --src-prefix=a/ --dst-prefix=b/ --no-relative --submodule=short
|
|
788
|
-
* --unified=<context> [--cached] [--binary] [-M] [rev]
|
|
800
|
+
* --inter-hunk-context=0 --unified=<context> [--cached] [--binary] [-M] [rev]
|
|
801
|
+
* [--] [paths]`, with `GIT_DIFF_OPTS` removed from git's environment), for the same rev
|
|
789
802
|
* and staged shape {@link diffNameStatus} lists paths for. `--` is passed
|
|
790
803
|
* once, when there is a rev or a path. Empty when nothing differs.
|
|
791
804
|
* {@link diffNameOnly} selects the same paths except under `diff.relative`,
|
|
@@ -798,18 +811,33 @@ export interface DiffAddedFileOptions {
|
|
|
798
811
|
* `diff.dstPrefix`) and `diff.relative`, which with a cwd below the
|
|
799
812
|
* repository root would drop changes outside it. They also keep a submodule
|
|
800
813
|
* change as a `Subproject commit` patch, whatever `diff.submodule` says, and
|
|
801
|
-
* the context at `context` lines (default three), whatever `diff.context
|
|
802
|
-
*
|
|
803
|
-
*
|
|
804
|
-
*
|
|
805
|
-
* lines
|
|
814
|
+
* the context at `context` lines (default three), whatever `diff.context`,
|
|
815
|
+
* `diff.interHunkContext` or the `GIT_DIFF_OPTS` environment variable says.
|
|
816
|
+
*
|
|
817
|
+
* Other settings still change the text, so a caller that compares or counts
|
|
818
|
+
* lines across machines should know them: rename detection (`diff.renames`,
|
|
819
|
+
* unless `findRenames` pins it on, and `diff.renameLimit`), `diff.algorithm`
|
|
820
|
+
* (which lines read as changed, so the line counts too),
|
|
821
|
+
* `diff.indentHeuristic` (where a hunk starts), `diff.ignoreSubmodules` and
|
|
822
|
+
* `submodule.<name>.ignore` (whether a submodule change is shown at all),
|
|
823
|
+
* `core.quotePath` (whether a non-ASCII path is C-quoted), `diff.orderFile`
|
|
824
|
+
* (the order of the files), `diff.suppressBlankEmpty` (a blank context line
|
|
825
|
+
* loses its leading space), `core.abbrev` (the length of the `index` line's
|
|
826
|
+
* hashes), a `diff.<driver>.xfuncname` (the function name after `@@`), and a
|
|
827
|
+
* `-diff` or `binary` attribute (`Binary files … differ` in place of a
|
|
828
|
+
* patch, unless `binary` is set). Clean filters and end-of-line conversion
|
|
829
|
+
* (`core.autocrlf`, `text`, `eol` and `filter` attributes) change the
|
|
830
|
+
* working-tree content git compares.
|
|
831
|
+
*
|
|
832
|
+
* The rev is followed by `--`, so git never reads it as a
|
|
806
833
|
* path: a rev that names a file but no revision throws, and a branch that
|
|
807
834
|
* shares its name with a file works.
|
|
808
835
|
*
|
|
809
836
|
* The text is decoded as UTF-8. A text file whose lines are not valid UTF-8
|
|
810
837
|
* comes back with U+FFFD in them, and the patch no longer applies. For a
|
|
811
838
|
* patch that must replay byte for byte, run the same argv through
|
|
812
|
-
* `rawBytesChecked
|
|
839
|
+
* `rawBytesChecked`, with `env: { GIT_DIFF_OPTS: '' }` (git ignores an empty
|
|
840
|
+
* value) so the context stays as asked.
|
|
813
841
|
*
|
|
814
842
|
* `absent: []`. A rev that does not resolve exits 128, and outside a
|
|
815
843
|
* repository `git diff` exits 129. Both throw, so "git failed" never reads as
|
|
@@ -819,10 +847,12 @@ export declare function diffText(rev?: string | undefined, opts?: DiffTextOption
|
|
|
819
847
|
/**
|
|
820
848
|
* One untracked file rendered as an all-added diff (`diff --no-color
|
|
821
849
|
* --no-ext-diff --no-textconv --src-prefix=a/ --dst-prefix=b/ --no-relative
|
|
822
|
-
* --submodule=short --unified=<context> --no-index --
|
|
850
|
+
* --submodule=short --inter-hunk-context=0 --unified=<context> --no-index --
|
|
851
|
+
* /dev/null <path>`, with `GIT_DIFF_OPTS` removed from git's environment), so a new
|
|
823
852
|
* file reaches a consumer in the same shape as a modified one: the flags are
|
|
824
853
|
* the ones {@link diffText} passes, and the text is as plain. An empty
|
|
825
|
-
* existing file still gives a diff header.
|
|
854
|
+
* existing file still gives a diff header. `context` is checked but does not
|
|
855
|
+
* change the text (see {@link DiffAddedFileOptions.context}).
|
|
826
856
|
*
|
|
827
857
|
* `--no-index` exits 1 whenever the inputs differ, which for a real file is
|
|
828
858
|
* always, so exit 1 is the success case. git also exits 1, with empty stdout,
|
package/dist/verbs.js
CHANGED
|
@@ -210,7 +210,7 @@ function configKey(verb, key) {
|
|
|
210
210
|
*/
|
|
211
211
|
function depthArg(verb, depth) {
|
|
212
212
|
if (!Number.isSafeInteger(depth) || depth < 1) {
|
|
213
|
-
throw new TypeError(`typed-git: ${verb}: depth must be a positive integer (got ${
|
|
213
|
+
throw new TypeError(`typed-git: ${verb}: depth must be a positive integer (got ${shown(depth)})`);
|
|
214
214
|
}
|
|
215
215
|
return `--depth=${depth}`;
|
|
216
216
|
}
|
|
@@ -233,7 +233,9 @@ 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, and no context lines between hunks
|
|
237
|
+
* (`diff.interHunkContext`), so nearby hunks are not merged. The context is
|
|
238
|
+
* {@link unifiedArg}'s.
|
|
237
239
|
*/
|
|
238
240
|
const PLAIN_PATCH = [
|
|
239
241
|
'--no-color',
|
|
@@ -243,7 +245,17 @@ const PLAIN_PATCH = [
|
|
|
243
245
|
'--dst-prefix=b/',
|
|
244
246
|
'--no-relative',
|
|
245
247
|
'--submodule=short',
|
|
248
|
+
'--inter-hunk-context=0',
|
|
246
249
|
];
|
|
250
|
+
/**
|
|
251
|
+
* The child env of the patch verbs: `GIT_DIFF_OPTS` removed, because git
|
|
252
|
+
* reads a `-u<n>` or `--unified=<n>` there over the `--unified` flag. The
|
|
253
|
+
* `undefined` value removes it (see `CommandRunOptions.env` in
|
|
254
|
+
* @osdlc/command-seam).
|
|
255
|
+
*/
|
|
256
|
+
const PLAIN_PATCH_ENV = Object.freeze({
|
|
257
|
+
GIT_DIFF_OPTS: undefined,
|
|
258
|
+
});
|
|
247
259
|
/** The lines of context {@link diffText} and {@link diffAddedFile} print by default. */
|
|
248
260
|
const DEFAULT_CONTEXT = 3;
|
|
249
261
|
/**
|
|
@@ -254,10 +266,18 @@ const DEFAULT_CONTEXT = 3;
|
|
|
254
266
|
function unifiedArg(verb, context) {
|
|
255
267
|
const n = context ?? DEFAULT_CONTEXT;
|
|
256
268
|
if (!Number.isSafeInteger(n) || n < 0) {
|
|
257
|
-
throw new TypeError(`typed-git: ${verb}: context must be a non-negative integer (got ${
|
|
269
|
+
throw new TypeError(`typed-git: ${verb}: context must be a non-negative integer (got ${shown(n)})`);
|
|
258
270
|
}
|
|
259
271
|
return `--unified=${n}`;
|
|
260
272
|
}
|
|
273
|
+
/**
|
|
274
|
+
* A bad option value for an error message: a number as `String` prints it, so
|
|
275
|
+
* `NaN` and `Infinity` read as themselves (`JSON.stringify` prints `null`), and
|
|
276
|
+
* anything else as JSON, so a string keeps its quotes.
|
|
277
|
+
*/
|
|
278
|
+
function shown(value) {
|
|
279
|
+
return typeof value === 'number' ? String(value) : JSON.stringify(value);
|
|
280
|
+
}
|
|
261
281
|
/** The child env that makes git print English, whatever the caller's locale. */
|
|
262
282
|
const C_LOCALE = Object.freeze({ LC_ALL: 'C' });
|
|
263
283
|
// ── queries ─────────────────────────────────────────────────────────────────
|
|
@@ -1043,7 +1063,8 @@ export function lsTree(rev, opts = {}) {
|
|
|
1043
1063
|
/**
|
|
1044
1064
|
* The unified diff text (`git diff --no-color --no-ext-diff --no-textconv
|
|
1045
1065
|
* --src-prefix=a/ --dst-prefix=b/ --no-relative --submodule=short
|
|
1046
|
-
* --unified=<context> [--cached] [--binary] [-M] [rev]
|
|
1066
|
+
* --inter-hunk-context=0 --unified=<context> [--cached] [--binary] [-M] [rev]
|
|
1067
|
+
* [--] [paths]`, with `GIT_DIFF_OPTS` removed from git's environment), for the same rev
|
|
1047
1068
|
* and staged shape {@link diffNameStatus} lists paths for. `--` is passed
|
|
1048
1069
|
* once, when there is a rev or a path. Empty when nothing differs.
|
|
1049
1070
|
* {@link diffNameOnly} selects the same paths except under `diff.relative`,
|
|
@@ -1056,18 +1077,33 @@ export function lsTree(rev, opts = {}) {
|
|
|
1056
1077
|
* `diff.dstPrefix`) and `diff.relative`, which with a cwd below the
|
|
1057
1078
|
* repository root would drop changes outside it. They also keep a submodule
|
|
1058
1079
|
* change as a `Subproject commit` patch, whatever `diff.submodule` says, and
|
|
1059
|
-
* the context at `context` lines (default three), whatever `diff.context
|
|
1060
|
-
*
|
|
1061
|
-
*
|
|
1062
|
-
*
|
|
1063
|
-
* lines
|
|
1080
|
+
* the context at `context` lines (default three), whatever `diff.context`,
|
|
1081
|
+
* `diff.interHunkContext` or the `GIT_DIFF_OPTS` environment variable says.
|
|
1082
|
+
*
|
|
1083
|
+
* Other settings still change the text, so a caller that compares or counts
|
|
1084
|
+
* lines across machines should know them: rename detection (`diff.renames`,
|
|
1085
|
+
* unless `findRenames` pins it on, and `diff.renameLimit`), `diff.algorithm`
|
|
1086
|
+
* (which lines read as changed, so the line counts too),
|
|
1087
|
+
* `diff.indentHeuristic` (where a hunk starts), `diff.ignoreSubmodules` and
|
|
1088
|
+
* `submodule.<name>.ignore` (whether a submodule change is shown at all),
|
|
1089
|
+
* `core.quotePath` (whether a non-ASCII path is C-quoted), `diff.orderFile`
|
|
1090
|
+
* (the order of the files), `diff.suppressBlankEmpty` (a blank context line
|
|
1091
|
+
* loses its leading space), `core.abbrev` (the length of the `index` line's
|
|
1092
|
+
* hashes), a `diff.<driver>.xfuncname` (the function name after `@@`), and a
|
|
1093
|
+
* `-diff` or `binary` attribute (`Binary files … differ` in place of a
|
|
1094
|
+
* patch, unless `binary` is set). Clean filters and end-of-line conversion
|
|
1095
|
+
* (`core.autocrlf`, `text`, `eol` and `filter` attributes) change the
|
|
1096
|
+
* working-tree content git compares.
|
|
1097
|
+
*
|
|
1098
|
+
* The rev is followed by `--`, so git never reads it as a
|
|
1064
1099
|
* path: a rev that names a file but no revision throws, and a branch that
|
|
1065
1100
|
* shares its name with a file works.
|
|
1066
1101
|
*
|
|
1067
1102
|
* The text is decoded as UTF-8. A text file whose lines are not valid UTF-8
|
|
1068
1103
|
* comes back with U+FFFD in them, and the patch no longer applies. For a
|
|
1069
1104
|
* patch that must replay byte for byte, run the same argv through
|
|
1070
|
-
* `rawBytesChecked
|
|
1105
|
+
* `rawBytesChecked`, with `env: { GIT_DIFF_OPTS: '' }` (git ignores an empty
|
|
1106
|
+
* value) so the context stays as asked.
|
|
1071
1107
|
*
|
|
1072
1108
|
* `absent: []`. A rev that does not resolve exits 128, and outside a
|
|
1073
1109
|
* repository `git diff` exits 129. Both throw, so "git failed" never reads as
|
|
@@ -1082,15 +1118,17 @@ export function diffText(rev, opts = {}) {
|
|
|
1082
1118
|
if (opts.findRenames === true)
|
|
1083
1119
|
argv.push('-M');
|
|
1084
1120
|
pushRevAndPaths(argv, optionalPositional('diffText', 'rev', rev), opts.paths);
|
|
1085
|
-
return { argv, absent: NONE, parse: (r) => r.stdout };
|
|
1121
|
+
return { argv, env: PLAIN_PATCH_ENV, absent: NONE, parse: (r) => r.stdout };
|
|
1086
1122
|
}
|
|
1087
1123
|
/**
|
|
1088
1124
|
* One untracked file rendered as an all-added diff (`diff --no-color
|
|
1089
1125
|
* --no-ext-diff --no-textconv --src-prefix=a/ --dst-prefix=b/ --no-relative
|
|
1090
|
-
* --submodule=short --unified=<context> --no-index --
|
|
1126
|
+
* --submodule=short --inter-hunk-context=0 --unified=<context> --no-index --
|
|
1127
|
+
* /dev/null <path>`, with `GIT_DIFF_OPTS` removed from git's environment), so a new
|
|
1091
1128
|
* file reaches a consumer in the same shape as a modified one: the flags are
|
|
1092
1129
|
* the ones {@link diffText} passes, and the text is as plain. An empty
|
|
1093
|
-
* existing file still gives a diff header.
|
|
1130
|
+
* existing file still gives a diff header. `context` is checked but does not
|
|
1131
|
+
* change the text (see {@link DiffAddedFileOptions.context}).
|
|
1094
1132
|
*
|
|
1095
1133
|
* `--no-index` exits 1 whenever the inputs differ, which for a real file is
|
|
1096
1134
|
* always, so exit 1 is the success case. git also exits 1, with empty stdout,
|
|
@@ -1108,6 +1146,7 @@ export function diffAddedFile(relPath, opts = {}) {
|
|
|
1108
1146
|
'/dev/null',
|
|
1109
1147
|
relPath,
|
|
1110
1148
|
],
|
|
1149
|
+
env: PLAIN_PATCH_ENV,
|
|
1111
1150
|
absent: [1],
|
|
1112
1151
|
parse(r, ranArgv) {
|
|
1113
1152
|
if (r.exitCode !== 0 && r.stdout === '')
|
|
@@ -1605,7 +1644,7 @@ export function fetchMany(remotes, opts = {}) {
|
|
|
1605
1644
|
argv.push('--no-tags');
|
|
1606
1645
|
if (opts.jobs !== undefined) {
|
|
1607
1646
|
if (!Number.isSafeInteger(opts.jobs) || opts.jobs < 1) {
|
|
1608
|
-
throw new TypeError(`typed-git: fetchMany: jobs must be a positive integer (got ${
|
|
1647
|
+
throw new TypeError(`typed-git: fetchMany: jobs must be a positive integer (got ${shown(opts.jobs)})`);
|
|
1609
1648
|
}
|
|
1610
1649
|
argv.push(`--jobs=${opts.jobs}`);
|
|
1611
1650
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@osdlc/typed-git",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.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",
|