isomorphic-git 1.14.0 → 1.15.2

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/README.md CHANGED
@@ -195,6 +195,7 @@ unless there is a major version bump.
195
195
  - [status](https://isomorphic-git.github.io/docs/status.html)
196
196
  - [statusMatrix](https://isomorphic-git.github.io/docs/statusMatrix.html)
197
197
  - [tag](https://isomorphic-git.github.io/docs/tag.html)
198
+ - [updateIndex](https://isomorphic-git.github.io/docs/updateIndex.html)
198
199
  - [version](https://isomorphic-git.github.io/docs/version.html)
199
200
  - [walk](https://isomorphic-git.github.io/docs/walk.html)
200
201
  - [writeBlob](https://isomorphic-git.github.io/docs/writeBlob.html)
@@ -1,8 +1,8 @@
1
1
  [
2
2
  "HeadlessChrome 0.0.0 (Linux 0.0.0)",
3
- "Firefox 97.0.0 (Ubuntu 0.0.0)",
3
+ "Firefox 98.0.0 (Ubuntu 0.0.0)",
4
4
  "Chrome Mobile 96.0.4664 (Android 0.0.0)",
5
5
  "Chrome 79.0.3945 (Windows 10 0.0.0)",
6
- "Safari 13.1.0 (Mac OS X 10.15.4)",
7
- "Mobile Safari 13.0.0 (iOS 13.0.0)"
6
+ "Mobile Safari 13.0.0 (iOS 13.0.0)",
7
+ "Safari 13.1.0 (Mac OS X 10.15.4)"
8
8
  ]
package/index.cjs CHANGED
@@ -762,6 +762,10 @@ class GitIndex {
762
762
  this._dirty = true;
763
763
  }
764
764
 
765
+ has({ filepath }) {
766
+ return this._entries.has(filepath)
767
+ }
768
+
765
769
  render() {
766
770
  return this.entries
767
771
  .map(entry => `${entry.mode.toString(8)} ${entry.oid} ${entry.path}`)
@@ -3119,12 +3123,14 @@ HttpError.code = 'HttpError';
3119
3123
 
3120
3124
  class InvalidFilepathError extends BaseError {
3121
3125
  /**
3122
- * @param {'leading-slash'|'trailing-slash'} [reason]
3126
+ * @param {'leading-slash'|'trailing-slash'|'directory'} [reason]
3123
3127
  */
3124
3128
  constructor(reason) {
3125
3129
  let message = 'invalid filepath';
3126
3130
  if (reason === 'leading-slash' || reason === 'trailing-slash') {
3127
3131
  message = `"filepath" parameter should not include leading or trailing directory separators because these can cause problems on some platforms.`;
3132
+ } else if (reason === 'directory') {
3133
+ message = `"filepath" should not be a directory.`;
3128
3134
  }
3129
3135
  super(message);
3130
3136
  this.code = this.name = InvalidFilepathError.code;
@@ -6912,8 +6918,8 @@ function filterCapabilities(server, client) {
6912
6918
 
6913
6919
  const pkg = {
6914
6920
  name: 'isomorphic-git',
6915
- version: '1.14.0',
6916
- agent: 'git/isomorphic-git@1.14.0',
6921
+ version: '1.15.2',
6922
+ agent: 'git/isomorphic-git@1.15.2',
6917
6923
  };
6918
6924
 
6919
6925
  class FIFO {
@@ -13489,6 +13495,169 @@ async function tag({
13489
13495
 
13490
13496
  // @ts-check
13491
13497
 
13498
+ /**
13499
+ * Register file contents in the working tree or object database to the git index (aka staging area).
13500
+ *
13501
+ * @param {object} args
13502
+ * @param {FsClient} args.fs - a file system client
13503
+ * @param {string} args.dir - The [working tree](dir-vs-gitdir.md) directory path
13504
+ * @param {string} [args.gitdir=join(dir, '.git')] - [required] The [git directory](dir-vs-gitdir.md) path
13505
+ * @param {string} args.filepath - File to act upon.
13506
+ * @param {string} [args.oid] - OID of the object in the object database to add to the index with the specified filepath.
13507
+ * @param {number} [args.mode = 100644] - The file mode to add the file to the index.
13508
+ * @param {boolean} [args.add] - Adds the specified file to the index if it does not yet exist in the index.
13509
+ * @param {boolean} [args.remove] - Remove the specified file from the index if it does not exist in the workspace anymore.
13510
+ * @param {boolean} [args.force] - Remove the specified file from the index, even if it still exists in the workspace.
13511
+ * @param {object} [args.cache] - a [cache](cache.md) object
13512
+ *
13513
+ * @returns {Promise<string | void>} Resolves successfully with the SHA-1 object id of the object written or updated in the index, or nothing if the file was removed.
13514
+ *
13515
+ * @example
13516
+ * await git.updateIndex({
13517
+ * fs,
13518
+ * dir: '/tutorial',
13519
+ * filepath: 'readme.md'
13520
+ * })
13521
+ *
13522
+ * @example
13523
+ * // Manually create a blob in the object database.
13524
+ * let oid = await git.writeBlob({
13525
+ * fs,
13526
+ * dir: '/tutorial',
13527
+ * blob: new Uint8Array([])
13528
+ * })
13529
+ *
13530
+ * // Write the object in the object database to the index.
13531
+ * await git.updateIndex({
13532
+ * fs,
13533
+ * dir: '/tutorial',
13534
+ * add: true,
13535
+ * filepath: 'readme.md',
13536
+ * oid
13537
+ * })
13538
+ */
13539
+ async function updateIndex({
13540
+ fs: _fs,
13541
+ dir,
13542
+ gitdir = join(dir, '.git'),
13543
+ cache = {},
13544
+ filepath,
13545
+ oid,
13546
+ mode,
13547
+ add,
13548
+ remove,
13549
+ force,
13550
+ }) {
13551
+ try {
13552
+ assertParameter('fs', _fs);
13553
+ assertParameter('gitdir', gitdir);
13554
+ assertParameter('filepath', filepath);
13555
+
13556
+ const fs = new FileSystem(_fs);
13557
+
13558
+ if (remove) {
13559
+ return await GitIndexManager.acquire(
13560
+ { fs, gitdir, cache },
13561
+ async function(index) {
13562
+ let fileStats;
13563
+
13564
+ if (!force) {
13565
+ // Check if the file is still present in the working directory
13566
+ fileStats = await fs.lstat(join(dir, filepath));
13567
+
13568
+ if (fileStats) {
13569
+ if (fileStats.isDirectory()) {
13570
+ // Removing directories should not work
13571
+ throw new InvalidFilepathError('directory')
13572
+ }
13573
+
13574
+ // Do nothing if we don't force and the file still exists in the workdir
13575
+ return
13576
+ }
13577
+ }
13578
+
13579
+ // Directories are not allowed, so we make sure the provided filepath exists in the index
13580
+ if (index.has({ filepath })) {
13581
+ index.delete({
13582
+ filepath,
13583
+ });
13584
+ }
13585
+ }
13586
+ )
13587
+ }
13588
+
13589
+ // Test if it is a file and exists on disk if `remove` is not provided, only of no oid is provided
13590
+ let fileStats;
13591
+
13592
+ if (!oid) {
13593
+ fileStats = await fs.lstat(join(dir, filepath));
13594
+
13595
+ if (!fileStats) {
13596
+ throw new NotFoundError(
13597
+ `file at "${filepath}" on disk and "remove" not set`
13598
+ )
13599
+ }
13600
+
13601
+ if (fileStats.isDirectory()) {
13602
+ throw new InvalidFilepathError('directory')
13603
+ }
13604
+ }
13605
+
13606
+ return await GitIndexManager.acquire({ fs, gitdir, cache }, async function(
13607
+ index
13608
+ ) {
13609
+ if (!add && !index.has({ filepath })) {
13610
+ // If the index does not contain the filepath yet and `add` is not set, we should throw
13611
+ throw new NotFoundError(
13612
+ `file at "${filepath}" in index and "add" not set`
13613
+ )
13614
+ }
13615
+
13616
+ // By default we use 0 for the stats of the index file
13617
+ let stats = {
13618
+ ctime: new Date(0),
13619
+ mtime: new Date(0),
13620
+ dev: 0,
13621
+ ino: 0,
13622
+ mode,
13623
+ uid: 0,
13624
+ gid: 0,
13625
+ size: 0,
13626
+ };
13627
+
13628
+ if (!oid) {
13629
+ stats = fileStats;
13630
+
13631
+ // Write the file to the object database
13632
+ const object = stats.isSymbolicLink()
13633
+ ? await fs.readlink(join(dir, filepath))
13634
+ : await fs.read(join(dir, filepath));
13635
+
13636
+ oid = await _writeObject({
13637
+ fs,
13638
+ gitdir,
13639
+ type: 'blob',
13640
+ format: 'content',
13641
+ object,
13642
+ });
13643
+ }
13644
+
13645
+ index.insert({
13646
+ filepath,
13647
+ oid: oid,
13648
+ stats,
13649
+ });
13650
+
13651
+ return oid
13652
+ })
13653
+ } catch (err) {
13654
+ err.caller = 'git.updateIndex';
13655
+ throw err
13656
+ }
13657
+ }
13658
+
13659
+ // @ts-check
13660
+
13492
13661
  /**
13493
13662
  * Return the version number of isomorphic-git
13494
13663
  *
@@ -14259,6 +14428,7 @@ var index = {
14259
14428
  removeNote,
14260
14429
  renameBranch,
14261
14430
  resetIndex,
14431
+ updateIndex,
14262
14432
  resolveRef,
14263
14433
  status,
14264
14434
  statusMatrix,
@@ -14332,6 +14502,7 @@ exports.setConfig = setConfig;
14332
14502
  exports.status = status;
14333
14503
  exports.statusMatrix = statusMatrix;
14334
14504
  exports.tag = tag;
14505
+ exports.updateIndex = updateIndex;
14335
14506
  exports.version = version;
14336
14507
  exports.walk = walk;
14337
14508
  exports.writeBlob = writeBlob;
package/index.d.ts CHANGED
@@ -685,6 +685,7 @@ declare namespace index {
685
685
  export { removeNote };
686
686
  export { renameBranch };
687
687
  export { resetIndex };
688
+ export { updateIndex };
688
689
  export { resolveRef };
689
690
  export { status };
690
691
  export { statusMatrix };
@@ -3107,6 +3108,59 @@ export function tag({ fs: _fs, dir, gitdir, ref, object, force, }: {
3107
3108
  object?: string;
3108
3109
  force?: boolean;
3109
3110
  }): Promise<void>;
3111
+ /**
3112
+ * Register file contents in the working tree or object database to the git index (aka staging area).
3113
+ *
3114
+ * @param {object} args
3115
+ * @param {FsClient} args.fs - a file system client
3116
+ * @param {string} args.dir - The [working tree](dir-vs-gitdir.md) directory path
3117
+ * @param {string} [args.gitdir=join(dir, '.git')] - [required] The [git directory](dir-vs-gitdir.md) path
3118
+ * @param {string} args.filepath - File to act upon.
3119
+ * @param {string} [args.oid] - OID of the object in the object database to add to the index with the specified filepath.
3120
+ * @param {number} [args.mode = 100644] - The file mode to add the file to the index.
3121
+ * @param {boolean} [args.add] - Adds the specified file to the index if it does not yet exist in the index.
3122
+ * @param {boolean} [args.remove] - Remove the specified file from the index if it does not exist in the workspace anymore.
3123
+ * @param {boolean} [args.force] - Remove the specified file from the index, even if it still exists in the workspace.
3124
+ * @param {object} [args.cache] - a [cache](cache.md) object
3125
+ *
3126
+ * @returns {Promise<string | void>} Resolves successfully with the SHA-1 object id of the object written or updated in the index, or nothing if the file was removed.
3127
+ *
3128
+ * @example
3129
+ * await git.updateIndex({
3130
+ * fs,
3131
+ * dir: '/tutorial',
3132
+ * filepath: 'readme.md'
3133
+ * })
3134
+ *
3135
+ * @example
3136
+ * // Manually create a blob in the object database.
3137
+ * let oid = await git.writeBlob({
3138
+ * fs,
3139
+ * dir: '/tutorial',
3140
+ * blob: new Uint8Array([])
3141
+ * })
3142
+ *
3143
+ * // Write the object in the object database to the index.
3144
+ * await git.updateIndex({
3145
+ * fs,
3146
+ * dir: '/tutorial',
3147
+ * add: true,
3148
+ * filepath: 'readme.md',
3149
+ * oid
3150
+ * })
3151
+ */
3152
+ export function updateIndex({ fs: _fs, dir, gitdir, cache, filepath, oid, mode, add, remove, force, }: {
3153
+ fs: CallbackFsClient | PromiseFsClient;
3154
+ dir: string;
3155
+ gitdir?: string;
3156
+ filepath: string;
3157
+ oid?: string;
3158
+ mode?: number;
3159
+ add?: boolean;
3160
+ remove?: boolean;
3161
+ force?: boolean;
3162
+ cache?: any;
3163
+ }): Promise<string | void>;
3110
3164
  /**
3111
3165
  * Return the version number of isomorphic-git
3112
3166
  *
@@ -3735,13 +3789,13 @@ declare namespace InternalError {
3735
3789
  }
3736
3790
  declare class InvalidFilepathError extends BaseError {
3737
3791
  /**
3738
- * @param {'leading-slash'|'trailing-slash'} [reason]
3792
+ * @param {'leading-slash'|'trailing-slash'|'directory'} [reason]
3739
3793
  */
3740
- constructor(reason?: "leading-slash" | "trailing-slash" | undefined);
3794
+ constructor(reason?: "leading-slash" | "trailing-slash" | "directory" | undefined);
3741
3795
  code: "InvalidFilepathError";
3742
3796
  name: "InvalidFilepathError";
3743
3797
  data: {
3744
- reason: "leading-slash" | "trailing-slash" | undefined;
3798
+ reason: "leading-slash" | "trailing-slash" | "directory" | undefined;
3745
3799
  };
3746
3800
  }
3747
3801
  declare namespace InvalidFilepathError {
package/index.js CHANGED
@@ -756,6 +756,10 @@ class GitIndex {
756
756
  this._dirty = true;
757
757
  }
758
758
 
759
+ has({ filepath }) {
760
+ return this._entries.has(filepath)
761
+ }
762
+
759
763
  render() {
760
764
  return this.entries
761
765
  .map(entry => `${entry.mode.toString(8)} ${entry.oid} ${entry.path}`)
@@ -3113,12 +3117,14 @@ HttpError.code = 'HttpError';
3113
3117
 
3114
3118
  class InvalidFilepathError extends BaseError {
3115
3119
  /**
3116
- * @param {'leading-slash'|'trailing-slash'} [reason]
3120
+ * @param {'leading-slash'|'trailing-slash'|'directory'} [reason]
3117
3121
  */
3118
3122
  constructor(reason) {
3119
3123
  let message = 'invalid filepath';
3120
3124
  if (reason === 'leading-slash' || reason === 'trailing-slash') {
3121
3125
  message = `"filepath" parameter should not include leading or trailing directory separators because these can cause problems on some platforms.`;
3126
+ } else if (reason === 'directory') {
3127
+ message = `"filepath" should not be a directory.`;
3122
3128
  }
3123
3129
  super(message);
3124
3130
  this.code = this.name = InvalidFilepathError.code;
@@ -6906,8 +6912,8 @@ function filterCapabilities(server, client) {
6906
6912
 
6907
6913
  const pkg = {
6908
6914
  name: 'isomorphic-git',
6909
- version: '1.14.0',
6910
- agent: 'git/isomorphic-git@1.14.0',
6915
+ version: '1.15.2',
6916
+ agent: 'git/isomorphic-git@1.15.2',
6911
6917
  };
6912
6918
 
6913
6919
  class FIFO {
@@ -13483,6 +13489,169 @@ async function tag({
13483
13489
 
13484
13490
  // @ts-check
13485
13491
 
13492
+ /**
13493
+ * Register file contents in the working tree or object database to the git index (aka staging area).
13494
+ *
13495
+ * @param {object} args
13496
+ * @param {FsClient} args.fs - a file system client
13497
+ * @param {string} args.dir - The [working tree](dir-vs-gitdir.md) directory path
13498
+ * @param {string} [args.gitdir=join(dir, '.git')] - [required] The [git directory](dir-vs-gitdir.md) path
13499
+ * @param {string} args.filepath - File to act upon.
13500
+ * @param {string} [args.oid] - OID of the object in the object database to add to the index with the specified filepath.
13501
+ * @param {number} [args.mode = 100644] - The file mode to add the file to the index.
13502
+ * @param {boolean} [args.add] - Adds the specified file to the index if it does not yet exist in the index.
13503
+ * @param {boolean} [args.remove] - Remove the specified file from the index if it does not exist in the workspace anymore.
13504
+ * @param {boolean} [args.force] - Remove the specified file from the index, even if it still exists in the workspace.
13505
+ * @param {object} [args.cache] - a [cache](cache.md) object
13506
+ *
13507
+ * @returns {Promise<string | void>} Resolves successfully with the SHA-1 object id of the object written or updated in the index, or nothing if the file was removed.
13508
+ *
13509
+ * @example
13510
+ * await git.updateIndex({
13511
+ * fs,
13512
+ * dir: '/tutorial',
13513
+ * filepath: 'readme.md'
13514
+ * })
13515
+ *
13516
+ * @example
13517
+ * // Manually create a blob in the object database.
13518
+ * let oid = await git.writeBlob({
13519
+ * fs,
13520
+ * dir: '/tutorial',
13521
+ * blob: new Uint8Array([])
13522
+ * })
13523
+ *
13524
+ * // Write the object in the object database to the index.
13525
+ * await git.updateIndex({
13526
+ * fs,
13527
+ * dir: '/tutorial',
13528
+ * add: true,
13529
+ * filepath: 'readme.md',
13530
+ * oid
13531
+ * })
13532
+ */
13533
+ async function updateIndex({
13534
+ fs: _fs,
13535
+ dir,
13536
+ gitdir = join(dir, '.git'),
13537
+ cache = {},
13538
+ filepath,
13539
+ oid,
13540
+ mode,
13541
+ add,
13542
+ remove,
13543
+ force,
13544
+ }) {
13545
+ try {
13546
+ assertParameter('fs', _fs);
13547
+ assertParameter('gitdir', gitdir);
13548
+ assertParameter('filepath', filepath);
13549
+
13550
+ const fs = new FileSystem(_fs);
13551
+
13552
+ if (remove) {
13553
+ return await GitIndexManager.acquire(
13554
+ { fs, gitdir, cache },
13555
+ async function(index) {
13556
+ let fileStats;
13557
+
13558
+ if (!force) {
13559
+ // Check if the file is still present in the working directory
13560
+ fileStats = await fs.lstat(join(dir, filepath));
13561
+
13562
+ if (fileStats) {
13563
+ if (fileStats.isDirectory()) {
13564
+ // Removing directories should not work
13565
+ throw new InvalidFilepathError('directory')
13566
+ }
13567
+
13568
+ // Do nothing if we don't force and the file still exists in the workdir
13569
+ return
13570
+ }
13571
+ }
13572
+
13573
+ // Directories are not allowed, so we make sure the provided filepath exists in the index
13574
+ if (index.has({ filepath })) {
13575
+ index.delete({
13576
+ filepath,
13577
+ });
13578
+ }
13579
+ }
13580
+ )
13581
+ }
13582
+
13583
+ // Test if it is a file and exists on disk if `remove` is not provided, only of no oid is provided
13584
+ let fileStats;
13585
+
13586
+ if (!oid) {
13587
+ fileStats = await fs.lstat(join(dir, filepath));
13588
+
13589
+ if (!fileStats) {
13590
+ throw new NotFoundError(
13591
+ `file at "${filepath}" on disk and "remove" not set`
13592
+ )
13593
+ }
13594
+
13595
+ if (fileStats.isDirectory()) {
13596
+ throw new InvalidFilepathError('directory')
13597
+ }
13598
+ }
13599
+
13600
+ return await GitIndexManager.acquire({ fs, gitdir, cache }, async function(
13601
+ index
13602
+ ) {
13603
+ if (!add && !index.has({ filepath })) {
13604
+ // If the index does not contain the filepath yet and `add` is not set, we should throw
13605
+ throw new NotFoundError(
13606
+ `file at "${filepath}" in index and "add" not set`
13607
+ )
13608
+ }
13609
+
13610
+ // By default we use 0 for the stats of the index file
13611
+ let stats = {
13612
+ ctime: new Date(0),
13613
+ mtime: new Date(0),
13614
+ dev: 0,
13615
+ ino: 0,
13616
+ mode,
13617
+ uid: 0,
13618
+ gid: 0,
13619
+ size: 0,
13620
+ };
13621
+
13622
+ if (!oid) {
13623
+ stats = fileStats;
13624
+
13625
+ // Write the file to the object database
13626
+ const object = stats.isSymbolicLink()
13627
+ ? await fs.readlink(join(dir, filepath))
13628
+ : await fs.read(join(dir, filepath));
13629
+
13630
+ oid = await _writeObject({
13631
+ fs,
13632
+ gitdir,
13633
+ type: 'blob',
13634
+ format: 'content',
13635
+ object,
13636
+ });
13637
+ }
13638
+
13639
+ index.insert({
13640
+ filepath,
13641
+ oid: oid,
13642
+ stats,
13643
+ });
13644
+
13645
+ return oid
13646
+ })
13647
+ } catch (err) {
13648
+ err.caller = 'git.updateIndex';
13649
+ throw err
13650
+ }
13651
+ }
13652
+
13653
+ // @ts-check
13654
+
13486
13655
  /**
13487
13656
  * Return the version number of isomorphic-git
13488
13657
  *
@@ -14253,6 +14422,7 @@ var index = {
14253
14422
  removeNote,
14254
14423
  renameBranch,
14255
14424
  resetIndex,
14425
+ updateIndex,
14256
14426
  resolveRef,
14257
14427
  status,
14258
14428
  statusMatrix,
@@ -14268,4 +14438,4 @@ var index = {
14268
14438
  };
14269
14439
 
14270
14440
  export default index;
14271
- export { Errors, STAGE, TREE, WORKDIR, add, addNote, addRemote, annotatedTag, branch, checkout, clone, commit, currentBranch, deleteBranch, deleteRef, deleteRemote, deleteTag, expandOid, expandRef, fastForward, fetch, findMergeBase, findRoot, getConfig, getConfigAll, getRemoteInfo, getRemoteInfo2, hashBlob, indexPack, init, isDescendent, isIgnored, listBranches, listFiles, listNotes, listRemotes, listServerRefs, listTags, log, merge, packObjects, pull, push, readBlob, readCommit, readNote, readObject, readTag, readTree, remove, removeNote, renameBranch, resetIndex, resolveRef, setConfig, status, statusMatrix, tag, version, walk, writeBlob, writeCommit, writeObject, writeRef, writeTag, writeTree };
14441
+ export { Errors, STAGE, TREE, WORKDIR, add, addNote, addRemote, annotatedTag, branch, checkout, clone, commit, currentBranch, deleteBranch, deleteRef, deleteRemote, deleteTag, expandOid, expandRef, fastForward, fetch, findMergeBase, findRoot, getConfig, getConfigAll, getRemoteInfo, getRemoteInfo2, hashBlob, indexPack, init, isDescendent, isIgnored, listBranches, listFiles, listNotes, listRemotes, listServerRefs, listTags, log, merge, packObjects, pull, push, readBlob, readCommit, readNote, readObject, readTag, readTree, remove, removeNote, renameBranch, resetIndex, resolveRef, setConfig, status, statusMatrix, tag, updateIndex, version, walk, writeBlob, writeCommit, writeObject, writeRef, writeTag, writeTree };
@@ -685,6 +685,7 @@ declare namespace index {
685
685
  export { removeNote };
686
686
  export { renameBranch };
687
687
  export { resetIndex };
688
+ export { updateIndex };
688
689
  export { resolveRef };
689
690
  export { status };
690
691
  export { statusMatrix };
@@ -3107,6 +3108,59 @@ export function tag({ fs: _fs, dir, gitdir, ref, object, force, }: {
3107
3108
  object?: string;
3108
3109
  force?: boolean;
3109
3110
  }): Promise<void>;
3111
+ /**
3112
+ * Register file contents in the working tree or object database to the git index (aka staging area).
3113
+ *
3114
+ * @param {object} args
3115
+ * @param {FsClient} args.fs - a file system client
3116
+ * @param {string} args.dir - The [working tree](dir-vs-gitdir.md) directory path
3117
+ * @param {string} [args.gitdir=join(dir, '.git')] - [required] The [git directory](dir-vs-gitdir.md) path
3118
+ * @param {string} args.filepath - File to act upon.
3119
+ * @param {string} [args.oid] - OID of the object in the object database to add to the index with the specified filepath.
3120
+ * @param {number} [args.mode = 100644] - The file mode to add the file to the index.
3121
+ * @param {boolean} [args.add] - Adds the specified file to the index if it does not yet exist in the index.
3122
+ * @param {boolean} [args.remove] - Remove the specified file from the index if it does not exist in the workspace anymore.
3123
+ * @param {boolean} [args.force] - Remove the specified file from the index, even if it still exists in the workspace.
3124
+ * @param {object} [args.cache] - a [cache](cache.md) object
3125
+ *
3126
+ * @returns {Promise<string | void>} Resolves successfully with the SHA-1 object id of the object written or updated in the index, or nothing if the file was removed.
3127
+ *
3128
+ * @example
3129
+ * await git.updateIndex({
3130
+ * fs,
3131
+ * dir: '/tutorial',
3132
+ * filepath: 'readme.md'
3133
+ * })
3134
+ *
3135
+ * @example
3136
+ * // Manually create a blob in the object database.
3137
+ * let oid = await git.writeBlob({
3138
+ * fs,
3139
+ * dir: '/tutorial',
3140
+ * blob: new Uint8Array([])
3141
+ * })
3142
+ *
3143
+ * // Write the object in the object database to the index.
3144
+ * await git.updateIndex({
3145
+ * fs,
3146
+ * dir: '/tutorial',
3147
+ * add: true,
3148
+ * filepath: 'readme.md',
3149
+ * oid
3150
+ * })
3151
+ */
3152
+ export function updateIndex({ fs: _fs, dir, gitdir, cache, filepath, oid, mode, add, remove, force, }: {
3153
+ fs: CallbackFsClient | PromiseFsClient;
3154
+ dir: string;
3155
+ gitdir?: string;
3156
+ filepath: string;
3157
+ oid?: string;
3158
+ mode?: number;
3159
+ add?: boolean;
3160
+ remove?: boolean;
3161
+ force?: boolean;
3162
+ cache?: any;
3163
+ }): Promise<string | void>;
3110
3164
  /**
3111
3165
  * Return the version number of isomorphic-git
3112
3166
  *
@@ -3735,13 +3789,13 @@ declare namespace InternalError {
3735
3789
  }
3736
3790
  declare class InvalidFilepathError extends BaseError {
3737
3791
  /**
3738
- * @param {'leading-slash'|'trailing-slash'} [reason]
3792
+ * @param {'leading-slash'|'trailing-slash'|'directory'} [reason]
3739
3793
  */
3740
- constructor(reason?: "leading-slash" | "trailing-slash" | undefined);
3794
+ constructor(reason?: "leading-slash" | "trailing-slash" | "directory" | undefined);
3741
3795
  code: "InvalidFilepathError";
3742
3796
  name: "InvalidFilepathError";
3743
3797
  data: {
3744
- reason: "leading-slash" | "trailing-slash" | undefined;
3798
+ reason: "leading-slash" | "trailing-slash" | "directory" | undefined;
3745
3799
  };
3746
3800
  }
3747
3801
  declare namespace InvalidFilepathError {