isomorphic-git 1.25.7 → 1.25.9

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 CHANGED
@@ -369,6 +369,8 @@ Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds
369
369
  <td align="center"><a href="https://github.com/scolladon"><img src="https://avatars.githubusercontent.com/u/522422?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Sebastien</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=scolladon" title="Code">💻</a></td>
370
370
  <td align="center"><a href="https://github.com/yarikoptic"><img src="https://avatars.githubusercontent.com/u/39889?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Yaroslav Halchenko</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=yarikoptic" title="Documentation">📖</a></td>
371
371
  <td align="center"><a href="https://alex-v.blog/"><img src="https://avatars.githubusercontent.com/u/716334?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Alex Villarreal</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=alexvy86" title="Code">💻</a></td>
372
+ <td align="center"><a href="https://github.com/amrc-benmorrow"><img src="https://avatars.githubusercontent.com/u/120477944?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Ben Morrow</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=amrc-benmorrow" title="Code">💻</a></td>
373
+ <td align="center"><a href="https://github.com/jayree"><img src="https://avatars.githubusercontent.com/u/14836154?v=4?s=60" width="60px;" alt=""/><br /><sub><b>jayree</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=jayree" title="Code">💻</a> <a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=jayree" title="Tests">⚠️</a></td>
372
374
  </tr>
373
375
  </table>
374
376
 
@@ -1,8 +1,8 @@
1
1
  [
2
2
  "Chrome Headless 79.0.3945.0 (Linux x86_64)",
3
- "Firefox 124.0 (Ubuntu 0.0.0)",
4
- "Chrome 120.0.0.0 (Android 10)",
3
+ "Firefox 125.0 (Ubuntu 0.0.0)",
4
+ "Chrome 123.0.0.0 (Android 10)",
5
5
  "Edge 79.0.309.65 (Windows 10)",
6
- "Mobile Safari 13.0 (iOS 13.0)",
7
- "Safari 13.1 (Mac OS 10.15.4)"
6
+ "Safari 13.1 (Mac OS 10.15.4)",
7
+ "Mobile Safari 13.0 (iOS 13.0)"
8
8
  ]
package/index.cjs CHANGED
@@ -907,18 +907,18 @@ class GitIndex {
907
907
  }
908
908
  }
909
909
 
