isomorphic-git 1.42.6 → 1.42.7

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
@@ -456,6 +456,7 @@ Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds
456
456
  <td align="center"><a href="http://toxik.us/"><img src="https://avatars.githubusercontent.com/u/235319?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Alexandru Georoceanu</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=toxik" title="Code">💻</a></td>
457
457
  <td align="center"><a href="https://github.com/arisgk"><img src="https://avatars.githubusercontent.com/u/4354335?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Aris Goudouras</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=arisgk" title="Code">💻</a> <a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=arisgk" title="Documentation">📖</a> <a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=arisgk" title="Tests">⚠️</a> <a href="https://github.com/isomorphic-git/isomorphic-git/issues?q=author%3Aarisgk" title="Bug reports">🐛</a></td>
458
458
  <td align="center"><a href="https://github.com/TonyWu2333"><img src="https://avatars.githubusercontent.com/u/75903587?v=4?s=60" width="60px;" alt=""/><br /><sub><b>TonyWu</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=TonyWu2333" title="Code">💻</a> <a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=TonyWu2333" title="Tests">⚠️</a> <a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=TonyWu2333" title="Documentation">📖</a></td>
459
+ <td align="center"><a href="https://github.com/MadalinTurluianu"><img src="https://avatars.githubusercontent.com/u/81984912?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Madalin Turluianu</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=MadalinTurluianu" title="Code">💻</a> <a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=MadalinTurluianu" title="Tests">⚠️</a></td>
459
460
  </tr>
460
461
  </table>
461
462
 
package/index.cjs CHANGED
@@ -1094,7 +1094,16 @@ async function isIndexStale(fs, filepath, cache) {
1094
1094
 
1095
1095
  const currStats = await fs.lstat(filepath);
1096
1096
  if (currStats === null) return false
1097
- return compareStats(savedStats, currStats)
1097
+ if (compareStats(savedStats, currStats)) return true
1098
+ // compareStats only looks at whole seconds, but the index is often rewritten
1099
+ // in the same second with the same size (an entry got a new oid). Both stats
1100
+ // come from the same fs, so compare the full timestamps too.
1101
+ const saved = normalizeStats(savedStats);
1102
+ const curr = normalizeStats(currStats);
1103
+ return (
1104
+ saved.mtimeNanoseconds !== curr.mtimeNanoseconds ||
1105
+ saved.ctimeNanoseconds !== curr.ctimeNanoseconds
1106
+ )
1098
1107
  }
1099
1108
 
