isomorphic-git 1.31.1 → 1.32.0

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.
@@ -1,8 +1,10 @@
1
1
  [
2
- "Chrome Headless 79.0.3945.0 (Linux x86_64)",
2
+ "X Chrome Headless 79.0.3945.0 (Linux x86_64)",
3
3
  "Firefox 139.0 (Linux x86_64)",
4
- "Edge 79.0.309.65 (Windows 10)",
5
4
  "Chrome 135.0.0.0 (Android 10)",
5
+ "Edge 79.0.309.65 (Windows 10)",
6
+ "Mobile Safari 14.0 (iOS 14.0.1)",
6
7
  "Safari 14.1 (Mac OS 10.15.7)",
7
- "Mobile Safari 14.0 (iOS 14.0.1)"
8
+ "Chrome Headless 79.0.3945.0 (Linux x86_64)",
9
+ "Chrome 135.0.0.0 (Android 10)"
8
10
  ]
package/index.cjs CHANGED
@@ -7776,8 +7776,8 @@ function filterCapabilities(server, client) {
7776
7776
 
7777
7777
  const pkg = {
7778
7778
  name: 'isomorphic-git',
7779
- version: '1.31.1',
7780
- agent: 'git/isomorphic-git@1.31.1',
7779
+ version: '1.32.0',
7780
+ agent: 'git/isomorphic-git@1.32.0',
7781
7781
  };
7782
7782
 
7783
7783
  class FIFO {
@@ -9440,10 +9440,8 @@ async function mergeTree({
9440
9440
  // Modifications
9441
9441
  if (
9442
9442
  ours &&
9443
- base &&
9444
9443
  theirs &&
9445
9444
  (await ours.type()) === 'blob' &&
9446
- (await base.type()) === 'blob' &&
9447
9445
  (await theirs.type()) === 'blob'
9448
9446
  ) {
9449
9447
  return mergeBlobs({
@@ -9462,13 +9460,18 @@ async function mergeTree({
9462
9460
  unmergedFiles.push(filepath);
9463
9461
  bothModified.push(filepath);
9464
9462
  if (!abortOnConflict) {
9465
- const baseOid = await base.oid();
9463
+ let baseOid = '';
9464
+ if (base && (await base.type()) === 'blob') {
9465
+ baseOid = await base.oid();
9466
+ }
9466
9467
  const ourOid = await ours.oid();
9467
9468
  const theirOid = await theirs.oid();
9468
9469
 
9469
9470
  index.delete({ filepath });
9470
9471
 
9471
- index.insert({ filepath, oid: baseOid, stage: 1 });
9472
+ if (baseOid) {
9473
+ index.insert({ filepath, oid: baseOid, stage: 1 });
9474
+ }
9472
9475
  index.insert({ filepath, oid: ourOid, stage: 2 });
9473
9476
  index.insert({ filepath, oid: theirOid, stage: 3 });
9474
9477
  }
@@ -9655,10 +9658,16 @@ async function mergeBlobs({
9655
9658
  const type = 'blob';
9656
9659
  // Compute the new mode.
9657
9660
  // Since there are ONLY two valid blob modes ('100755' and '100644') it boils down to this
9661
+ let baseMode = '100755';
9662
+ let baseOid = '';
9663
+ let baseContent = '';
9664
+ if (base && (await base.type()) === 'blob') {
9665
+ baseMode = await base.mode();
9666
+ baseOid = await base.oid();
9667
+ baseContent = Buffer.from(await base.content()).toString('utf8');
9668
+ }
9658
9669
  const mode =
9659
- (await base.mode()) === (await ours.mode())
9660
- ? await theirs.mode()
9661
- : await ours.mode();
9670
+ baseMode === (await ours.mode()) ? await theirs.mode() : await ours.mode();
9662
9671
  // The trivial case: nothing to merge except maybe mode
9663
9672
  if ((await ours.oid()) === (await theirs.oid())) {
9664
9673
  return {
@@ -9667,13 +9676,13 @@ async function mergeBlobs({
9667
9676
  }
9668
9677
  }
9669
9678
  // if only one side made oid changes, return that side's oid
9670
- if ((await ours.oid()) === (await base.oid())) {
9679
+ if ((await ours.oid()) === baseOid) {
9671
9680
  return {
9672
9681
  cleanMerge: true,
9673
9682
  mergeResult: { mode, path, oid: await theirs.oid(), type },
9674
9683
  }
9675
9684
  }
9676
- if ((await theirs.oid()) === (await base.oid())) {
9685
+ if ((await theirs.oid()) === baseOid) {
9677
9686
  return {
9678
9687
  cleanMerge: true,
9679
9688
  mergeResult: { mode, path, oid: await ours.oid(), type },
@@ -9681,7 +9690,6 @@ async function mergeBlobs({
9681
9690
  }
9682
9691
  // if both sides made changes do a merge
9683
9692
  const ourContent = Buffer.from(await ours.content()).toString('utf8');
9684
- const baseContent = Buffer.from(await base.content()).toString('utf8');
9685
9693
  const theirContent = Buffer.from(await theirs.content()).toString('utf8');
9686
9694
  const { mergedText, cleanMerge } = await mergeDriver({
9687
9695
  branches: [baseName, ourName, theirName],
@@ -9739,6 +9747,7 @@ async function mergeBlobs({
9739
9747
  * @param {string} [args.signingKey]
9740
9748
  * @param {SignCallback} [args.onSign] - a PGP signing implementation
9741
9749
  * @param {MergeDriverCallback} [args.mergeDriver]
9750
+ * @param {boolean} args.allowUnrelatedHistories
9742
9751
  *
9743
9752
  * @returns {Promise<MergeResult>} Resolves to a description of the merge operation
9744
9753
  *
@@ -9761,6 +9770,7 @@ async function _merge({
9761
9770
  signingKey,
9762
9771
  onSign,
9763
9772
  mergeDriver,
9773
+ allowUnrelatedHistories = false,
9764
9774
  }) {
9765
9775
  if (ours === undefined) {
9766
9776
  ours = await _currentBranch({ fs, gitdir, fullname: true });
@@ -9793,8 +9803,13 @@ async function _merge({
9793
9803
  oids: [ourOid, theirOid],
9794
9804
  });
9795
9805
  if (baseOids.length !== 1) {
9796
- // TODO: Recursive Merge strategy
9797
- throw new MergeNotSupportedError()
9806
+ if (baseOids.length === 0 && allowUnrelatedHistories) {
9807
+ // 4b825… == the empty tree used by git
9808
+ baseOids.push('4b825dc642cb6eb9a060e54bf8d69288fbee4904');
9809
+ } else {
9810
+ // TODO: Recursive Merge strategy
9811
+ throw new MergeNotSupportedError()
9812
+ }
9798
9813
  }
9799
9814
  const baseOid = baseOids[0];
9800
9815
  // handle fast-forward case
@@ -12017,6 +12032,7 @@ async function log({
12017
12032
  * @param {string} [args.signingKey] - passed to [commit](commit.md) when creating a merge commit
12018
12033
  * @param {object} [args.cache] - a [cache](cache.md) object
12019
12034
  * @param {MergeDriverCallback} [args.mergeDriver] - a [merge driver](mergeDriver.md) implementation
12035
+ * @param {boolean} [args.allowUnrelatedHistories = false] - If true, allows merging histories of two branches that started their lives independently.
12020
12036
  *
12021
12037
  * @returns {Promise<MergeResult>} Resolves to a description of the merge operation
12022
12038
  * @see MergeResult
@@ -12049,6 +12065,7 @@ async function merge({
12049
12065
  signingKey,
12050
12066
  cache = {},
12051
12067
  mergeDriver,
12068
+ allowUnrelatedHistories = false,
12052
12069
  }) {
12053
12070
  try {
12054
12071
  assertParameter('fs', _fs);
@@ -12090,6 +12107,7 @@ async function merge({
12090
12107
  signingKey,
12091
12108
  onSign,
12092
12109
  mergeDriver,
12110
+ allowUnrelatedHistories,
12093
12111
  })
12094
12112
  } catch (err) {
12095
12113
  err.caller = 'git.merge';
package/index.d.ts CHANGED
@@ -2245,6 +2245,7 @@ export function log({ fs, dir, gitdir, filepath, ref, depth, since, force, follo
2245
2245
  * @param {string} [args.signingKey] - passed to [commit](commit.md) when creating a merge commit
2246
2246
  * @param {object} [args.cache] - a [cache](cache.md) object
2247
2247
  * @param {MergeDriverCallback} [args.mergeDriver] - a [merge driver](mergeDriver.md) implementation
2248
+ * @param {boolean} [args.allowUnrelatedHistories = false] - If true, allows merging histories of two branches that started their lives independently.
2248
2249
  *
2249
2250
  * @returns {Promise<MergeResult>} Resolves to a description of the merge operation
2250
2251
  * @see MergeResult
@@ -2259,7 +2260,7 @@ export function log({ fs, dir, gitdir, filepath, ref, depth, since, force, follo
2259
2260
  * console.log(m)
2260
2261
  *
2261
2262
  */
2262
- export function merge({ fs: _fs, onSign, dir, gitdir, ours, theirs, fastForward, fastForwardOnly, dryRun, noUpdateBranch, abortOnConflict, message, author: _author, committer: _committer, signingKey, cache, mergeDriver, }: {
2263
+ export function merge({ fs: _fs, onSign, dir, gitdir, ours, theirs, fastForward, fastForwardOnly, dryRun, noUpdateBranch, abortOnConflict, message, author: _author, committer: _committer, signingKey, cache, mergeDriver, allowUnrelatedHistories, }: {
2263
2264
  fs: FsClient;
2264
2265
  onSign?: SignCallback | undefined;
2265
2266
  dir?: string | undefined;
@@ -2287,6 +2288,7 @@ export function merge({ fs: _fs, onSign, dir, gitdir, ours, theirs, fastForward,
2287
2288
  signingKey?: string | undefined;
2288
2289
  cache?: object;
2289
2290
  mergeDriver?: MergeDriverCallback | undefined;
2291
+ allowUnrelatedHistories?: boolean | undefined;
2290
2292
  }): Promise<MergeResult>;
2291
2293
  /**
2292
2294
  *
package/index.js CHANGED
@@ -7770,8 +7770,8 @@ function filterCapabilities(server, client) {
7770
7770
 
7771
7771
  const pkg = {
7772
7772
  name: 'isomorphic-git',
7773
- version: '1.31.1',
7774
- agent: 'git/isomorphic-git@1.31.1',
7773
+ version: '1.32.0',
7774
+ agent: 'git/isomorphic-git@1.32.0',
7775
7775
  };
7776
7776
 
7777
7777
  class FIFO {
@@ -9434,10 +9434,8 @@ async function mergeTree({
9434
9434
  // Modifications
9435
9435
  if (
9436
9436
  ours &&
9437
- base &&
9438
9437
  theirs &&
9439
9438
  (await ours.type()) === 'blob' &&
9440
- (await base.type()) === 'blob' &&
9441
9439
  (await theirs.type()) === 'blob'
9442
9440
  ) {
9443
9441
  return mergeBlobs({
@@ -9456,13 +9454,18 @@ async function mergeTree({
9456
9454
  unmergedFiles.push(filepath);
9457
9455
  bothModified.push(filepath);
9458
9456
  if (!abortOnConflict) {
9459
- const baseOid = await base.oid();
9457
+ let baseOid = '';
9458
+ if (base && (await base.type()) === 'blob') {
9459
+ baseOid = await base.oid();
9460
+ }
9460
9461
  const ourOid = await ours.oid();
9461
9462
  const theirOid = await theirs.oid();
9462
9463
 
9463
9464
  index.delete({ filepath });
9464
9465
 
9465
- index.insert({ filepath, oid: baseOid, stage: 1 });
9466
+ if (baseOid) {
9467
+ index.insert({ filepath, oid: baseOid, stage: 1 });
9468
+ }
9466
9469
  index.insert({ filepath, oid: ourOid, stage: 2 });
9467
9470
  index.insert({ filepath, oid: theirOid, stage: 3 });
9468
9471
  }
@@ -9649,10 +9652,16 @@ async function mergeBlobs({
9649
9652
  const type = 'blob';
9650
9653
  // Compute the new mode.
9651
9654
  // Since there are ONLY two valid blob modes ('100755' and '100644') it boils down to this
9655
+ let baseMode = '100755';
9656
+ let baseOid = '';
9657
+ let baseContent = '';
9658
+ if (base && (await base.type()) === 'blob') {
9659
+ baseMode = await base.mode();
9660
+ baseOid = await base.oid();
9661
+ baseContent = Buffer.from(await base.content()).toString('utf8');
9662
+ }
9652
9663
  const mode =
9653
- (await base.mode()) === (await ours.mode())
9654
- ? await theirs.mode()
9655
- : await ours.mode();
9664
+ baseMode === (await ours.mode()) ? await theirs.mode() : await ours.mode();
9656
9665
  // The trivial case: nothing to merge except maybe mode
9657
9666
  if ((await ours.oid()) === (await theirs.oid())) {
9658
9667
  return {
@@ -9661,13 +9670,13 @@ async function mergeBlobs({
9661
9670
  }
9662
9671
  }
9663
9672
  // if only one side made oid changes, return that side's oid
9664
- if ((await ours.oid()) === (await base.oid())) {
9673
+ if ((await ours.oid()) === baseOid) {
9665
9674
  return {
9666
9675
  cleanMerge: true,
9667
9676
  mergeResult: { mode, path, oid: await theirs.oid(), type },
9668
9677
  }
9669
9678
  }
9670
- if ((await theirs.oid()) === (await base.oid())) {
9679
+ if ((await theirs.oid()) === baseOid) {
9671
9680
  return {
9672
9681
  cleanMerge: true,
9673
9682
  mergeResult: { mode, path, oid: await ours.oid(), type },
@@ -9675,7 +9684,6 @@ async function mergeBlobs({
9675
9684
  }
9676
9685
  // if both sides made changes do a merge
9677
9686
  const ourContent = Buffer.from(await ours.content()).toString('utf8');
9678
- const baseContent = Buffer.from(await base.content()).toString('utf8');
9679
9687
  const theirContent = Buffer.from(await theirs.content()).toString('utf8');
9680
9688
  const { mergedText, cleanMerge } = await mergeDriver({
9681
9689
  branches: [baseName, ourName, theirName],
@@ -9733,6 +9741,7 @@ async function mergeBlobs({
9733
9741
  * @param {string} [args.signingKey]
9734
9742
  * @param {SignCallback} [args.onSign] - a PGP signing implementation
9735
9743
  * @param {MergeDriverCallback} [args.mergeDriver]
9744
+ * @param {boolean} args.allowUnrelatedHistories
9736
9745
  *
9737
9746
  * @returns {Promise<MergeResult>} Resolves to a description of the merge operation
9738
9747
  *
@@ -9755,6 +9764,7 @@ async function _merge({
9755
9764
  signingKey,
9756
9765
  onSign,
9757
9766
  mergeDriver,
9767
+ allowUnrelatedHistories = false,
9758
9768
  }) {
9759
9769
  if (ours === undefined) {
9760
9770
  ours = await _currentBranch({ fs, gitdir, fullname: true });
@@ -9787,8 +9797,13 @@ async function _merge({
9787
9797
  oids: [ourOid, theirOid],
9788
9798
  });
9789
9799
  if (baseOids.length !== 1) {
9790
- // TODO: Recursive Merge strategy
9791
- throw new MergeNotSupportedError()
9800
+ if (baseOids.length === 0 && allowUnrelatedHistories) {
9801
+ // 4b825… == the empty tree used by git
9802
+ baseOids.push('4b825dc642cb6eb9a060e54bf8d69288fbee4904');
9803
+ } else {
9804
+ // TODO: Recursive Merge strategy
9805
+ throw new MergeNotSupportedError()
9806
+ }
9792
9807
  }
9793
9808
  const baseOid = baseOids[0];
9794
9809
  // handle fast-forward case
@@ -12011,6 +12026,7 @@ async function log({
12011
12026
  * @param {string} [args.signingKey] - passed to [commit](commit.md) when creating a merge commit
12012
12027
  * @param {object} [args.cache] - a [cache](cache.md) object
12013
12028
  * @param {MergeDriverCallback} [args.mergeDriver] - a [merge driver](mergeDriver.md) implementation
12029
+ * @param {boolean} [args.allowUnrelatedHistories = false] - If true, allows merging histories of two branches that started their lives independently.
12014
12030
  *
12015
12031
  * @returns {Promise<MergeResult>} Resolves to a description of the merge operation
12016
12032
  * @see MergeResult
@@ -12043,6 +12059,7 @@ async function merge({
12043
12059
  signingKey,
12044
12060
  cache = {},
12045
12061
  mergeDriver,
12062
+ allowUnrelatedHistories = false,
12046
12063
  }) {
12047
12064
  try {
12048
12065
  assertParameter('fs', _fs);
@@ -12084,6 +12101,7 @@ async function merge({
12084
12101
  signingKey,
12085
12102
  onSign,
12086
12103
  mergeDriver,
12104
+ allowUnrelatedHistories,
12087
12105
  })
12088
12106
  } catch (err) {
12089
12107
  err.caller = 'git.merge';
@@ -2245,6 +2245,7 @@ export function log({ fs, dir, gitdir, filepath, ref, depth, since, force, follo
2245
2245
  * @param {string} [args.signingKey] - passed to [commit](commit.md) when creating a merge commit
2246
2246
  * @param {object} [args.cache] - a [cache](cache.md) object
2247
2247
  * @param {MergeDriverCallback} [args.mergeDriver] - a [merge driver](mergeDriver.md) implementation
2248
+ * @param {boolean} [args.allowUnrelatedHistories = false] - If true, allows merging histories of two branches that started their lives independently.
2248
2249
  *
2249
2250
  * @returns {Promise<MergeResult>} Resolves to a description of the merge operation
2250
2251
  * @see MergeResult
@@ -2259,7 +2260,7 @@ export function log({ fs, dir, gitdir, filepath, ref, depth, since, force, follo
2259
2260
  * console.log(m)
2260
2261
  *
2261
2262
  */
2262
- export function merge({ fs: _fs, onSign, dir, gitdir, ours, theirs, fastForward, fastForwardOnly, dryRun, noUpdateBranch, abortOnConflict, message, author: _author, committer: _committer, signingKey, cache, mergeDriver, }: {
2263
+ export function merge({ fs: _fs, onSign, dir, gitdir, ours, theirs, fastForward, fastForwardOnly, dryRun, noUpdateBranch, abortOnConflict, message, author: _author, committer: _committer, signingKey, cache, mergeDriver, allowUnrelatedHistories, }: {
2263
2264
  fs: FsClient;
2264
2265
  onSign?: SignCallback | undefined;
2265
2266
  dir?: string | undefined;
@@ -2287,6 +2288,7 @@ export function merge({ fs: _fs, onSign, dir, gitdir, ours, theirs, fastForward,
2287
2288
  signingKey?: string | undefined;
2288
2289
  cache?: object;
2289
2290
  mergeDriver?: MergeDriverCallback | undefined;
2291
+ allowUnrelatedHistories?: boolean | undefined;
2290
2292
  }): Promise<MergeResult>;
2291
2293
  /**
2292
2294
  *