910
- function compareStats(entry, stats) {
910
+ function compareStats(entry, stats, filemode = true, trustino = true) {
911
911
  // Comparison based on the description in Paragraph 4 of
912
912
  // https://www.kernel.org/pub/software/scm/git/docs/technical/racy-git.txt
913
913
  const e = normalizeStats(entry);
914
914
  const s = normalizeStats(stats);
915
915
  const staleness =
916
- e.mode !== s.mode ||
916
+ (filemode && e.mode !== s.mode) ||
917
917
  e.mtimeSeconds !== s.mtimeSeconds ||
918
918
  e.ctimeSeconds !== s.ctimeSeconds ||
919
919
  e.uid !== s.uid ||
920
920
  e.gid !== s.gid ||
921
- e.ino !== s.ino ||
921
+ (trustino && e.ino !== s.ino) ||
922
922
  e.size !== s.size;
923
923
  return staleness
924
924
  }
@@ -1623,26 +1623,28 @@ class GitConfig {
1623
1623
  constructor(text) {
1624
1624
  let section = null;
1625
1625
  let subsection = null;
1626
- this.parsedConfig = text.split('\n').map(line => {
1627
- let name = null;
1628
- let value = null;
1629
-
1630
- const trimmedLine = line.trim();
1631
- const extractedSection = extractSectionLine(trimmedLine);
1632
- const isSection = extractedSection != null;
1633
- if (isSection) {
1634
- ;[section, subsection] = extractedSection;
1635
- } else {
1636
- const extractedVariable = extractVariableLine(trimmedLine);
1637
- const isVariable = extractedVariable != null;
1638
- if (isVariable) {
1639
- ;[name, value] = extractedVariable;
1640
- }
1641
- }
1626
+ this.parsedConfig = text
1627
+ ? text.split('\n').map(line => {
1628
+ let name = null;
1629
+ let value = null;
1630
+
1631
+ const trimmedLine = line.trim();
1632
+ const extractedSection = extractSectionLine(trimmedLine);
1633
+ const isSection = extractedSection != null;
1634
+ if (isSection) {
1635
+ ;[section, subsection] = extractedSection;
1636
+ } else {
1637
+ const extractedVariable = extractVariableLine(trimmedLine);
1638
+ const isVariable = extractedVariable != null;
1639
+ if (isVariable) {
1640
+ ;[name, value] = extractedVariable;
1641
+ }
1642
+ }
1642
1643
 
1643
- const path = getPath(section, subsection, name);
1644
- return { line, isSection, section, subsection, name, value, path }
1645
- });
1644
+ const path = getPath(section, subsection, name);
1645
+ return { line, isSection, section, subsection, name, value, path }
1646
+ })
1647
+ : [];
1646
1648
  }
1647
1649
 
1648
1650
  static from(text) {
@@ -4175,11 +4177,13 @@ class GitWalkerFs {
4175
4177
 
4176
4178
  async content(entry) {
4177
4179
  if (entry._content === false) {
4178
- const { fs, dir } = this;
4180
+ const { fs, dir, gitdir } = this;
4179
4181
  if ((await entry.type()) === 'tree') {
4180
4182
  entry._content = undefined;
4181
4183
  } else {
4182
- const content = await fs.read(`${dir}/${entry._fullpath}`);
4184
+ const config = await GitConfigManager.get({ fs, gitdir });
4185
+ const autocrlf = await config.get('core.autocrlf');
4186
+ const content = await fs.read(`${dir}/${entry._fullpath}`, { autocrlf });
4183
4187
  // workaround for a BrowserFS edge case
4184
4188
  entry._actualSize = content.length;
4185
4189
  if (entry._stat && entry._stat.size === -1) {
@@ -4201,7 +4205,10 @@ class GitWalkerFs {
4201
4205
  ) {
4202
4206
  const stage = index.entriesMap.get(entry._fullpath);
4203
4207
  const stats = await entry.stat();
4204
- if (!stage || compareStats(stats, stage)) {
4208
+ const config = await GitConfigManager.get({ fs, gitdir });
4209
+ const filemode = await config.get('core.filemode');
4210
+ const trustino = !(process.platform === 'win32');
4211
+ if (!stage || compareStats(stats, stage, filemode, trustino)) {
4205
4212
  const content = await entry.content();
4206
4213
  if (content === undefined) {
4207
4214
  oid = undefined;
@@ -4215,8 +4222,8 @@ class GitWalkerFs {
4215
4222
  if (
4216
4223
  stage &&
4217
4224
  oid === stage.oid &&
4218
- stats.mode === stage.mode &&
4219
- compareStats(stats, stage)
4225
+ (!filemode || stats.mode === stage.mode) &&
4226
+ compareStats(stats, stage, filemode, trustino)
4220
4227
  ) {
4221
4228
  index.insert({
4222
4229
  filepath: entry._fullpath,
@@ -4553,6 +4560,15 @@ class FileSystem {
4553
4560
  async read(filepath, options = {}) {
4554
4561
  try {
4555
4562
  let buffer = await this._readFile(filepath, options);
4563
+ if (options.autocrlf === 'true') {
4564
+ try {
4565
+ buffer = new TextDecoder('utf8', { fatal: true }).decode(buffer);
4566
+ buffer = buffer.replace(/\r\n/g, '\n');
4567
+ buffer = new TextEncoder().encode(buffer);
4568
+ } catch (error) {
4569
+ // non utf8 file
4570
+ }
4571
+ }
4556
4572
  // Convert plain ArrayBuffers to Buffers
4557
4573
  if (typeof buffer !== 'string') {
4558
4574
  buffer = Buffer.from(buffer);
@@ -5083,9 +5099,11 @@ async function addToIndex({
5083
5099
  }
5084
5100
  }
5085
5101
  } else {
5102
+ const config = await GitConfigManager.get({ fs, gitdir });
5103
+ const autocrlf = await config.get('core.autocrlf');
5086
5104
  const object = stats.isSymbolicLink()
5087
5105
  ? await fs.readlink(join(dir, currentFilepath)).then(posixifyPathBuffer)
5088
- : await fs.read(join(dir, currentFilepath));
5106
+ : await fs.read(join(dir, currentFilepath), { autocrlf });
5089
5107
  if (object === null) throw new NotFoundError(currentFilepath)
5090
5108
  const oid = await _writeObject({ fs, gitdir, type: 'blob', object });
5091
5109
  index.insert({ filepath: currentFilepath, stats, oid });
@@ -7362,8 +7380,8 @@ function filterCapabilities(server, client) {
7362
7380
 
7363
7381
  const pkg = {
7364
7382
  name: 'isomorphic-git',
7365
- version: '1.25.7',
7366
- agent: 'git/isomorphic-git@1.25.7',
7383
+ version: '1.25.9',
7384
+ agent: 'git/isomorphic-git@1.25.9',
7367
7385
  };
7368
7386
 
7369
7387
  class FIFO {
package/index.js CHANGED
@@ -901,18 +901,18 @@ class GitIndex {
901
901
  }
902
902
  }
903
903
 
904
- function compareStats(entry, stats) {
904
+ function compareStats(entry, stats, filemode = true, trustino = true) {
905
905
  // Comparison based on the description in Paragraph 4 of
906
906
  // https://www.kernel.org/pub/software/scm/git/docs/technical/racy-git.txt
907
907
  const e = normalizeStats(entry);
908
908
  const s = normalizeStats(stats);
909
909
  const staleness =
910
- e.mode !== s.mode ||
910
+ (filemode && e.mode !== s.mode) ||
911
911
  e.mtimeSeconds !== s.mtimeSeconds ||
912
912
  e.ctimeSeconds !== s.ctimeSeconds ||
913
913
  e.uid !== s.uid ||
914
914
  e.gid !== s.gid ||
915
- e.ino !== s.ino ||
915
+ (trustino && e.ino !== s.ino) ||
916
916
  e.size !== s.size;
917
917
  return staleness
918
918
  }
@@ -1617,26 +1617,28 @@ class GitConfig {
1617
1617
  constructor(text) {
1618
1618
  let section = null;
1619
1619
  let subsection = null;
1620
- this.parsedConfig = text.split('\n').map(line => {
1621
- let name = null;
1622
- let value = null;
1623
-
1624
- const trimmedLine = line.trim();
1625
- const extractedSection = extractSectionLine(trimmedLine);
1626
- const isSection = extractedSection != null;
1627
- if (isSection) {
1628
- ;[section, subsection] = extractedSection;
1629
- } else {
1630
- const extractedVariable = extractVariableLine(trimmedLine);
1631
- const isVariable = extractedVariable != null;
1632
- if (isVariable) {
1633
- ;[name, value] = extractedVariable;
1634
- }
1635
- }
1620
+ this.parsedConfig = text
1621
+ ? text.split('\n').map(line => {
1622
+ let name = null;
1623
+ let value = null;
1624
+
1625
+ const trimmedLine = line.trim();
1626
+ const extractedSection = extractSectionLine(trimmedLine);
1627
+ const isSection = extractedSection != null;
1628
+ if (isSection) {
1629
+ ;[section, subsection] = extractedSection;
1630
+ } else {
1631
+ const extractedVariable = extractVariableLine(trimmedLine);
1632
+ const isVariable = extractedVariable != null;
1633
+ if (isVariable) {
1634
+ ;[name, value] = extractedVariable;
1635
+ }
1636
+ }
1636
1637
 
1637
- const path = getPath(section, subsection, name);
1638
- return { line, isSection, section, subsection, name, value, path }
1639
- });
1638
+ const path = getPath(section, subsection, name);
1639
+ return { line, isSection, section, subsection, name, value, path }
1640
+ })
1641
+ : [];
1640
1642
  }
1641
1643
 
1642
1644
  static from(text) {
@@ -4169,11 +4171,13 @@ class GitWalkerFs {
4169
4171
 
4170
4172
  async content(entry) {
4171
4173
  if (entry._content === false) {
4172
- const { fs, dir } = this;
4174
+ const { fs, dir, gitdir } = this;
4173
4175
  if ((await entry.type()) === 'tree') {
4174
4176
  entry._content = undefined;
4175
4177
  } else {
4176
- const content = await fs.read(`${dir}/${entry._fullpath}`);
4178
+ const config = await GitConfigManager.get({ fs, gitdir });
4179
+ const autocrlf = await config.get('core.autocrlf');
4180
+ const content = await fs.read(`${dir}/${entry._fullpath}`, { autocrlf });
4177
4181
  // workaround for a BrowserFS edge case
4178
4182
  entry._actualSize = content.length;
4179
4183
  if (entry._stat && entry._stat.size === -1) {
@@ -4195,7 +4199,10 @@ class GitWalkerFs {
4195
4199
  ) {
4196
4200
  const stage = index.entriesMap.get(entry._fullpath);
4197
4201
  const stats = await entry.stat();
4198
- if (!stage || compareStats(stats, stage)) {
4202
+ const config = await GitConfigManager.get({ fs, gitdir });
4203
+ const filemode = await config.get('core.filemode');
4204
+ const trustino = !(process.platform === 'win32');
4205
+ if (!stage || compareStats(stats, stage, filemode, trustino)) {
4199
4206
  const content = await entry.content();
4200
4207
  if (content === undefined) {
4201
4208
  oid = undefined;
@@ -4209,8 +4216,8 @@ class GitWalkerFs {
4209
4216
  if (
4210
4217
  stage &&
4211
4218
  oid === stage.oid &&
4212
- stats.mode === stage.mode &&
4213
- compareStats(stats, stage)
4219
+ (!filemode || stats.mode === stage.mode) &&
4220
+ compareStats(stats, stage, filemode, trustino)
4214
4221
  ) {
4215
4222
  index.insert({
4216
4223
  filepath: entry._fullpath,
@@ -4547,6 +4554,15 @@ class FileSystem {
4547
4554
  async read(filepath, options = {}) {
4548
4555
  try {
4549
4556
  let buffer = await this._readFile(filepath, options);
4557
+ if (options.autocrlf === 'true') {
4558
+ try {
4559
+ buffer = new TextDecoder('utf8', { fatal: true }).decode(buffer);
4560
+ buffer = buffer.replace(/\r\n/g, '\n');
4561
+ buffer = new TextEncoder().encode(buffer);
4562
+ } catch (error) {
4563
+ // non utf8 file
4564
+ }
4565
+ }
4550
4566
  // Convert plain ArrayBuffers to Buffers
4551
4567
  if (typeof buffer !== 'string') {
4552
4568
  buffer = Buffer.from(buffer);
@@ -5077,9 +5093,11 @@ async function addToIndex({
5077
5093
  }
5078
5094
  }
5079
5095
  } else {
5096
+ const config = await GitConfigManager.get({ fs, gitdir });
5097
+ const autocrlf = await config.get('core.autocrlf');
5080
5098
  const object = stats.isSymbolicLink()
5081
5099
  ? await fs.readlink(join(dir, currentFilepath)).then(posixifyPathBuffer)
5082
- : await fs.read(join(dir, currentFilepath));
5100
+ : await fs.read(join(dir, currentFilepath), { autocrlf });
5083
5101
  if (object === null) throw new NotFoundError(currentFilepath)
5084
5102
  const oid = await _writeObject({ fs, gitdir, type: 'blob', object });
5085
5103
  index.insert({ filepath: currentFilepath, stats, oid });
@@ -7356,8 +7374,8 @@ function filterCapabilities(server, client) {
7356
7374
 
7357
7375
  const pkg = {
7358
7376
  name: 'isomorphic-git',
7359
- version: '1.25.7',
7360
- agent: 'git/isomorphic-git@1.25.7',
7377
+ version: '1.25.9',
7378
+ agent: 'git/isomorphic-git@1.25.9',
7361
7379
  };
7362
7380
 
7363
7381
  class FIFO {