isomorphic-git 1.31.1 → 1.32.1

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,8 @@
1
1
  [
2
2
  "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)",
6
- "Safari 14.1 (Mac OS 10.15.7)",
7
- "Mobile Safari 14.0 (iOS 14.0.1)"
5
+ "Edge 79.0.309.65 (Windows 10)",
6
+ "Mobile Safari 14.0 (iOS 14.0.1)",
7
+ "Safari 14.1 (Mac OS 10.15.7)"
8
8
  ]
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.1',
7780
+ agent: 'git/isomorphic-git@1.32.1',
7781
7781
  };
7782
7782
 
7783
7783
  class FIFO {
@@ -9437,13 +9437,26 @@ async function mergeTree({
9437
9437
  : undefined
9438
9438
  }
9439
9439
  case 'true-true': {
9440
- // Modifications
9440
+ // Handle tree-tree merges (directories)
9441
+ if (
9442
+ ours &&
9443
+ theirs &&
9444
+ (await ours.type()) === 'tree' &&
9445
+ (await theirs.type()) === 'tree'
9446
+ ) {
9447
+ return {
9448
+ mode: await ours.mode(),
9449
+ path,
9450
+ oid: await ours.oid(),
9451
+ type: 'tree',
9452
+ }
9453
+ }
9454
+
9455
+ // Modifications - both are blobs
9441
9456
  if (
9442
9457
  ours &&
9443
- base &&
9444
9458
  theirs &&
9445
9459
  (await ours.type()) === 'blob' &&
9446
- (await base.type()) === 'blob' &&
9447
9460
  (await theirs.type()) === 'blob'
9448
9461
  ) {
9449
9462
  return mergeBlobs({
@@ -9462,13 +9475,18 @@ async function mergeTree({
9462
9475
  unmergedFiles.push(filepath);
9463
9476
  bothModified.push(filepath);
9464
9477
  if (!abortOnConflict) {
9465
- const baseOid = await base.oid();
9478
+ let baseOid = '';
9479
+ if (base && (await base.type()) === 'blob') {
9480
+ baseOid = await base.oid();
9481
+ }
9466
9482
  const ourOid = await ours.oid();
9467
9483
  const theirOid = await theirs.oid();
9468
9484
 
9469
9485
  index.delete({ filepath });
9470
9486
 
9471
- index.insert({ filepath, oid: baseOid, stage: 1 });
9487
+ if (baseOid) {
9488
+ index.insert({ filepath, oid: baseOid, stage: 1 });
9489
+ }
9472
9490
  index.insert({ filepath, oid: ourOid, stage: 2 });
9473
9491
  index.insert({ filepath, oid: theirOid, stage: 3 });
9474
9492
  }
@@ -9655,10 +9673,16 @@ async function mergeBlobs({
9655
9673
  const type = 'blob';
9656
9674
  // Compute the new mode.
9657
9675
  // Since there are ONLY two valid blob modes ('100755' and '100644') it boils down to this
9676
+ let baseMode = '100755';
9677
+ let baseOid = '';
9678
+ let baseContent = '';
9679
+ if (base && (await base.type()) === 'blob') {
9680
+ baseMode = await base.mode();
9681
+ baseOid = await base.oid();
9682
+ baseContent = Buffer.from(await base.content()).toString('utf8');
9683
+ }
9658
9684
  const mode =
9659
- (await base.mode()) === (await ours.mode())
9660
- ? await theirs.mode()
9661
- : await ours.mode();
9685
+ baseMode === (await ours.mode()) ? await theirs.mode() : await ours.mode();
9662
9686
  // The trivial case: nothing to merge except maybe mode
9663
9687
  if ((await ours.oid()) === (await theirs.oid())) {
9664
9688
  return {
@@ -9667,13 +9691,13 @@ async function mergeBlobs({
9667
9691
  }
9668
9692
  }
9669
9693
  // if only one side made oid changes, return that side's oid
9670
- if ((await ours.oid()) === (await base.oid())) {
9694
+ if ((await ours.oid()) === baseOid) {
9671
9695
  return {
9672
9696
  cleanMerge: true,
9673
9697
  mergeResult: { mode, path, oid: await theirs.oid(), type },
9674
9698
  }
9675
9699
  }
9676
- if ((await theirs.oid()) === (await base.oid())) {
9700
+ if ((await theirs.oid()) === baseOid) {
9677
9701
  return {
9678
9702
  cleanMerge: true,
9679
9703
  mergeResult: { mode, path, oid: await ours.oid(), type },
@@ -9681,7 +9705,6 @@ async function mergeBlobs({
9681
9705
  }
9682
9706
  // if both sides made changes do a merge
9683
9707
  const ourContent = Buffer.from(await ours.content()).toString('utf8');
9684
- const baseContent = Buffer.from(await base.content()).toString('utf8');
9685
9708
  const theirContent = Buffer.from(await theirs.content()).toString('utf8');
9686
9709
  const { mergedText, cleanMerge } = await mergeDriver({
9687
9710
  branches: [baseName, ourName, theirName],
@@ -9739,6 +9762,7 @@ async function mergeBlobs({
9739
9762
  * @param {string} [args.signingKey]
9740
9763
  * @param {SignCallback} [args.onSign] - a PGP signing implementation
9741
9764
  * @param {MergeDriverCallback} [args.mergeDriver]
9765
+ * @param {boolean} args.allowUnrelatedHistories
9742
9766
  *
9743
9767
  * @returns {Promise<MergeResult>} Resolves to a description of the merge operation
9744
9768
  *
@@ -9761,6 +9785,7 @@ async function _merge({
9761
9785
  signingKey,
9762
9786
  onSign,
9763
9787
  mergeDriver,
9788
+ allowUnrelatedHistories = false,
9764
9789
  }) {
9765
9790
  if (ours === undefined) {
9766
9791
  ours = await _currentBranch({ fs, gitdir, fullname: true });
@@ -9793,8 +9818,13 @@ async function _merge({
9793
9818
  oids: [ourOid, theirOid],
9794
9819
  });
9795
9820
  if (baseOids.length !== 1) {
9796
- // TODO: Recursive Merge strategy
9797
- throw new MergeNotSupportedError()
9821
+ if (baseOids.length === 0 && allowUnrelatedHistories) {
9822
+ // 4b825… == the empty tree used by git
9823
+ baseOids.push('4b825dc642cb6eb9a060e54bf8d69288fbee4904');
9824
+ } else {
9825
+ // TODO: Recursive Merge strategy
9826
+ throw new MergeNotSupportedError()
9827
+ }
9798
9828
  }
9799
9829
  const baseOid = baseOids[0];
9800
9830
  // handle fast-forward case
@@ -12017,6 +12047,7 @@ async function log({
12017
12047
  * @param {string} [args.signingKey] - passed to [commit](commit.md) when creating a merge commit
12018
12048
  * @param {object} [args.cache] - a [cache](cache.md) object
12019
12049
  * @param {MergeDriverCallback} [args.mergeDriver] - a [merge driver](mergeDriver.md) implementation
12050
+ * @param {boolean} [args.allowUnrelatedHistories = false] - If true, allows merging histories of two branches that started their lives independently.
12020
12051
  *
12021
12052
  * @returns {Promise<MergeResult>} Resolves to a description of the merge operation
12022
12053
  * @see MergeResult
@@ -12049,6 +12080,7 @@ async function merge({
12049
12080
  signingKey,
12050
12081
  cache = {},
12051
12082
  mergeDriver,
12083
+ allowUnrelatedHistories = false,
12052
12084
  }) {
12053
12085
  try {
12054
12086
  assertParameter('fs', _fs);
@@ -12090,6 +12122,7 @@ async function merge({
12090
12122
  signingKey,
12091
12123
  onSign,
12092
12124
  mergeDriver,
12125
+ allowUnrelatedHistories,
12093
12126
  })
12094
12127
  } catch (err) {
12095
12128
  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.1',
7774
+ agent: 'git/isomorphic-git@1.32.1',
7775
7775
  };
7776
7776
 
7777
7777
  class FIFO {
@@ -9431,13 +9431,26 @@ async function mergeTree({
9431
9431
  : undefined
9432
9432
  }
9433
9433
  case 'true-true': {
9434
- // Modifications
9434
+ // Handle tree-tree merges (directories)
9435
+ if (
9436
+ ours &&
9437
+ theirs &&
9438
+ (await ours.type()) === 'tree' &&
9439
+ (await theirs.type()) === 'tree'
9440
+ ) {
9441
+ return {
9442
+ mode: await ours.mode(),
9443
+ path,
9444
+ oid: await ours.oid(),
9445
+ type: 'tree',
9446
+ }
9447
+ }
9448
+
9449
+ // Modifications - both are blobs
9435
9450
  if (
9436
9451
  ours &&
9437
- base &&
9438
9452
  theirs &&
9439
9453
  (await ours.type()) === 'blob' &&
9440
- (await base.type()) === 'blob' &&
9441
9454
  (await theirs.type()) === 'blob'
9442
9455
  ) {
9443
9456
  return mergeBlobs({
@@ -9456,13 +9469,18 @@ async function mergeTree({
9456
9469
  unmergedFiles.push(filepath);
9457
9470
  bothModified.push(filepath);
9458
9471
  if (!abortOnConflict) {
9459
- const baseOid = await base.oid();
9472
+ let baseOid = '';
9473
+ if (base && (await base.type()) === 'blob') {
9474
+ baseOid = await base.oid();
9475
+ }
9460
9476
  const ourOid = await ours.oid();
9461
9477
  const theirOid = await theirs.oid();
9462
9478
 
9463
9479
  index.delete({ filepath });
9464
9480
 
9465
- index.insert({ filepath, oid: baseOid, stage: 1 });
9481
+ if (baseOid) {
9482
+ index.insert({ filepath, oid: baseOid, stage: 1 });
9483
+ }
9466
9484
  index.insert({ filepath, oid: ourOid, stage: 2 });
9467
9485
  index.insert({ filepath, oid: theirOid, stage: 3 });
9468
9486
  }
@@ -9649,10 +9667,16 @@ async function mergeBlobs({
9649
9667
  const type = 'blob';
9650
9668
  // Compute the new mode.
9651
9669
  // Since there are ONLY two valid blob modes ('100755' and '100644') it boils down to this
9670
+ let baseMode = '100755';
9671
+ let baseOid = '';
9672
+ let baseContent = '';
9673
+ if (base && (await base.type()) === 'blob') {
9674
+ baseMode = await base.mode();
9675
+ baseOid = await base.oid();
9676
+ baseContent = Buffer.from(await base.content()).toString('utf8');
9677
+ }
9652
9678
  const mode =
9653
- (await base.mode()) === (await ours.mode())
9654
- ? await theirs.mode()
9655
- : await ours.mode();
9679
+ baseMode === (await ours.mode()) ? await theirs.mode() : await ours.mode();
9656
9680
  // The trivial case: nothing to merge except maybe mode
9657
9681
  if ((await ours.oid()) === (await theirs.oid())) {
9658
9682
  return {
@@ -9661,13 +9685,13 @@ async function mergeBlobs({
9661
9685
  }
9662
9686
  }
9663
9687
  // if only one side made oid changes, return that side's oid
9664
- if ((await ours.oid()) === (await base.oid())) {
9688
+ if ((await ours.oid()) === baseOid) {
9665
9689
  return {
9666
9690
  cleanMerge: true,
9667
9691
  mergeResult: { mode, path, oid: await theirs.oid(), type },
9668
9692
  }
9669
9693
  }
9670
- if ((await theirs.oid()) === (await base.oid())) {
9694
+ if ((await theirs.oid()) === baseOid) {
9671
9695
  return {
9672
9696
  cleanMerge: true,
9673
9697
  mergeResult: { mode, path, oid: await ours.oid(), type },
@@ -9675,7 +9699,6 @@ async function mergeBlobs({
9675
9699
  }
9676
9700
  // if both sides made changes do a merge
9677
9701
  const ourContent = Buffer.from(await ours.content()).toString('utf8');
9678
- const baseContent = Buffer.from(await base.content()).toString('utf8');
9679
9702
  const theirContent = Buffer.from(await theirs.content()).toString('utf8');
9680
9703
  const { mergedText, cleanMerge } = await mergeDriver({
9681
9704
  branches: [baseName, ourName, theirName],
@@ -9733,6 +9756,7 @@ async function mergeBlobs({
9733
9756
  * @param {string} [args.signingKey]
9734
9757
  * @param {SignCallback} [args.onSign] - a PGP signing implementation
9735
9758
  * @param {MergeDriverCallback} [args.mergeDriver]
9759
+ * @param {boolean} args.allowUnrelatedHistories
9736
9760
  *
9737
9761
  * @returns {Promise<MergeResult>} Resolves to a description of the merge operation
9738
9762
  *
@@ -9755,6 +9779,7 @@ async function _merge({
9755
9779
  signingKey,
9756
9780
  onSign,
9757
9781
  mergeDriver,
9782
+ allowUnrelatedHistories = false,
9758
9783
  }) {
9759
9784
  if (ours === undefined) {
9760
9785
  ours = await _currentBranch({ fs, gitdir, fullname: true });
@@ -9787,8 +9812,13 @@ async function _merge({
9787
9812
  oids: [ourOid, theirOid],
9788
9813
  });
9789
9814
  if (baseOids.length !== 1) {
9790
- // TODO: Recursive Merge strategy
9791
- throw new MergeNotSupportedError()
9815
+ if (baseOids.length === 0 && allowUnrelatedHistories) {
9816
+ // 4b825… == the empty tree used by git
9817
+ baseOids.push('4b825dc642cb6eb9a060e54bf8d69288fbee4904');
9818
+ } else {
9819
+ // TODO: Recursive Merge strategy
9820
+ throw new MergeNotSupportedError()
9821
+ }
9792
9822
  }
9793
9823
  const baseOid = baseOids[0];
9794
9824
  // handle fast-forward case
@@ -12011,6 +12041,7 @@ async function log({
12011
12041
  * @param {string} [args.signingKey] - passed to [commit](commit.md) when creating a merge commit
12012
12042
  * @param {object} [args.cache] - a [cache](cache.md) object
12013
12043
  * @param {MergeDriverCallback} [args.mergeDriver] - a [merge driver](mergeDriver.md) implementation
12044
+ * @param {boolean} [args.allowUnrelatedHistories = false] - If true, allows merging histories of two branches that started their lives independently.
12014
12045
  *
12015
12046
  * @returns {Promise<MergeResult>} Resolves to a description of the merge operation
12016
12047
  * @see MergeResult
@@ -12043,6 +12074,7 @@ async function merge({
12043
12074
  signingKey,
12044
12075
  cache = {},
12045
12076
  mergeDriver,
12077
+ allowUnrelatedHistories = false,
12046
12078
  }) {
12047
12079
  try {
12048
12080
  assertParameter('fs', _fs);
@@ -12084,6 +12116,7 @@ async function merge({
12084
12116
  signingKey,
12085
12117
  onSign,
12086
12118
  mergeDriver,
12119
+ allowUnrelatedHistories,
12087
12120
  })
12088
12121
  } catch (err) {
12089
12122
  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
  *