isomorphic-git 1.44.8 → 1.44.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.
@@ -1196,7 +1196,8 @@ function SecondsNanoseconds(
1196
1196
  milliseconds = date.valueOf();
1197
1197
  }
1198
1198
  const seconds = Math.floor(milliseconds / 1000);
1199
- const nanoseconds = (milliseconds - seconds * 1000) * 1000000;
1199
+ // Match the integer precision used when these timestamps are written to the index.
1200
+ const nanoseconds = Math.floor((milliseconds - seconds * 1000) * 1000000);
1200
1201
  return [seconds, nanoseconds]
1201
1202
  }
1202
1203
 
@@ -1617,7 +1618,9 @@ function compareStats(entry, stats, filemode = true, trustino = true) {
1617
1618
  const staleness =
1618
1619
  (filemode && e.mode !== s.mode) ||
1619
1620
  e.mtimeSeconds !== s.mtimeSeconds ||
1621
+ e.mtimeNanoseconds !== s.mtimeNanoseconds ||
1620
1622
  e.ctimeSeconds !== s.ctimeSeconds ||
1623
+ e.ctimeNanoseconds !== s.ctimeNanoseconds ||
1621
1624
  e.uid !== s.uid ||
1622
1625
  e.gid !== s.gid ||
1623
1626
  (trustino && e.ino !== s.ino) ||
@@ -3668,12 +3671,16 @@ ${obj.gpgsig ? obj.gpgsig : ''}`
3668
3671
  }
3669
3672
  }
3670
3673
  const obj = {};
3674
+ const seen = new Set();
3671
3675
  for (const h of hs) {
3672
3676
  const key = h.slice(0, h.indexOf(' '));
3673
3677
  const value = h.slice(h.indexOf(' ') + 1);
3674
- if (Array.isArray(obj[key])) {
3675
- obj[key].push(value);
3676
- } else {
3678
+ // A tag header may appear only once, so the first occurrence wins, the
3679
+ // way canonical git reads them. Keeping the last one instead would make a
3680
+ // tag with a duplicate `object` header point at a different target here
3681
+ // than in git, under the same oid.
3682
+ if (!seen.has(key)) {
3683
+ seen.add(key);
3677
3684
  obj[key] = value;
3678
3685
  }
3679
3686
  }
@@ -3804,12 +3811,18 @@ class GitCommit {
3804
3811
  const obj = {
3805
3812
  parent: [],
3806
3813
  };
3814
+ const seen = new Set();
3807
3815
  for (const h of hs) {
3808
3816
  const key = h.slice(0, h.indexOf(' '));
3809
3817
  const value = h.slice(h.indexOf(' ') + 1);
3810
3818
  if (Array.isArray(obj[key])) {
3811
3819
  obj[key].push(value);
3812
- } else {
3820
+ } else if (!seen.has(key)) {
3821
+ // Only `parent` may appear more than once. For every other header the
3822
+ // first occurrence wins, the way canonical git reads them. Keeping the
3823
+ // last one instead would make a commit with a duplicate `tree` header
3824
+ // resolve to a different tree here than in git, under the same oid.
3825
+ seen.add(key);
3813
3826
  obj[key] = value;
3814
3827
  }
3815
3828
  }
package/managers/index.js CHANGED
@@ -1189,7 +1189,8 @@ function SecondsNanoseconds(
1189
1189
  milliseconds = date.valueOf();
1190
1190
  }
1191
1191
  const seconds = Math.floor(milliseconds / 1000);
1192
- const nanoseconds = (milliseconds - seconds * 1000) * 1000000;
1192
+ // Match the integer precision used when these timestamps are written to the index.
1193
+ const nanoseconds = Math.floor((milliseconds - seconds * 1000) * 1000000);
1193
1194
  return [seconds, nanoseconds]
1194
1195
  }
1195
1196
 
@@ -1610,7 +1611,9 @@ function compareStats(entry, stats, filemode = true, trustino = true) {
1610
1611
  const staleness =
1611
1612
  (filemode && e.mode !== s.mode) ||
1612
1613
  e.mtimeSeconds !== s.mtimeSeconds ||
1614
+ e.mtimeNanoseconds !== s.mtimeNanoseconds ||
1613
1615
  e.ctimeSeconds !== s.ctimeSeconds ||
1616
+ e.ctimeNanoseconds !== s.ctimeNanoseconds ||
1614
1617
  e.uid !== s.uid ||
1615
1618
  e.gid !== s.gid ||
1616
1619
  (trustino && e.ino !== s.ino) ||
@@ -3661,12 +3664,16 @@ ${obj.gpgsig ? obj.gpgsig : ''}`
3661
3664
  }
3662
3665
  }
3663
3666
  const obj = {};
3667
+ const seen = new Set();
3664
3668
  for (const h of hs) {
3665
3669
  const key = h.slice(0, h.indexOf(' '));
3666
3670
  const value = h.slice(h.indexOf(' ') + 1);
3667
- if (Array.isArray(obj[key])) {
3668
- obj[key].push(value);
3669
- } else {
3671
+ // A tag header may appear only once, so the first occurrence wins, the
3672
+ // way canonical git reads them. Keeping the last one instead would make a
3673
+ // tag with a duplicate `object` header point at a different target here
3674
+ // than in git, under the same oid.
3675
+ if (!seen.has(key)) {
3676
+ seen.add(key);
3670
3677
  obj[key] = value;
3671
3678
  }
3672
3679
  }
@@ -3797,12 +3804,18 @@ class GitCommit {
3797
3804
  const obj = {
3798
3805
  parent: [],
3799
3806
  };
3807
+ const seen = new Set();
3800
3808
  for (const h of hs) {
3801
3809
  const key = h.slice(0, h.indexOf(' '));
3802
3810
  const value = h.slice(h.indexOf(' ') + 1);
3803
3811
  if (Array.isArray(obj[key])) {
3804
3812
  obj[key].push(value);
3805
- } else {
3813
+ } else if (!seen.has(key)) {
3814
+ // Only `parent` may appear more than once. For every other header the
3815
+ // first occurrence wins, the way canonical git reads them. Keeping the
3816
+ // last one instead would make a commit with a duplicate `tree` header
3817
+ // resolve to a different tree here than in git, under the same oid.
3818
+ seen.add(key);
3806
3819
  obj[key] = value;
3807
3820
  }
3808
3821
  }