isomorphic-git 1.44.8 → 1.44.10

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/index.cjs CHANGED
@@ -622,7 +622,8 @@ function SecondsNanoseconds(
622
622
  milliseconds = date.valueOf();
623
623
  }
624
624
  const seconds = Math.floor(milliseconds / 1000);
625
- const nanoseconds = (milliseconds - seconds * 1000) * 1000000;
625
+ // Match the integer precision used when these timestamps are written to the index.
626
+ const nanoseconds = Math.floor((milliseconds - seconds * 1000) * 1000000);
626
627
  return [seconds, nanoseconds]
627
628
  }
628
629
 
@@ -1043,7 +1044,9 @@ function compareStats(entry, stats, filemode = true, trustino = true) {
1043
1044
  const staleness =
1044
1045
  (filemode && e.mode !== s.mode) ||
1045
1046
  e.mtimeSeconds !== s.mtimeSeconds ||
1047
+ e.mtimeNanoseconds !== s.mtimeNanoseconds ||
1046
1048
  e.ctimeSeconds !== s.ctimeSeconds ||
1049
+ e.ctimeNanoseconds !== s.ctimeNanoseconds ||
1047
1050
  e.uid !== s.uid ||
1048
1051
  e.gid !== s.gid ||
1049
1052
  (trustino && e.ino !== s.ino) ||
@@ -4615,12 +4618,16 @@ ${obj.gpgsig ? obj.gpgsig : ''}`
4615
4618
  }
4616
4619
  }
4617
4620
  const obj = {};
4621
+ const seen = new Set();
4618
4622
  for (const h of hs) {
4619
4623
  const key = h.slice(0, h.indexOf(' '));
4620
4624
  const value = h.slice(h.indexOf(' ') + 1);
4621
- if (Array.isArray(obj[key])) {
4622
- obj[key].push(value);
4623
- } else {
4625
+ // A tag header may appear only once, so the first occurrence wins, the
4626
+ // way canonical git reads them. Keeping the last one instead would make a
4627
+ // tag with a duplicate `object` header point at a different target here
4628
+ // than in git, under the same oid.
4629
+ if (!seen.has(key)) {
4630
+ seen.add(key);
4624
4631
  obj[key] = value;
4625
4632
  }
4626
4633
  }
@@ -4751,14 +4758,34 @@ class GitCommit {
4751
4758
  const obj = {
4752
4759
  parent: [],
4753
4760
  };
4754
- for (const h of hs) {
4755
- const key = h.slice(0, h.indexOf(' '));
4756
- const value = h.slice(h.indexOf(' ') + 1);
4757
- if (Array.isArray(obj[key])) {
4758
- obj[key].push(value);
4759
- } else {
4760
- obj[key] = value;
4761
- }
4761
+ const keyOf = h => h.slice(0, h.indexOf(' '));
4762
+ const valueOf = h => h.slice(h.indexOf(' ') + 1);
4763
+ // Git reads the start of a commit by position: one `tree`, then the
4764
+ // `parent` lines that follow it directly. Anything after that run is an
4765
+ // extra header that git keeps but never interprets, so a `tree` or
4766
+ // `parent` further down must not count here either. Reading them would
4767
+ // give the same oid a different tree, or a different ancestry, than git
4768
+ // and every other implementation reports.
4769
+ if (hs.length === 0 || keyOf(hs[0]) !== 'tree') {
4770
+ throw new ParseError(
4771
+ 'tree as the first commit header',
4772
+ keyOf(hs[0] || '')
4773
+ )
4774
+ }
4775
+ obj.tree = valueOf(hs[0]);
4776
+ let index = 1;
4777
+ while (index < hs.length && keyOf(hs[index]) === 'parent') {
4778
+ obj.parent.push(valueOf(hs[index]));
4779
+ index++;
4780
+ }
4781
+ const seen = new Set(['tree', 'parent']);
4782
+ for (; index < hs.length; index++) {
4783
+ const key = keyOf(hs[index]);
4784
+ // The first occurrence of a single-valued header wins, the way canonical
4785
+ // git reads them.
4786
+ if (seen.has(key)) continue
4787
+ seen.add(key);
4788
+ obj[key] = valueOf(hs[index]);
4762
4789
  }
4763
4790
  if (obj.author) {
4764
4791
  obj.author = parseAuthor(obj.author);
@@ -10267,8 +10294,8 @@ function filterCapabilities(server, client) {
10267
10294
 
10268
10295
  const pkg = {
10269
10296
  name: 'isomorphic-git',
10270
- version: '1.44.8',
10271
- agent: 'git/isomorphic-git@1.44.8',
10297
+ version: '1.44.10',
10298
+ agent: 'git/isomorphic-git@1.44.10',
10272
10299
  };
10273
10300
 
10274
10301
  class FIFO {
package/index.js CHANGED
@@ -615,7 +615,8 @@ function SecondsNanoseconds(
615
615
  milliseconds = date.valueOf();
616
616
  }
617
617
  const seconds = Math.floor(milliseconds / 1000);
618
- const nanoseconds = (milliseconds - seconds * 1000) * 1000000;
618
+ // Match the integer precision used when these timestamps are written to the index.
619
+ const nanoseconds = Math.floor((milliseconds - seconds * 1000) * 1000000);
619
620
  return [seconds, nanoseconds]
620
621
  }
621
622
 
@@ -1036,7 +1037,9 @@ function compareStats(entry, stats, filemode = true, trustino = true) {
1036
1037
  const staleness =
1037
1038
  (filemode && e.mode !== s.mode) ||
1038
1039
  e.mtimeSeconds !== s.mtimeSeconds ||
1040
+ e.mtimeNanoseconds !== s.mtimeNanoseconds ||
1039
1041
  e.ctimeSeconds !== s.ctimeSeconds ||
1042
+ e.ctimeNanoseconds !== s.ctimeNanoseconds ||
1040
1043
  e.uid !== s.uid ||
1041
1044
  e.gid !== s.gid ||
1042
1045
  (trustino && e.ino !== s.ino) ||
@@ -4602,12 +4605,16 @@ ${obj.gpgsig ? obj.gpgsig : ''}`
4602
4605
  }
