isomorphic-git 1.25.7 → 1.25.8

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,7 @@ 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>
372
373
  </tr>
373
374
  </table>
374
375
 
@@ -1,7 +1,7 @@
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
6
  "Mobile Safari 13.0 (iOS 13.0)",
7
7
  "Safari 13.1 (Mac OS 10.15.4)"
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,17 +4177,22 @@ 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')) || false;
4186
+ const content = await fs.read(`${dir}/${entry._fullpath}`, {
4187
+ encoding: 'utf8',
4188
+ autocrlf,
4189
+ });
4183
4190
  // workaround for a BrowserFS edge case
4184
4191
  entry._actualSize = content.length;
4185
4192
  if (entry._stat && entry._stat.size === -1) {
4186
4193
  entry._stat.size = entry._actualSize;
4187
4194
  }
4188
- entry._content = new Uint8Array(content);
4195
+ entry._content = new TextEncoder().encode(content);
4189
4196
  }
4190
4197
  }
4191
4198
  return entry._content
@@ -4201,7 +4208,10 @@ class GitWalkerFs {
4201
4208
  ) {
4202
4209
  const stage = index.entriesMap.get(entry._fullpath);
4203
4210
  const stats = await entry.stat();
4204
- if (!stage || compareStats(stats, stage)) {
4211
+ const config = await GitConfigManager.get({ fs, gitdir });
4212
+ const filemode = await config.get('core.filemode');
4213
+ const trustino = !(process.platform === 'win32');
4214
+ if (!stage || compareStats(stats, stage, filemode, trustino)) {
4205
4215
  const content = await entry.content();
4206
4216
  if (content === undefined) {
4207
4217
  oid = undefined;
@@ -4215,8 +4225,8 @@ class GitWalkerFs {
4215
4225
  if (
4216
4226
  stage &&
4217
4227
  oid === stage.oid &&
4218
- stats.mode === stage.mode &&
4219
- compareStats(stats, stage)
4228
+ (!filemode || stats.mode === stage.mode) &&
4229
+ compareStats(stats, stage, filemode, trustino)
4220
4230
  ) {
4221
4231
  index.insert({
4222
4232
  filepath: entry._fullpath,
@@ -4553,6 +4563,9 @@ class FileSystem {
4553
4563
  async read(filepath, options = {}) {
4554
4564
  try {
4555
4565
  let buffer = await this._readFile(filepath, options);
4566
+ if (typeof buffer === 'string' && options.autocrlf) {
4567
+ buffer = buffer.replace(/\r\n/g, '\n');
4568
+ }
4556
4569
  // Convert plain ArrayBuffers to Buffers
4557
4570
  if (typeof buffer !== 'string') {
4558
4571
  buffer = Buffer.from(buffer);
@@ -5083,11 +5096,21 @@ async function addToIndex({
5083
5096
  }
5084
5097
  }
5085
5098
  } else {
5099
+ const config = await GitConfigManager.get({ fs, gitdir });
5100
+ const autocrlf = (await config.get('core.autocrlf')) || false;
5086
5101
  const object = stats.isSymbolicLink()
5087
5102
  ? await fs.readlink(join(dir, currentFilepath)).then(posixifyPathBuffer)
5088
- : await fs.read(join(dir, currentFilepath));
5103
+ : await fs.read(join(dir, currentFilepath), {
5104
+ encoding: 'utf8',
5105
+ autocrlf,
5106
+ });
5089
5107
  if (object === null) throw new NotFoundError(currentFilepath)
5090
- const oid = await _writeObject({ fs, gitdir, type: 'blob', object });
5108
+ const oid = await _writeObject({
5109
+ fs,
5110
+ gitdir,
5111
+ type: 'blob',
5112
+ object: new TextEncoder().encode(object),
5113
+ });
5091
5114
  index.insert({ filepath: currentFilepath, stats, oid });
5092
5115
  }
5093
5116
  });
@@ -7362,8 +7385,8 @@ function filterCapabilities(server, client) {
7362
7385
 
7363
7386
  const pkg = {
7364
7387
  name: 'isomorphic-git',
7365
- version: '1.25.7',
7366
- agent: 'git/isomorphic-git@1.25.7',
7388
+ version: '1.25.8',
7389
+ agent: 'git/isomorphic-git@1.25.8',
7367
7390
  };
7368
7391
 
7369
7392
  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,17 +4171,22 @@ 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')) || false;
4180
+ const content = await fs.read(`${dir}/${entry._fullpath}`, {
4181
+ encoding: 'utf8',
4182
+ autocrlf,
4183
+ });
4177
4184
  // workaround for a BrowserFS edge case
4178
4185
  entry._actualSize = content.length;
4179
4186
  if (entry._stat && entry._stat.size === -1) {
4180
4187
  entry._stat.size = entry._actualSize;
4181
4188
  }
4182
- entry._content = new Uint8Array(content);
4189
+ entry._content = new TextEncoder().encode(content);
4183
4190
  }
4184
4191
  }
4185
4192
  return entry._content
@@ -4195,7 +4202,10 @@ class GitWalkerFs {
4195
4202
  ) {
4196
4203
  const stage = index.entriesMap.get(entry._fullpath);
4197
4204
  const stats = await entry.stat();
4198
- if (!stage || compareStats(stats, stage)) {
4205
+ const config = await GitConfigManager.get({ fs, gitdir });
4206
+ const filemode = await config.get('core.filemode');
4207
+ const trustino = !(process.platform === 'win32');
4208
+ if (!stage || compareStats(stats, stage, filemode, trustino)) {
4199
4209
  const content = await entry.content();
4200
4210
  if (content === undefined) {
4201
4211
  oid = undefined;
@@ -4209,8 +4219,8 @@ class GitWalkerFs {
4209
4219
  if (
4210
4220
  stage &&
4211
4221
  oid === stage.oid &&
4212
- stats.mode === stage.mode &&
4213
- compareStats(stats, stage)
4222
+ (!filemode || stats.mode === stage.mode) &&
4223
+ compareStats(stats, stage, filemode, trustino)
4214
4224
  ) {
4215
4225
  index.insert({
4216
4226
  filepath: entry._fullpath,
@@ -4547,6 +4557,9 @@ class FileSystem {
4547
4557
  async read(filepath, options = {}) {
4548
4558
  try {
4549
4559
  let buffer = await this._readFile(filepath, options);
4560
+ if (typeof buffer === 'string' && options.autocrlf) {
4561
+ buffer = buffer.replace(/\r\n/g, '\n');
4562
+ }
4550
4563
  // Convert plain ArrayBuffers to Buffers
4551
4564
  if (typeof buffer !== 'string') {
4552
4565
  buffer = Buffer.from(buffer);
@@ -5077,11 +5090,21 @@ async function addToIndex({
5077
5090
  }
5078
5091
  }
5079
5092
  } else {
5093
+ const config = await GitConfigManager.get({ fs, gitdir });
5094
+ const autocrlf = (await config.get('core.autocrlf')) || false;
5080
5095
  const object = stats.isSymbolicLink()
5081
5096
  ? await fs.readlink(join(dir, currentFilepath)).then(posixifyPathBuffer)
5082
- : await fs.read(join(dir, currentFilepath));
5097
+ : await fs.read(join(dir, currentFilepath), {
5098
+ encoding: 'utf8',
5099
+ autocrlf,
5100
+ });
5083
5101
  if (object === null) throw new NotFoundError(currentFilepath)
5084
- const oid = await _writeObject({ fs, gitdir, type: 'blob', object });
5102
+ const oid = await _writeObject({
5103
+ fs,
5104
+ gitdir,
5105
+ type: 'blob',
5106
+ object: new TextEncoder().encode(object),
5107
+ });
5085
5108
  index.insert({ filepath: currentFilepath, stats, oid });
5086
5109
  }
5087
5110
  });
@@ -7356,8 +7379,8 @@ function filterCapabilities(server, client) {
7356
7379
 
7357
7380
  const pkg = {
7358
7381
  name: 'isomorphic-git',
7359
- version: '1.25.7',
7360
- agent: 'git/isomorphic-git@1.25.7',
7382
+ version: '1.25.8',
7383
+ agent: 'git/isomorphic-git@1.25.8',
7361
7384
  };
7362
7385
 
7363
7386
  class FIFO {