1100
1109
  class GitIndexManager {
@@ -4824,6 +4833,10 @@ class GitWalkerFs {
4824
4833
  this.dir = dir;
4825
4834
  this.gitdir = gitdir;
4826
4835
  this.refresh = refresh;
4836
+ // Index entries whose stat info needs a refresh. `flush` writes them to
4837
+ // the index together when the walk is finished.
4838
+ this.refreshQueue = [];
4839
+ this.flushed = false;
4827
4840
 
4828
4841
  this.config = null;
4829
4842
  const walker = this;
@@ -4968,11 +4981,20 @@ class GitWalkerFs {
4968
4981
  (!filemode || stats.mode === stage.mode) &&
4969
4982
  compareStats(stats, stage, filemode, trustino)
4970
4983
  ) {
4971
- index.insert({
4972
- filepath: entry._fullpath,
4973
- stats,
4974
- oid,
4975
- });
4984
+ if (self.flushed) {
4985
+ // The walk is finished and `flush` already ran, so write
4986
+ // it right away.
4987
+ index.insert({ filepath: entry._fullpath, stats, oid });
4988
+ } else {
4989
+ // Queue the refresh so `flush` can write all of them to the
4990
+ // index in one go when the walk is finished.
4991
+ self.refreshQueue.push({
4992
+ filepath: entry._fullpath,
4993
+ stage,
4994
+ stats,
4995
+ oid,
4996
+ });
4997
+ }
4976
4998
  }
4977
4999
  }
4978
5000
  } else {
@@ -4986,6 +5008,26 @@ class GitWalkerFs {
4986
5008
  return entry._oid
4987
5009
  }
4988
5010
 
5011
+ /**
5012
+ * Write the queued stat refreshes to the index in a single pass.
5013
+ * `_walk` calls this once the walk is finished. The entries it returned
5014
+ * can still be asked for their oid afterwards, so from then on `oid`
5015
+ * writes a refresh right away instead of queueing it.
5016
+ */
5017
+ async flush() {
5018
+ const { fs, gitdir, cache, refreshQueue } = this;
5019
+ this.refreshQueue = [];
5020
+ this.flushed = true;
5021
+ if (refreshQueue.length === 0) return
5022
+ await GitIndexManager.acquire({ fs, gitdir, cache }, async index => {
5023
+ for (const { filepath, stage, stats, oid } of refreshQueue) {
5024
+ // Only refresh entries that are still the ones we looked at.
5025
+ if (index.entriesMap.get(filepath) !== stage) continue
5026
+ index.insert({ filepath, stats, oid });
5027
+ }
5028
+ });
5029
+ }
5030
+
4989
5031
  async _getGitConfig(fs, gitdir) {
4990
5032
  if (this.config) {
4991
5033
  return this.config
@@ -5183,7 +5225,13 @@ async function _walk({
5183
5225
  return reduce(parent, walkedChildren)
5184
5226
  }
5185
5227
  };
5186
- return walk(root)
5228
+ const result = await walk(root);
5229
+ // Let walkers write out what they queued during the walk. WORKDIR queues
5230
+ // its index stat refreshes so the index is written once at the end.
5231
+ for (const walker of walkers) {
5232
+ if (walker.flush) await walker.flush();
5233
+ }
5234
+ return result
5187
5235
  }
5188
5236
 
5189
5237
  /**
@@ -9975,8 +10023,8 @@ function filterCapabilities(server, client) {
9975
10023
 
9976
10024
  const pkg = {
9977
10025
  name: 'isomorphic-git',
9978
- version: '1.42.6',
9979
- agent: 'git/isomorphic-git@1.42.6',
10026
+ version: '1.42.7',
10027
+ agent: 'git/isomorphic-git@1.42.7',
9980
10028
  };
9981
10029
 
9982
10030
  class FIFO {
package/index.js CHANGED
@@ -1087,7 +1087,16 @@ async function isIndexStale(fs, filepath, cache) {
1087
1087
 
1088
1088
  const currStats = await fs.lstat(filepath);
1089
1089
  if (currStats === null) return false
1090
- return compareStats(savedStats, currStats)
1090
+ if (compareStats(savedStats, currStats)) return true
1091
+ // compareStats only looks at whole seconds, but the index is often rewritten
1092
+ // in the same second with the same size (an entry got a new oid). Both stats
1093
+ // come from the same fs, so compare the full timestamps too.
1094
+ const saved = normalizeStats(savedStats);
1095
+ const curr = normalizeStats(currStats);
1096
+ return (
1097
+ saved.mtimeNanoseconds !== curr.mtimeNanoseconds ||
1098
+ saved.ctimeNanoseconds !== curr.ctimeNanoseconds
1099
+ )
1091
1100
  }
1092
1101
 
1093
1102
  class GitIndexManager {
@@ -4811,6 +4820,10 @@ class GitWalkerFs {
4811
4820
  this.dir = dir;
4812
4821
  this.gitdir = gitdir;
4813
4822
  this.refresh = refresh;
4823
+ // Index entries whose stat info needs a refresh. `flush` writes them to
4824
+ // the index together when the walk is finished.
4825
+ this.refreshQueue = [];
4826
+ this.flushed = false;
4814
4827
 
4815
4828
  this.config = null;
4816
4829
  const walker = this;
@@ -4955,11 +4968,20 @@ class GitWalkerFs {
4955
4968
  (!filemode || stats.mode === stage.mode) &&
4956
4969
  compareStats(stats, stage, filemode, trustino)
4957
4970
  ) {
4958
- index.insert({
4959
- filepath: entry._fullpath,
4960
- stats,
4961
- oid,
4962
- });
4971
+ if (self.flushed) {
4972
+ // The walk is finished and `flush` already ran, so write
4973
+ // it right away.
4974
+ index.insert({ filepath: entry._fullpath, stats, oid });
4975
+ } else {
4976
+ // Queue the refresh so `flush` can write all of them to the
4977
+ // index in one go when the walk is finished.
4978
+ self.refreshQueue.push({
4979
+ filepath: entry._fullpath,
4980
+ stage,
4981
+ stats,
4982
+ oid,
4983
+ });
4984
+ }
4963
4985
  }
4964
4986
  }
4965
4987
  } else {
@@ -4973,6 +4995,26 @@ class GitWalkerFs {
4973
4995
  return entry._oid
4974
4996
  }
4975
4997
 
4998
+ /**
4999
+ * Write the queued stat refreshes to the index in a single pass.
5000
+ * `_walk` calls this once the walk is finished. The entries it returned
5001
+ * can still be asked for their oid afterwards, so from then on `oid`
5002
+ * writes a refresh right away instead of queueing it.
5003
+ */
5004
+ async flush() {
5005
+ const { fs, gitdir, cache, refreshQueue } = this;
5006
+ this.refreshQueue = [];
5007
+ this.flushed = true;
5008
+ if (refreshQueue.length === 0) return
5009
+ await GitIndexManager.acquire({ fs, gitdir, cache }, async index => {
5010
+ for (const { filepath, stage, stats, oid } of refreshQueue) {
5011
+ // Only refresh entries that are still the ones we looked at.
5012
+ if (index.entriesMap.get(filepath) !== stage) continue
5013
+ index.insert({ filepath, stats, oid });
5014
+ }
5015
+ });
5016
+ }
5017
+
4976
5018
  async _getGitConfig(fs, gitdir) {
4977
5019
  if (this.config) {
4978
5020
  return this.config
@@ -5170,7 +5212,13 @@ async function _walk({
5170
5212
  return reduce(parent, walkedChildren)
5171
5213
  }
5172
5214
  };
5173
- return walk(root)
5215
+ const result = await walk(root);
5216
+ // Let walkers write out what they queued during the walk. WORKDIR queues
5217
+ // its index stat refreshes so the index is written once at the end.
5218
+ for (const walker of walkers) {
5219
+ if (walker.flush) await walker.flush();
5220
+ }
5221
+ return result
5174
5222
  }
5175
5223
 
5176
5224
  /**
@@ -9962,8 +10010,8 @@ function filterCapabilities(server, client) {
9962
10010
 
9963
10011
  const pkg = {
9964
10012
  name: 'isomorphic-git',
9965
- version: '1.42.6',
9966
- agent: 'git/isomorphic-git@1.42.6',
10013
+ version: '1.42.7',
10014
+ agent: 'git/isomorphic-git@1.42.7',
9967
10015
  };
9968
10016
 
9969
10017
  class FIFO {