4603
4606
  }
4604
4607
  const obj = {};
4608
+ const seen = new Set();
4605
4609
  for (const h of hs) {
4606
4610
  const key = h.slice(0, h.indexOf(' '));
4607
4611
  const value = h.slice(h.indexOf(' ') + 1);
4608
- if (Array.isArray(obj[key])) {
4609
- obj[key].push(value);
4610
- } else {
4612
+ // A tag header may appear only once, so the first occurrence wins, the
4613
+ // way canonical git reads them. Keeping the last one instead would make a
4614
+ // tag with a duplicate `object` header point at a different target here
4615
+ // than in git, under the same oid.
4616
+ if (!seen.has(key)) {
4617
+ seen.add(key);
4611
4618
  obj[key] = value;
4612
4619
  }
4613
4620
  }
@@ -4738,14 +4745,34 @@ class GitCommit {
4738
4745
  const obj = {
4739
4746
  parent: [],
4740
4747
  };
4741
- for (const h of hs) {
4742
- const key = h.slice(0, h.indexOf(' '));
4743
- const value = h.slice(h.indexOf(' ') + 1);
4744
- if (Array.isArray(obj[key])) {
4745
- obj[key].push(value);
4746
- } else {
4747
- obj[key] = value;
4748
- }
4748
+ const keyOf = h => h.slice(0, h.indexOf(' '));
4749
+ const valueOf = h => h.slice(h.indexOf(' ') + 1);
4750
+ // Git reads the start of a commit by position: one `tree`, then the
4751
+ // `parent` lines that follow it directly. Anything after that run is an
4752
+ // extra header that git keeps but never interprets, so a `tree` or
4753
+ // `parent` further down must not count here either. Reading them would
4754
+ // give the same oid a different tree, or a different ancestry, than git
4755
+ // and every other implementation reports.
4756
+ if (hs.length === 0 || keyOf(hs[0]) !== 'tree') {
4757
+ throw new ParseError(
4758
+ 'tree as the first commit header',
4759
+ keyOf(hs[0] || '')
4760
+ )
4761
+ }
4762
+ obj.tree = valueOf(hs[0]);
4763
+ let index = 1;
4764
+ while (index < hs.length && keyOf(hs[index]) === 'parent') {
4765
+ obj.parent.push(valueOf(hs[index]));
4766
+ index++;
4767
+ }
4768
+ const seen = new Set(['tree', 'parent']);
4769
+ for (; index < hs.length; index++) {
4770
+ const key = keyOf(hs[index]);
4771
+ // The first occurrence of a single-valued header wins, the way canonical
4772
+ // git reads them.
4773
+ if (seen.has(key)) continue
4774
+ seen.add(key);
4775
+ obj[key] = valueOf(hs[index]);
4749
4776
  }
4750
4777
  if (obj.author) {
4751
4778
  obj.author = parseAuthor(obj.author);
@@ -10254,8 +10281,8 @@ function filterCapabilities(server, client) {
10254
10281
 
10255
10282
  const pkg = {
10256
10283
  name: 'isomorphic-git',
10257
- version: '1.44.8',
10258
- agent: 'git/isomorphic-git@1.44.8',
10284
+ version: '1.44.10',
10285
+ agent: 'git/isomorphic-git@1.44.10',
10259
10286
  };
10260
10287
 
10261
10288
  class FIFO {