isomorphic-git 1.42.3 → 1.42.5
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 +54 -6
- package/index.js +54 -6
- package/index.umd.min.js +1 -1
- package/index.umd.min.js.map +1 -1
- package/managers/index.cjs +52 -4
- package/managers/index.js +52 -4
- package/managers/index.umd.min.js +1 -1
- package/managers/index.umd.min.js.map +1 -1
- package/models/index.cjs +47 -2
- package/models/index.js +47 -2
- package/models/index.umd.min.js +1 -1
- package/models/index.umd.min.js.map +1 -1
- package/package.json +1 -1
package/managers/index.cjs
CHANGED
|
@@ -886,14 +886,17 @@ class GitIgnoreManager {
|
|
|
886
886
|
});
|
|
887
887
|
}
|
|
888
888
|
let ignoredStatus = false;
|
|
889
|
-
for (const p of pairs) {
|
|
889
|
+
for (const [index, p] of pairs.entries()) {
|
|
890
890
|
let file;
|
|
891
891
|
try {
|
|
892
892
|
file = await fs.read(p.gitignore, 'utf8');
|
|
893
893
|
} catch (err) {
|
|
894
894
|
if (err.code === 'NOENT') continue
|
|
895
895
|
}
|
|
896
|
-
const ign = ignore()
|
|
896
|
+
const ign = ignore();
|
|
897
|
+
// The patterns in .git/info/exclude are relative to the working directory,
|
|
898
|
+
// so only the first pair, which holds the full filepath, can use them.
|
|
899
|
+
if (index === 0) ign.add(excludes);
|
|
897
900
|
ign.add(file);
|
|
898
901
|
// If the parent directory is excluded, we are done.
|
|
899
902
|
// "It is not possible to re-include a file if a parent directory of that file is excluded. Git doesn’t list excluded directories for performance reasons, so any patterns on contained files have no effect, no matter where they are defined."
|
|
@@ -1068,9 +1071,54 @@ class BufferCursor {
|
|
|
1068
1071
|
}
|
|
1069
1072
|
}
|
|
1070
1073
|
|
|
1074
|
+
// Code units from U+D800 up. Only these can make the two orders differ.
|
|
1075
|
+
const NEEDS_CODE_POINT_ORDER = /[\ud800-]/;
|
|
1076
|
+
|
|
1077
|
+
// Is the code unit at index i a surrogate with no partner? Such a unit is not valid Unicode.
|
|
1078
|
+
// A high surrogate needs a low one after it. A low surrogate needs a high one before it.
|
|
1079
|
+
function isLoneSurrogate(s, i, unit) {
|
|
1080
|
+
if (unit < 0xd800 || unit > 0xdfff) return false
|
|
1081
|
+
if (unit < 0xdc00) {
|
|
1082
|
+
const next = i + 1 < s.length ? s.charCodeAt(i + 1) : 0;
|
|
1083
|
+
return next < 0xdc00 || next > 0xdfff
|
|
1084
|
+
}
|
|
1085
|
+
const prev = i > 0 ? s.charCodeAt(i - 1) : 0;
|
|
1086
|
+
return prev < 0xd800 || prev > 0xdbff
|
|
1087
|
+
}
|
|
1088
|
+
|
|
1089
|
+
/**
|
|
1090
|
+
* Compare two strings by code point. This gives the same order as the UTF-8 bytes of the
|
|
1091
|
+
* strings, and git sorts paths in that order. The `<` operator compares UTF-16 code units,
|
|
1092
|
+
* so it puts a character above U+FFFF (a surrogate pair) before the characters from U+E000
|
|
1093
|
+
* to U+FFFF. Git puts it after them. A lone surrogate counts as U+FFFD, because the UTF-8
|
|
1094
|
+
* encoding of the path writes it that way.
|
|
1095
|
+
*
|
|
1096
|
+
* @param {string} a
|
|
1097
|
+
* @param {string} b
|
|
1098
|
+
* @returns {-1 | 0 | 1}
|
|
1099
|
+
*/
|
|
1071
1100
|
function compareStrings(a, b) {
|
|
1072
|
-
|
|
1073
|
-
|
|
1101
|
+
if (!NEEDS_CODE_POINT_ORDER.test(a) && !NEEDS_CODE_POINT_ORDER.test(b)) {
|
|
1102
|
+
// Both orders are the same, and the `<` operator is the fastest way.
|
|
1103
|
+
return -(a < b) || +(a > b)
|
|
1104
|
+
}
|
|
1105
|
+
const length = Math.min(a.length, b.length);
|
|
1106
|
+
for (let i = 0; i < length; i++) {
|
|
1107
|
+
let x = a.charCodeAt(i);
|
|
1108
|
+
let y = b.charCodeAt(i);
|
|
1109
|
+
if (x !== y) {
|
|
1110
|
+
if (isLoneSurrogate(a, i, x)) x = 0xfffd;
|
|
1111
|
+
if (isLoneSurrogate(b, i, y)) y = 0xfffd;
|
|
1112
|
+
if (x === y) continue
|
|
1113
|
+
// Move the surrogates (U+D800 to U+DFFF) above U+FFFF, where their code points are.
|
|
1114
|
+
if (x >= 0xd800 && y >= 0xd800) {
|
|
1115
|
+
x += x >= 0xe000 ? -0x800 : 0x2000;
|
|
1116
|
+
y += y >= 0xe000 ? -0x800 : 0x2000;
|
|
1117
|
+
}
|
|
1118
|
+
return x < y ? -1 : 1
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1121
|
+
return a.length < b.length ? -1 : a.length > b.length ? 1 : 0
|
|
1074
1122
|
}
|
|
1075
1123
|
|
|
1076
1124
|
function comparePath(a, b) {
|
package/managers/index.js
CHANGED
|
@@ -879,14 +879,17 @@ class GitIgnoreManager {
|
|
|
879
879
|
});
|
|
880
880
|
}
|
|
881
881
|
let ignoredStatus = false;
|
|
882
|
-
for (const p of pairs) {
|
|
882
|
+
for (const [index, p] of pairs.entries()) {
|
|
883
883
|
let file;
|
|
884
884
|
try {
|
|
885
885
|
file = await fs.read(p.gitignore, 'utf8');
|
|
886
886
|
} catch (err) {
|
|
887
887
|
if (err.code === 'NOENT') continue
|
|
888
888
|
}
|
|
889
|
-
const ign = ignore()
|
|
889
|
+
const ign = ignore();
|
|
890
|
+
// The patterns in .git/info/exclude are relative to the working directory,
|
|
891
|
+
// so only the first pair, which holds the full filepath, can use them.
|
|
892
|
+
if (index === 0) ign.add(excludes);
|
|
890
893
|
ign.add(file);
|
|
891
894
|
// If the parent directory is excluded, we are done.
|
|
892
895
|
// "It is not possible to re-include a file if a parent directory of that file is excluded. Git doesn’t list excluded directories for performance reasons, so any patterns on contained files have no effect, no matter where they are defined."
|
|
@@ -1061,9 +1064,54 @@ class BufferCursor {
|
|
|
1061
1064
|
}
|
|
1062
1065
|
}
|
|
1063
1066
|
|
|
1067
|
+
// Code units from U+D800 up. Only these can make the two orders differ.
|
|
1068
|
+
const NEEDS_CODE_POINT_ORDER = /[\ud800-]/;
|
|
1069
|
+
|
|
1070
|
+
// Is the code unit at index i a surrogate with no partner? Such a unit is not valid Unicode.
|
|
1071
|
+
// A high surrogate needs a low one after it. A low surrogate needs a high one before it.
|
|
1072
|
+
function isLoneSurrogate(s, i, unit) {
|
|
1073
|
+
if (unit < 0xd800 || unit > 0xdfff) return false
|
|
1074
|
+
if (unit < 0xdc00) {
|
|
1075
|
+
const next = i + 1 < s.length ? s.charCodeAt(i + 1) : 0;
|
|
1076
|
+
return next < 0xdc00 || next > 0xdfff
|
|
1077
|
+
}
|
|
1078
|
+
const prev = i > 0 ? s.charCodeAt(i - 1) : 0;
|
|
1079
|
+
return prev < 0xd800 || prev > 0xdbff
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1082
|
+
/**
|
|
1083
|
+
* Compare two strings by code point. This gives the same order as the UTF-8 bytes of the
|
|
1084
|
+
* strings, and git sorts paths in that order. The `<` operator compares UTF-16 code units,
|
|
1085
|
+
* so it puts a character above U+FFFF (a surrogate pair) before the characters from U+E000
|
|
1086
|
+
* to U+FFFF. Git puts it after them. A lone surrogate counts as U+FFFD, because the UTF-8
|
|
1087
|
+
* encoding of the path writes it that way.
|
|
1088
|
+
*
|
|
1089
|
+
* @param {string} a
|
|
1090
|
+
* @param {string} b
|
|
1091
|
+
* @returns {-1 | 0 | 1}
|
|
1092
|
+
*/
|
|
1064
1093
|
function compareStrings(a, b) {
|
|
1065
|
-
|
|
1066
|
-
|
|
1094
|
+
if (!NEEDS_CODE_POINT_ORDER.test(a) && !NEEDS_CODE_POINT_ORDER.test(b)) {
|
|
1095
|
+
// Both orders are the same, and the `<` operator is the fastest way.
|
|
1096
|
+
return -(a < b) || +(a > b)
|
|
1097
|
+
}
|
|
1098
|
+
const length = Math.min(a.length, b.length);
|
|
1099
|
+
for (let i = 0; i < length; i++) {
|
|
1100
|
+
let x = a.charCodeAt(i);
|
|
1101
|
+
let y = b.charCodeAt(i);
|
|
1102
|
+
if (x !== y) {
|
|
1103
|
+
if (isLoneSurrogate(a, i, x)) x = 0xfffd;
|
|
1104
|
+
if (isLoneSurrogate(b, i, y)) y = 0xfffd;
|
|
1105
|
+
if (x === y) continue
|
|
1106
|
+
// Move the surrogates (U+D800 to U+DFFF) above U+FFFF, where their code points are.
|
|
1107
|
+
if (x >= 0xd800 && y >= 0xd800) {
|
|
1108
|
+
x += x >= 0xe000 ? -0x800 : 0x2000;
|
|
1109
|
+
y += y >= 0xe000 ? -0x800 : 0x2000;
|
|
1110
|
+
}
|
|
1111
|
+
return x < y ? -1 : 1
|
|
1112
|
+
}
|
|
1113
|
+
}
|
|
1114
|
+
return a.length < b.length ? -1 : a.length > b.length ? 1 : 0
|
|
1067
1115
|
}
|
|
1068
1116
|
|
|
1069
1117
|
function comparePath(a, b) {
|