isomorphic-git 1.44.15 → 1.44.16

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/LICENSE.md CHANGED
@@ -5,3 +5,55 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
5
5
  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
6
 
7
7
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8
+
9
+ ## Third-party code
10
+
11
+ ### path-browserify
12
+
13
+ `src/utils/join.js` contains the POSIX path normalisation from
14
+ [path-browserify](https://github.com/browserify/path-browserify), which
15
+ extracted it from Node.js.
16
+
17
+ MIT License
18
+
19
+ Copyright (c) 2013 James Halliday
20
+
21
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
22
+ this software and associated documentation files (the "Software"), to deal in
23
+ the Software without restriction, including without limitation the rights to
24
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
25
+ the Software, and to permit persons to whom the Software is furnished to do so,
26
+ subject to the following conditions:
27
+
28
+ The above copyright notice and this permission notice shall be included in all
29
+ copies or substantial portions of the Software.
30
+
31
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
32
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
33
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
34
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
35
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
36
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
37
+
38
+ The Node.js code it was extracted from carries its own notice:
39
+
40
+ Copyright Joyent, Inc. and other Node contributors.
41
+
42
+ Permission is hereby granted, free of charge, to any person obtaining a
43
+ copy of this software and associated documentation files (the
44
+ "Software"), to deal in the Software without restriction, including
45
+ without limitation the rights to use, copy, modify, merge, publish,
46
+ distribute, sublicense, and/or sell copies of the Software, and to permit
47
+ persons to whom the Software is furnished to do so, subject to the
48
+ following conditions:
49
+
50
+ The above copyright notice and this permission notice shall be included
51
+ in all copies or substantial portions of the Software.
52
+
53
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
54
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
55
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
56
+ NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
57
+ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
58
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
59
+ USE OR OTHER DEALINGS IN THE SOFTWARE.
package/index.cjs CHANGED
@@ -1734,57 +1734,75 @@ function isValidRef(name, onelevel) {
1734
1734
  }
1735
1735
 
1736
1736
  /*!
1737
- * This code for `path.join` is directly copied from @zenfs/core/path for bundle size improvements.
1738
- * SPDX-License-Identifier: LGPL-3.0-or-later
1739
- * Copyright (c) James Prevett and other ZenFS contributors.
1737
+ * The POSIX core below - `assertPath`, `normalizeStringPosix` and the body of
1738
+ * `normalize` - comes from path-browserify, which extracted it from Node.js.
1739
+ * Reformatted to this project's style (`const`/`let`, no semicolons); the
1740
+ * algorithm is unchanged.
1740
1741
  *
1741
- * Windows support added:
1742
+ * SPDX-License-Identifier: MIT
1743
+ * Copyright (c) 2013 James Halliday
1744
+ * Copyright Joyent, Inc. and other Node contributors.
1745
+ *
1746
+ * @see https://github.com/browserify/path-browserify
1747
+ *
1748
+ * The Windows handling is this project's own, added in #2302. path-browserify
1749
+ * is the POSIX part of `path` only, so `normalize` and `join` are wrapped with:
1742
1750
  * - Backslashes are normalised to forward slashes before processing.
1743
1751
  * - Drive-letter prefixes (e.g. "C:") are detected and preserved through
1744
1752
  * normalisation, so absolute Windows paths are handled correctly.
1745
- * - An absolute argument passed to join() resets the accumulated path,
1753
+ * - A drive-letter argument passed to join() resets the accumulated path,
1746
1754
  * matching Node behaviour and handling worktree gitdir paths properly.
1747
1755
  *
1748
1756
  * Limitation: UNC paths (e.g. \\server\share) are not supported. The leading
1749
1757
  * backslashes are normalised to forward slashes and then collapsed by
1750
- * normalizeString, losing the UNC root. Git on Windows works with
1758
+ * normalizeStringPosix, losing the UNC root. Git on Windows works with
1751
1759
  * drive-letter paths, so this is not expected to be a practical issue.
1752
1760
  */
1753
1761
 
1754
- function normalizeString(path, aar) {
1762
+ function assertPath(path) {
1763
+ if (typeof path !== 'string') {
1764
+ throw new TypeError(
1765
+ 'Path must be a string. Received ' + JSON.stringify(path)
1766
+ )
1767
+ }
1768
+ }
1769
+
1770
+ // Resolves . and .. elements in a path with directory names
1771
+ function normalizeStringPosix(path, allowAboveRoot) {
1755
1772
  let res = '';
1756
1773
  let lastSegmentLength = 0;
1757
1774
  let lastSlash = -1;
1758
1775
  let dots = 0;
1759
- let char = '\x00';
1776
+ let code;
1760
1777
  for (let i = 0; i <= path.length; ++i) {
1761
- if (i < path.length) char = path[i];
1762
- else if (char === '/') break
1763
- else char = '/';
1764
-
1765
- if (char === '/') {
1778
+ if (i < path.length) code = path.charCodeAt(i);
1779
+ else if (code === 47 /* / */) break
1780
+ else code = 47; /* / */
1781
+ if (code === 47 /* / */) {
1766
1782
  if (lastSlash === i - 1 || dots === 1) {
1767
1783
  // NOOP
1768
- } else if (dots === 2) {
1784
+ } else if (lastSlash !== i - 1 && dots === 2) {
1769
1785
  if (
1770
1786
  res.length < 2 ||
1771
1787
  lastSegmentLength !== 2 ||
1772
- res.at(-1) !== '.' ||
1773
- res.at(-2) !== '.'
1788
+ res.charCodeAt(res.length - 1) !== 46 /* . */ ||
1789
+ res.charCodeAt(res.length - 2) !== 46 /* . */
1774
1790
  ) {
1775
1791
  if (res.length > 2) {
1776
1792
  const lastSlashIndex = res.lastIndexOf('/');
1777
- if (lastSlashIndex === -1) {
1778
- res = '';
1779
- lastSegmentLength = 0;
1780
- } else {
1781
- res = res.slice(0, lastSlashIndex);
1782
- lastSegmentLength = res.length - 1 - res.lastIndexOf('/');
1793
+ if (lastSlashIndex !== res.length - 1) {
1794
+ if (lastSlashIndex === -1) {
1795
+ res = '';
1796
+ lastSegmentLength = 0;
1797
+ } else {
1798
+ res = res.slice(0, lastSlashIndex);
1799
+ lastSegmentLength = res.length - 1 - res.lastIndexOf('/');
1800
+ }
1801
+ lastSlash = i;
1802
+ dots = 0;
1803
+ continue
1783
1804
  }
1784
- lastSlash = i;
1785
- dots = 0;
1786
- continue
1787
- } else if (res.length !== 0) {
1805
+ } else if (res.length === 2 || res.length === 1) {
1788
1806
  res = '';
1789
1807
  lastSegmentLength = 0;
1790
1808
  lastSlash = i;
@@ -1792,8 +1810,9 @@ function normalizeString(path, aar) {
1792
1810
  continue
1793
1811
  }
1794
1812
  }
1795
- if (aar) {
1796
- res += res.length > 0 ? '/..' : '..';
1813
+ if (allowAboveRoot) {
1814
+ if (res.length > 0) res += '/..';
1815
+ else res = '..';
1797
1816
  lastSegmentLength = 2;
1798
1817
  }
1799
1818
  } else {
@@ -1803,7 +1822,7 @@ function normalizeString(path, aar) {
1803
1822
  }
1804
1823
  lastSlash = i;
1805
1824
  dots = 0;
1806
- } else if (char === '.' && dots !== -1) {
1825
+ } else if (code === 46 /* . */ && dots !== -1) {
1807
1826
  ++dots;
1808
1827
  } else {
1809
1828
  dots = -1;
@@ -1821,7 +1840,9 @@ function getWindowsDrivePrefix(path) {
1821
1840
  }
1822
1841
 
1823
1842
  function normalize(path) {
1824
- if (!path.length) return '.'
1843
+ assertPath(path);
1844
+
1845
+ if (path.length === 0) return '.'
1825
1846
 
1826
1847
  // Normalise backslashes to forward slashes before any other processing.
1827
1848
  path = path.replace(/\\/g, '/');
@@ -1829,26 +1850,19 @@ function normalize(path) {
1829
1850
  const drivePrefix = getWindowsDrivePrefix(path);
1830
1851
  // isAbsolute: Unix root ('/foo') OR Windows drive+slash ('C:/foo').
1831
1852
  const isAbsolute =
1832
- path[0] === '/' || (drivePrefix !== null && path[2] === '/');
1833
- const trailingSeparator = path.at(-1) === '/';
1834
-
1835
- // Strip the drive prefix before feeding into normalizeString so that the
1836
- // core algorithm only ever sees a plain POSIX-style string.
1837
- const pathBody = drivePrefix ? path.slice(2) : path;
1838
-
1839
- let normalized = normalizeString(pathBody, !isAbsolute);
1853
+ path.charCodeAt(0) === 47 /* / */ ||
1854
+ (drivePrefix !== null && path.charCodeAt(2) === 47); /* / */
1855
+ const trailingSeparator = path.charCodeAt(path.length - 1) === 47; /* / */
1856
+
1857
+ // Strip the drive prefix before normalizing so that the core algorithm only
1858
+ // ever sees a plain POSIX-style string.
1859
+ let normalized = normalizeStringPosix(
1860
+ drivePrefix ? path.slice(2) : path,
1861
+ !isAbsolute
1862
+ );
1840
1863
 
1841
- if (!normalized.length) {
1842
- const root = drivePrefix
1843
- ? isAbsolute
1844
- ? drivePrefix + '/'
1845
- : drivePrefix
1846
- : isAbsolute
1847
- ? '/'
1848
- : '.';
1849
- return trailingSeparator && !isAbsolute ? root + '/' : root
1850
- }
1851
- if (trailingSeparator) normalized += '/';
1864
+ if (normalized.length === 0 && !isAbsolute) normalized = '.';
1865
+ if (normalized.length > 0 && trailingSeparator) normalized += '/';
1852
1866
 
1853
1867
  if (drivePrefix) {
1854
1868
  return isAbsolute
@@ -1862,19 +1876,21 @@ function join(...args) {
1862
1876
  if (args.length === 0) return '.'
1863
1877
  let joined;
1864
1878
  for (let i = 0; i < args.length; ++i) {
1879
+ assertPath(args[i]);
1865
1880
  // Normalise separators before processing.
1866
1881
  const arg = args[i].replace(/\\/g, '/');
1867
1882
  if (arg.length === 0) continue
1868
1883
 
1869
1884
  // A Windows drive-letter path (e.g. "C:/worktrees/foo") cannot be
1870
1885
  // meaningfully appended to any base, so it resets the accumulator.
1871
- // Unix absolute paths (leading '/') are NOT reset here — that would be
1886
+ // Unix absolute paths (leading '/') are NOT reset here - that would be
1872
1887
  // path.resolve() semantics; path.join('foo', '/bar') must yield 'foo/bar'.
1873
1888
  if (/^[a-zA-Z]:\//.test(arg)) {
1874
1889
  joined = arg;
1890
+ } else if (joined === undefined) {
1891
+ joined = arg;
1875
1892
  } else {
1876
- if (joined === undefined) joined = arg;
1877
- else joined += '/' + arg;
1893
+ joined += '/' + arg;
1878
1894
  }
1879
1895
  }
1880
1896
  if (joined === undefined) return '.'
@@ -10425,8 +10441,8 @@ function filterCapabilities(server, client) {
10425
10441
 
10426
10442
  const pkg = {
10427
10443
  name: 'isomorphic-git',
10428
- version: '1.44.15',
10429
- agent: 'git/isomorphic-git@1.44.15',
10444
+ version: '1.44.16',
10445
+ agent: 'git/isomorphic-git@1.44.16',
10430
10446
  };
10431
10447
 
10432
10448
  class FIFO {
package/index.js CHANGED
@@ -1728,57 +1728,75 @@ function isValidRef(name, onelevel) {
1728
1728
  }
1729
1729
 
1730
1730
  /*!
1731
- * This code for `path.join` is directly copied from @zenfs/core/path for bundle size improvements.
1732
- * SPDX-License-Identifier: LGPL-3.0-or-later
1733
- * Copyright (c) James Prevett and other ZenFS contributors.
1731
+ * The POSIX core below - `assertPath`, `normalizeStringPosix` and the body of
1732
+ * `normalize` - comes from path-browserify, which extracted it from Node.js.
1733
+ * Reformatted to this project's style (`const`/`let`, no semicolons); the
1734
+ * algorithm is unchanged.
1734
1735
  *
1735
- * Windows support added:
1736
+ * SPDX-License-Identifier: MIT
1737
+ * Copyright (c) 2013 James Halliday
1738
+ * Copyright Joyent, Inc. and other Node contributors.
1739
+ *
1740
+ * @see https://github.com/browserify/path-browserify
1741
+ *
1742
+ * The Windows handling is this project's own, added in #2302. path-browserify
1743
+ * is the POSIX part of `path` only, so `normalize` and `join` are wrapped with:
1736
1744
  * - Backslashes are normalised to forward slashes before processing.
1737
1745
  * - Drive-letter prefixes (e.g. "C:") are detected and preserved through
1738
1746
  * normalisation, so absolute Windows paths are handled correctly.
1739
- * - An absolute argument passed to join() resets the accumulated path,
1747
+ * - A drive-letter argument passed to join() resets the accumulated path,
1740
1748
  * matching Node behaviour and handling worktree gitdir paths properly.
1741
1749
  *
1742
1750
  * Limitation: UNC paths (e.g. \\server\share) are not supported. The leading
1743
1751
  * backslashes are normalised to forward slashes and then collapsed by
1744
- * normalizeString, losing the UNC root. Git on Windows works with
1752
+ * normalizeStringPosix, losing the UNC root. Git on Windows works with
1745
1753
  * drive-letter paths, so this is not expected to be a practical issue.
1746
1754
  */
1747
1755
 
1748
- function normalizeString(path, aar) {
1756
+ function assertPath(path) {
1757
+ if (typeof path !== 'string') {
1758
+ throw new TypeError(
1759
+ 'Path must be a string. Received ' + JSON.stringify(path)
1760
+ )
1761
+ }
1762
+ }
1763
+
1764
+ // Resolves . and .. elements in a path with directory names
1765
+ function normalizeStringPosix(path, allowAboveRoot) {
1749
1766
  let res = '';
1750
1767
  let lastSegmentLength = 0;
1751
1768
  let lastSlash = -1;
1752
1769
  let dots = 0;
1753
- let char = '\x00';
1770
+ let code;
1754
1771
  for (let i = 0; i <= path.length; ++i) {
1755
- if (i < path.length) char = path[i];
1756
- else if (char === '/') break
1757
- else char = '/';
1758
-
1759
- if (char === '/') {
1772
+ if (i < path.length) code = path.charCodeAt(i);
1773
+ else if (code === 47 /* / */) break
1774
+ else code = 47; /* / */
1775
+ if (code === 47 /* / */) {
1760
1776
  if (lastSlash === i - 1 || dots === 1) {
1761
1777
  // NOOP
1762
- } else if (dots === 2) {
1778
+ } else if (lastSlash !== i - 1 && dots === 2) {
1763
1779
  if (
1764
1780
  res.length < 2 ||
1765
1781
  lastSegmentLength !== 2 ||
1766
- res.at(-1) !== '.' ||
1767
- res.at(-2) !== '.'
1782
+ res.charCodeAt(res.length - 1) !== 46 /* . */ ||
1783
+ res.charCodeAt(res.length - 2) !== 46 /* . */
1768
1784
  ) {
1769
1785
  if (res.length > 2) {
1770
1786
  const lastSlashIndex = res.lastIndexOf('/');
1771
- if (lastSlashIndex === -1) {
1772
- res = '';
1773
- lastSegmentLength = 0;
1774
- } else {
1775
- res = res.slice(0, lastSlashIndex);
1776
- lastSegmentLength = res.length - 1 - res.lastIndexOf('/');
1787
+ if (lastSlashIndex !== res.length - 1) {
1788
+ if (lastSlashIndex === -1) {
1789
+ res = '';
1790
+ lastSegmentLength = 0;
1791
+ } else {
1792
+ res = res.slice(0, lastSlashIndex);
1793
+ lastSegmentLength = res.length - 1 - res.lastIndexOf('/');
1794
+ }
1795
+ lastSlash = i;
1796
+ dots = 0;
1797
+ continue
1777
1798
  }
1778
- lastSlash = i;
1779
- dots = 0;
1780
- continue
1781
- } else if (res.length !== 0) {
1799
+ } else if (res.length === 2 || res.length === 1) {
1782
1800
  res = '';
1783
1801
  lastSegmentLength = 0;
1784
1802
  lastSlash = i;
@@ -1786,8 +1804,9 @@ function normalizeString(path, aar) {
1786
1804
  continue
1787
1805
  }
1788
1806
  }
1789
- if (aar) {
1790
- res += res.length > 0 ? '/..' : '..';
1807
+ if (allowAboveRoot) {
1808
+ if (res.length > 0) res += '/..';
1809
+ else res = '..';
1791
1810
  lastSegmentLength = 2;
1792
1811
  }
1793
1812
  } else {
@@ -1797,7 +1816,7 @@ function normalizeString(path, aar) {
1797
1816
  }
1798
1817
  lastSlash = i;
1799
1818
  dots = 0;
1800
- } else if (char === '.' && dots !== -1) {
1819
+ } else if (code === 46 /* . */ && dots !== -1) {
1801
1820
  ++dots;
1802
1821
  } else {
1803
1822
  dots = -1;
@@ -1815,7 +1834,9 @@ function getWindowsDrivePrefix(path) {
1815
1834
  }
1816
1835
 
1817
1836
  function normalize(path) {
1818
- if (!path.length) return '.'
1837
+ assertPath(path);
1838
+
1839
+ if (path.length === 0) return '.'
1819
1840
 
1820
1841
  // Normalise backslashes to forward slashes before any other processing.
1821
1842
  path = path.replace(/\\/g, '/');
@@ -1823,26 +1844,19 @@ function normalize(path) {
1823
1844
  const drivePrefix = getWindowsDrivePrefix(path);
1824
1845
  // isAbsolute: Unix root ('/foo') OR Windows drive+slash ('C:/foo').
1825
1846
  const isAbsolute =
1826
- path[0] === '/' || (drivePrefix !== null && path[2] === '/');
1827
- const trailingSeparator = path.at(-1) === '/';
1828
-
1829
- // Strip the drive prefix before feeding into normalizeString so that the
1830
- // core algorithm only ever sees a plain POSIX-style string.
1831
- const pathBody = drivePrefix ? path.slice(2) : path;
1832
-
1833
- let normalized = normalizeString(pathBody, !isAbsolute);
1847
+ path.charCodeAt(0) === 47 /* / */ ||
1848
+ (drivePrefix !== null && path.charCodeAt(2) === 47); /* / */
1849
+ const trailingSeparator = path.charCodeAt(path.length - 1) === 47; /* / */
1850
+
1851
+ // Strip the drive prefix before normalizing so that the core algorithm only
1852
+ // ever sees a plain POSIX-style string.
1853
+ let normalized = normalizeStringPosix(
1854
+ drivePrefix ? path.slice(2) : path,
1855
+ !isAbsolute
1856
+ );
1834
1857
 
1835
- if (!normalized.length) {
1836
- const root = drivePrefix
1837
- ? isAbsolute
1838
- ? drivePrefix + '/'
1839
- : drivePrefix
1840
- : isAbsolute
1841
- ? '/'
1842
- : '.';
1843
- return trailingSeparator && !isAbsolute ? root + '/' : root
1844
- }
1845
- if (trailingSeparator) normalized += '/';
1858
+ if (normalized.length === 0 && !isAbsolute) normalized = '.';
1859
+ if (normalized.length > 0 && trailingSeparator) normalized += '/';
1846
1860
 
1847
1861
  if (drivePrefix) {
1848
1862
  return isAbsolute
@@ -1856,19 +1870,21 @@ function join(...args) {
1856
1870
  if (args.length === 0) return '.'
1857
1871
  let joined;
1858
1872
  for (let i = 0; i < args.length; ++i) {
1873
+ assertPath(args[i]);
1859
1874
  // Normalise separators before processing.
1860
1875
  const arg = args[i].replace(/\\/g, '/');
1861
1876
  if (arg.length === 0) continue
1862
1877
 
1863
1878
  // A Windows drive-letter path (e.g. "C:/worktrees/foo") cannot be
1864
1879
  // meaningfully appended to any base, so it resets the accumulator.
1865
- // Unix absolute paths (leading '/') are NOT reset here — that would be
1880
+ // Unix absolute paths (leading '/') are NOT reset here - that would be
1866
1881
  // path.resolve() semantics; path.join('foo', '/bar') must yield 'foo/bar'.
1867
1882
  if (/^[a-zA-Z]:\//.test(arg)) {
1868
1883
  joined = arg;
1884
+ } else if (joined === undefined) {
1885
+ joined = arg;
1869
1886
  } else {
1870
- if (joined === undefined) joined = arg;
1871
- else joined += '/' + arg;
1887
+ joined += '/' + arg;
1872
1888
  }
1873
1889
  }
1874
1890
  if (joined === undefined) return '.'
@@ -10413,8 +10429,8 @@ function filterCapabilities(server, client) {
10413
10429
 
10414
10430
  const pkg = {
10415
10431
  name: 'isomorphic-git',
10416
- version: '1.44.15',
10417
- agent: 'git/isomorphic-git@1.44.15',
10432
+ version: '1.44.16',
10433
+ agent: 'git/isomorphic-git@1.44.16',
10418
10434
  };
10419
10435
 
10420
10436
  class FIFO {