isomorphic-git 1.25.9 → 1.26.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.
package/index.cjs CHANGED
@@ -6,6 +6,7 @@ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'defau
6
6
 
7
7
  var AsyncLock = _interopDefault(require('async-lock'));
8
8
  var Hash = _interopDefault(require('sha.js/sha1.js'));
9
+ var path = require('path');
9
10
  var crc32 = _interopDefault(require('crc-32'));
10
11
  var pako = _interopDefault(require('pako'));
11
12
  var pify = _interopDefault(require('pify'));
@@ -309,6 +310,39 @@ var diff3Merge = _interopDefault(require('diff3'));
309
310
  * @typedef {[string, HeadStatus, WorkdirStatus, StageStatus]} StatusRow
310
311
  */
311
312
 
313
+ /**
314
+ * @typedef {Object} ClientRef
315
+ * @property {string} ref The name of the ref
316
+ * @property {string} oid The SHA-1 object id the ref points to
317
+ */
318
+
319
+ /**
320
+ * @typedef {Object} PrePushParams
321
+ * @property {string} remote The expanded name of target remote
322
+ * @property {string} url The URL address of target remote
323
+ * @property {ClientRef} localRef The ref which the client wants to push to the remote
324
+ * @property {ClientRef} remoteRef The ref which is known by the remote
325
+ */
326
+
327
+ /**
328
+ * @callback PrePushCallback
329
+ * @param {PrePushParams} args
330
+ * @returns {boolean | Promise<boolean>} Returns false if push must be cancelled
331
+ */
332
+
333
+ /**
334
+ * @typedef {Object} PostCheckoutParams
335
+ * @property {string} previousHead The SHA-1 object id of HEAD before checkout
336
+ * @property {string} newHead The SHA-1 object id of HEAD after checkout
337
+ * @property {'branch' | 'file'} type flag determining whether a branch or a set of files was checked
338
+ */
339
+
340
+ /**
341
+ * @callback PostCheckoutCallback
342
+ * @param {PostCheckoutParams} args
343
+ * @returns {void | Promise<void>}
344
+ */
345
+
312
346
  class BaseError extends Error {
313
347
  constructor(message) {
314
348
  super(message);
@@ -1448,40 +1482,6 @@ function compareRefNames(a, b) {
1448
1482
  return tmp
1449
1483
  }
1450
1484
 
1451
- const memo = new Map();
1452
- function normalizePath(path) {
1453
- let normalizedPath = memo.get(path);
1454
- if (!normalizedPath) {
1455
- normalizedPath = normalizePathInternal(path);
1456
- memo.set(path, normalizedPath);
1457
- }
1458
- return normalizedPath
1459
- }
1460
-
1461
- function normalizePathInternal(path) {
1462
- path = path
1463
- .split('/./')
1464
- .join('/') // Replace '/./' with '/'
1465
- .replace(/\/{2,}/g, '/'); // Replace consecutive '/'
1466
-
1467
- if (path === '/.') return '/' // if path === '/.' return '/'
1468
- if (path === './') return '.' // if path === './' return '.'
1469
-
1470
- if (path.startsWith('./')) path = path.slice(2); // Remove leading './'
1471
- if (path.endsWith('/.')) path = path.slice(0, -2); // Remove trailing '/.'
1472
- if (path.length > 1 && path.endsWith('/')) path = path.slice(0, -1); // Remove trailing '/'
1473
-
1474
- if (path === '') return '.' // if path === '' return '.'
1475
-
1476
- return path
1477
- }
1478
-
1479
- // For some reason path.posix.join is undefined in webpack
1480
-
1481
- function join(...parts) {
1482
- return normalizePath(parts.map(normalizePath).join('/'))
1483
- }
1484
-
1485
1485
  // This is straight from parse_unit_factor in config.c of canonical git
1486
1486
  const num = val => {
1487
1487
  val = val.toLowerCase();
@@ -1596,7 +1596,7 @@ const getPath = (section, subsection, name) => {
1596
1596
  .join('.')
1597
1597
  };
1598
1598
 
1599
- const normalizePath$1 = path => {
1599
+ const normalizePath = path => {
1600
1600
  const pathSegments = path.split('.');
1601
1601
  const section = pathSegments.shift();
1602
1602
  const name = pathSegments.pop();
@@ -1652,7 +1652,7 @@ class GitConfig {
1652
1652
  }
1653
1653
 
1654
1654
  async get(path, getall = false) {
1655
- const normalizedPath = normalizePath$1(path).path;
1655
+ const normalizedPath = normalizePath(path).path;
1656
1656
  const allValues = this.parsedConfig
1657
1657
  .filter(config => config.path === normalizedPath)
1658
1658
  .map(({ section, name, value }) => {
@@ -1690,7 +1690,7 @@ class GitConfig {
1690
1690
  name,
1691
1691
  path: normalizedPath,
1692
1692
  sectionPath,
1693
- } = normalizePath$1(path);
1693
+ } = normalizePath(path);
1694
1694
  const configIndex = findLastIndex(
1695
1695
  this.parsedConfig,
1696
1696
  config => config.path === normalizedPath
@@ -1912,7 +1912,7 @@ class GitRefManager {
1912
1912
  // and .git/refs/remotes/origin/refs/merge-requests
1913
1913
  for (const [key, value] of actualRefsToWrite) {
1914
1914
  await acquireLock(key, async () =>
1915
- fs.write(join(gitdir, key), `${value.trim()}\n`, 'utf8')
1915
+ fs.write(path.join(gitdir, key), `${value.trim()}\n`, 'utf8')
1916
1916
  );
1917
1917
  }
1918
1918
  return { pruned }
@@ -1925,13 +1925,13 @@ class GitRefManager {
1925
1925
  throw new InvalidOidError(value)
1926
1926
  }
1927
1927
  await acquireLock(ref, async () =>
1928
- fs.write(join(gitdir, ref), `${value.trim()}\n`, 'utf8')
1928
+ fs.write(path.join(gitdir, ref), `${value.trim()}\n`, 'utf8')
1929
1929
  );
1930
1930
  }
1931
1931
 
1932
1932
  static async writeSymbolicRef({ fs, gitdir, ref, value }) {
1933
1933
  await acquireLock(ref, async () =>
1934
- fs.write(join(gitdir, ref), 'ref: ' + `${value.trim()}\n`, 'utf8')
1934
+ fs.write(path.join(gitdir, ref), 'ref: ' + `${value.trim()}\n`, 'utf8')
1935
1935
  );
1936
1936
  }
1937
1937
 
@@ -1941,7 +1941,7 @@ class GitRefManager {
1941
1941
 
1942
1942
  static async deleteRefs({ fs, gitdir, refs }) {
1943
1943
  // Delete regular ref
1944
- await Promise.all(refs.map(ref => fs.rm(join(gitdir, ref))));
1944
+ await Promise.all(refs.map(ref => fs.rm(path.join(gitdir, ref))));
1945
1945
  // Delete any packed ref
1946
1946
  let text = await acquireLock('packed-refs', async () =>
1947
1947
  fs.read(`${gitdir}/packed-refs`, { encoding: 'utf8' })
@@ -2431,6 +2431,10 @@ function getIterator(iterable) {
2431
2431
  // inspired by 'gartal' but lighter-weight and more battle-tested.
2432
2432
  class StreamReader {
2433
2433
  constructor(stream) {
2434
+ // TODO: fix usage in bundlers before Buffer dependency is removed #1855
2435
+ if (typeof Buffer === 'undefined') {
2436
+ throw new Error('Missing Buffer dependency')
2437
+ }
2434
2438
  this.stream = getIterator(stream);
2435
2439
  this.buffer = null;
2436
2440
  this.cursor = 0;
@@ -3066,7 +3070,7 @@ async function readObjectPacked({
3066
3070
  }) {
3067
3071
  // Check to see if it's in a packfile.
3068
3072
  // Iterate through all the .idx files
3069
- let list = await fs.readdir(join(gitdir, 'objects/pack'));
3073
+ let list = await fs.readdir(path.join(gitdir, 'objects/pack'));
3070
3074
  list = list.filter(x => x.endsWith('.idx'));
3071
3075
  for (const filename of list) {
3072
3076
  const indexFile = `${gitdir}/objects/pack/${filename}`;
@@ -4018,9 +4022,9 @@ class GitWalkerRepo {
4018
4022
  const tree = GitTree.from(object);
4019
4023
  // cache all entries
4020
4024
  for (const entry of tree) {
4021
- map.set(join(filepath, entry.path), entry);
4025
+ map.set(path.join(filepath, entry.path), entry);
4022
4026
  }
4023
- return tree.entries().map(entry => join(filepath, entry.path))
4027
+ return tree.entries().map(entry => path.join(filepath, entry.path))
4024
4028
  }
4025
4029
 
4026
4030
  async type(entry) {
@@ -4131,9 +4135,9 @@ class GitWalkerFs {
4131
4135
  async readdir(entry) {
4132
4136
  const filepath = entry._fullpath;
4133
4137
  const { fs, dir } = this;
4134
- const names = await fs.readdir(join(dir, filepath));
4138
+ const names = await fs.readdir(path.join(dir, filepath));
4135
4139
  if (names === null) return null
4136
- return names.map(name => join(filepath, name))
4140
+ return names.map(name => path.join(filepath, name))
4137
4141
  }
4138
4142
 
4139
4143
  async type(entry) {
@@ -4440,7 +4444,7 @@ async function rmRecursive(fs, filepath) {
4440
4444
  } else if (entries.length) {
4441
4445
  await Promise.all(
4442
4446
  entries.map(entry => {
4443
- const subpath = join(filepath, entry);
4447
+ const subpath = path.join(filepath, entry);
4444
4448
  return fs.lstat(subpath).then(stat => {
4445
4449
  if (!stat) return
4446
4450
  return stat.isDirectory() ? rmRecursive(fs, subpath) : fs.rm(subpath)
@@ -4785,7 +4789,7 @@ async function modified(entry, base) {
4785
4789
  async function abortMerge({
4786
4790
  fs: _fs,
4787
4791
  dir,
4788
- gitdir = join(dir, '.git'),
4792
+ gitdir = path.join(dir, '.git'),
4789
4793
  commit = 'HEAD',
4790
4794
  cache = {},
4791
4795
  }) {
@@ -4864,21 +4868,21 @@ async function abortMerge({
4864
4868
  // I'm putting this in a Manager because I reckon it could benefit
4865
4869
  // from a LOT of caching.
4866
4870
  class GitIgnoreManager {
4867
- static async isIgnored({ fs, dir, gitdir = join(dir, '.git'), filepath }) {
4871
+ static async isIgnored({ fs, dir, gitdir = path.join(dir, '.git'), filepath }) {
4868
4872
  // ALWAYS ignore ".git" folders.
4869
4873
  if (basename(filepath) === '.git') return true
4870
4874
  // '.' is not a valid gitignore entry, so '.' is never ignored
4871
4875
  if (filepath === '.') return false
4872
4876
  // Check and load exclusion rules from project exclude file (.git/info/exclude)
4873
4877
  let excludes = '';
4874
- const excludesFile = join(gitdir, 'info', 'exclude');
4878
+ const excludesFile = path.join(gitdir, 'info', 'exclude');
4875
4879
  if (await fs.exists(excludesFile)) {
4876
4880
  excludes = await fs.read(excludesFile, 'utf8');
4877
4881
  }
4878
4882
  // Find all the .gitignore files that could affect this file
4879
4883
  const pairs = [
4880
4884
  {
4881
- gitignore: join(dir, '.gitignore'),
4885
+ gitignore: path.join(dir, '.gitignore'),
4882
4886
  filepath,
4883
4887
  },
4884
4888
  ];
@@ -4887,7 +4891,7 @@ class GitIgnoreManager {
4887
4891
  const folder = pieces.slice(0, i).join('/');
4888
4892
  const file = pieces.slice(i).join('/');
4889
4893
  pairs.push({
4890
- gitignore: join(dir, folder, '.gitignore'),
4894
+ gitignore: path.join(dir, folder, '.gitignore'),
4891
4895
  filepath: file,
4892
4896
  });
4893
4897
  }
@@ -5016,7 +5020,7 @@ function posixifyPathBuffer(buffer) {
5016
5020
  async function add({
5017
5021
  fs: _fs,
5018
5022
  dir,
5019
- gitdir = join(dir, '.git'),
5023
+ gitdir = path.join(dir, '.git'),
5020
5024
  filepath,
5021
5025
  cache = {},
5022
5026
  force = false,
@@ -5067,18 +5071,18 @@ async function addToIndex({
5067
5071
  });
5068
5072
  if (ignored) return
5069
5073
  }
5070
- const stats = await fs.lstat(join(dir, currentFilepath));
5074
+ const stats = await fs.lstat(path.join(dir, currentFilepath));
5071
5075
  if (!stats) throw new NotFoundError(currentFilepath)
5072
5076
 
5073
5077
  if (stats.isDirectory()) {
5074
- const children = await fs.readdir(join(dir, currentFilepath));
5078
+ const children = await fs.readdir(path.join(dir, currentFilepath));
5075
5079
  if (parallel) {
5076
5080
  const promises = children.map(child =>
5077
5081
  addToIndex({
5078
5082
  dir,
5079
5083
  gitdir,
5080
5084
  fs,
5081
- filepath: [join(currentFilepath, child)],
5085
+ filepath: [path.join(currentFilepath, child)],
5082
5086
  index,
5083
5087
  force,
5084
5088
  parallel,
@@ -5091,7 +5095,7 @@ async function addToIndex({
5091
5095
  dir,
5092
5096
  gitdir,
5093
5097
  fs,
5094
- filepath: [join(currentFilepath, child)],
5098
+ filepath: [path.join(currentFilepath, child)],
5095
5099
  index,
5096
5100
  force,
5097
5101
  parallel,
@@ -5102,8 +5106,8 @@ async function addToIndex({
5102
5106
  const config = await GitConfigManager.get({ fs, gitdir });
5103
5107
  const autocrlf = await config.get('core.autocrlf');
5104
5108
  const object = stats.isSymbolicLink()
5105
- ? await fs.readlink(join(dir, currentFilepath)).then(posixifyPathBuffer)
5106
- : await fs.read(join(dir, currentFilepath), { autocrlf });
5109
+ ? await fs.readlink(path.join(dir, currentFilepath)).then(posixifyPathBuffer)
5110
+ : await fs.read(path.join(dir, currentFilepath), { autocrlf });
5107
5111
  if (object === null) throw new NotFoundError(currentFilepath)
5108
5112
  const oid = await _writeObject({ fs, gitdir, type: 'blob', object });
5109
5113
  index.insert({ filepath: currentFilepath, stats, oid });
@@ -5608,7 +5612,7 @@ async function addNote({
5608
5612
  fs: _fs,
5609
5613
  onSign,
5610
5614
  dir,
5611
- gitdir = join(dir, '.git'),
5615
+ gitdir = path.join(dir, '.git'),
5612
5616
  ref = 'refs/notes/commits',
5613
5617
  oid,
5614
5618
  note,
@@ -5723,7 +5727,7 @@ async function _addRemote({ fs, gitdir, remote, url, force }) {
5723
5727
  async function addRemote({
5724
5728
  fs,
5725
5729
  dir,
5726
- gitdir = join(dir, '.git'),
5730
+ gitdir = path.join(dir, '.git'),
5727
5731
  remote,
5728
5732
  url,
5729
5733
  force = false,
@@ -5874,7 +5878,7 @@ async function annotatedTag({
5874
5878
  fs: _fs,
5875
5879
  onSign,
5876
5880
  dir,
5877
- gitdir = join(dir, '.git'),
5881
+ gitdir = path.join(dir, '.git'),
5878
5882
  ref,
5879
5883
  tagger: _tagger,
5880
5884
  message = ref,
@@ -6005,7 +6009,7 @@ async function _branch({
6005
6009
  async function branch({
6006
6010
  fs,
6007
6011
  dir,
6008
- gitdir = join(dir, '.git'),
6012
+ gitdir = path.join(dir, '.git'),
6009
6013
  ref,
6010
6014
  object,
6011
6015
  checkout = false,
@@ -6047,6 +6051,7 @@ const worthWalking = (filepath, root) => {
6047
6051
  * @param {import('../models/FileSystem.js').FileSystem} args.fs
6048
6052
  * @param {any} args.cache
6049
6053
  * @param {ProgressCallback} [args.onProgress]
6054
+ * @param {PostCheckoutCallback} [args.onPostCheckout]
6050
6055
  * @param {string} args.dir
6051
6056
  * @param {string} args.gitdir
6052
6057
  * @param {string} args.ref
@@ -6065,6 +6070,7 @@ async function _checkout({
6065
6070
  fs,
6066
6071
  cache,
6067
6072
  onProgress,
6073
+ onPostCheckout,
6068
6074
  dir,
6069
6075
  gitdir,
6070
6076
  remote,
@@ -6076,6 +6082,16 @@ async function _checkout({
6076
6082
  force,
6077
6083
  track = true,
6078
6084
  }) {
6085
+ // oldOid is defined only if onPostCheckout hook is attached
6086
+ let oldOid;
6087
+ if (onPostCheckout) {
6088
+ try {
6089
+ oldOid = await GitRefManager.resolve({ fs, gitdir, ref: 'HEAD' });
6090
+ } catch (err) {
6091
+ oldOid = '0000000000000000000000000000000000000000';
6092
+ }
6093
+ }
6094
+
6079
6095
  // Get tree oid
6080
6096
  let oid;
6081
6097
  try {
@@ -6151,6 +6167,14 @@ async function _checkout({
6151
6167
  if (dryRun) {
6152
6168
  // Since the format of 'ops' is in flux, I really would rather folk besides myself not start relying on it
6153
6169
  // return ops
6170
+
6171
+ if (onPostCheckout) {
6172
+ await onPostCheckout({
6173
+ previousHead: oldOid,
6174
+ newHead: oid,
6175
+ type: filepaths != null && filepaths.length > 0 ? 'file' : 'branch',
6176
+ });
6177
+ }
6154
6178
  return
6155
6179
  }
6156
6180
 
@@ -6295,6 +6319,14 @@ async function _checkout({
6295
6319
  })
6296
6320
  );
6297
6321
  });
6322
+
6323
+ if (onPostCheckout) {
6324
+ await onPostCheckout({
6325
+ previousHead: oldOid,
6326
+ newHead: oid,
6327
+ type: filepaths != null && filepaths.length > 0 ? 'file' : 'branch',
6328
+ });
6329
+ }
6298
6330
  }
6299
6331
 
6300
6332
  // Update HEAD
@@ -6614,6 +6646,7 @@ async function analyze({
6614
6646
  * @param {object} args
6615
6647
  * @param {FsClient} args.fs - a file system implementation
6616
6648
  * @param {ProgressCallback} [args.onProgress] - optional progress event callback
6649
+ * @param {PostCheckoutCallback} [args.onPostCheckout] - optional post-checkout hook callback
6617
6650
  * @param {string} args.dir - The [working tree](dir-vs-gitdir.md) directory path
6618
6651
  * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
6619
6652
  * @param {string} [args.ref = 'HEAD'] - Source to checkout files from
@@ -6662,8 +6695,9 @@ async function analyze({
6662
6695
  async function checkout({
6663
6696
  fs,
6664
6697
  onProgress,
6698
+ onPostCheckout,
6665
6699
  dir,
6666
- gitdir = join(dir, '.git'),
6700
+ gitdir = path.join(dir, '.git'),
6667
6701
  remote = 'origin',
6668
6702
  ref: _ref,
6669
6703
  filepaths,
@@ -6684,6 +6718,7 @@ async function checkout({
6684
6718
  fs: new FileSystem(fs),
6685
6719
  cache,
6686
6720
  onProgress,
6721
+ onPostCheckout,
6687
6722
  dir,
6688
6723
  gitdir,
6689
6724
  remote,
@@ -7267,7 +7302,7 @@ let lock$2 = null;
7267
7302
  class GitShallowManager {
7268
7303
  static async read({ fs, gitdir }) {
7269
7304
  if (lock$2 === null) lock$2 = new AsyncLock();
7270
- const filepath = join(gitdir, 'shallow');
7305
+ const filepath = path.join(gitdir, 'shallow');
7271
7306
  const oids = new Set();
7272
7307
  await lock$2.acquire(filepath, async function() {
7273
7308
  const text = await fs.read(filepath, { encoding: 'utf8' });
@@ -7283,7 +7318,7 @@ class GitShallowManager {
7283
7318
 
7284
7319
  static async write({ fs, gitdir, oids }) {
7285
7320
  if (lock$2 === null) lock$2 = new AsyncLock();
7286
- const filepath = join(gitdir, 'shallow');
7321
+ const filepath = path.join(gitdir, 'shallow');
7287
7322
  if (oids.size > 0) {
7288
7323
  const text = [...oids].join('\n') + '\n';
7289
7324
  await lock$2.acquire(filepath, async function() {
@@ -7314,7 +7349,7 @@ async function hasObjectPacked({
7314
7349
  }) {
7315
7350
  // Check to see if it's in a packfile.
7316
7351
  // Iterate through all the .idx files
7317
- let list = await fs.readdir(join(gitdir, 'objects/pack'));
7352
+ let list = await fs.readdir(path.join(gitdir, 'objects/pack'));
7318
7353
  list = list.filter(x => x.endsWith('.idx'));
7319
7354
  for (const filename of list) {
7320
7355
  const indexFile = `${gitdir}/objects/pack/${filename}`;
@@ -7380,8 +7415,8 @@ function filterCapabilities(server, client) {
7380
7415
 
7381
7416
  const pkg = {
7382
7417
  name: 'isomorphic-git',
7383
- version: '1.25.9',
7384
- agent: 'git/isomorphic-git@1.25.9',
7418
+ version: '1.26.0',
7419
+ agent: 'git/isomorphic-git@1.26.0',
7385
7420
  };
7386
7421
 
7387
7422
  class FIFO {
@@ -8047,7 +8082,7 @@ async function _fetch({
8047
8082
  // c) compare the computed SHA with the last 20 bytes of the stream before saving to disk, and throwing a "packfile got corrupted during download" error if the SHA doesn't match.
8048
8083
  if (packfileSha !== '' && !emptyPackfile(packfile)) {
8049
8084
  res.packfile = `objects/pack/pack-${packfileSha}.pack`;
8050
- const fullpath = join(gitdir, res.packfile);
8085
+ const fullpath = path.join(gitdir, res.packfile);
8051
8086
  await fs.write(fullpath, packfile);
8052
8087
  const getExternalRefDelta = oid => _readObject({ fs, cache, gitdir, oid });
8053
8088
  const idx = await GitPackIndex.fromPack({
@@ -8077,7 +8112,7 @@ async function _init({
8077
8112
  fs,
8078
8113
  bare = false,
8079
8114
  dir,
8080
- gitdir = bare ? dir : join(dir, '.git'),
8115
+ gitdir = bare ? dir : path.join(dir, '.git'),
8081
8116
  defaultBranch = 'master',
8082
8117
  }) {
8083
8118
  // Don't overwrite an existing config
@@ -8121,6 +8156,7 @@ async function _init({
8121
8156
  * @param {AuthCallback} [args.onAuth]
8122
8157
  * @param {AuthFailureCallback} [args.onAuthFailure]
8123
8158
  * @param {AuthSuccessCallback} [args.onAuthSuccess]
8159
+ * @param {PostCheckoutCallback} [args.onPostCheckout]
8124
8160
  * @param {string} [args.dir]
8125
8161
  * @param {string} args.gitdir
8126
8162
  * @param {string} args.url
@@ -8148,6 +8184,7 @@ async function _clone({
8148
8184
  onAuth,
8149
8185
  onAuthSuccess,
8150
8186
  onAuthFailure,
8187
+ onPostCheckout,
8151
8188
  dir,
8152
8189
  gitdir,
8153
8190
  url,
@@ -8200,6 +8237,7 @@ async function _clone({
8200
8237
  fs,
8201
8238
  cache,
8202
8239
  onProgress,
8240
+ onPostCheckout,
8203
8241
  dir,
8204
8242
  gitdir,
8205
8243
  ref,
@@ -8230,6 +8268,7 @@ async function _clone({
8230
8268
  * @param {AuthCallback} [args.onAuth] - optional auth fill callback
8231
8269
  * @param {AuthFailureCallback} [args.onAuthFailure] - optional auth rejected callback
8232
8270
  * @param {AuthSuccessCallback} [args.onAuthSuccess] - optional auth approved callback
8271
+ * @param {PostCheckoutCallback} [args.onPostCheckout] - optional post-checkout hook callback
8233
8272
  * @param {string} args.dir - The [working tree](dir-vs-gitdir.md) directory path
8234
8273
  * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
8235
8274
  * @param {string} args.url - The URL of the remote repository
@@ -8269,8 +8308,9 @@ async function clone({
8269
8308
  onAuth,
8270
8309
  onAuthSuccess,
8271
8310
  onAuthFailure,
8311
+ onPostCheckout,
8272
8312
  dir,
8273
- gitdir = join(dir, '.git'),
8313
+ gitdir = path.join(dir, '.git'),
8274
8314
  url,
8275
8315
  corsProxy = undefined,
8276
8316
  ref = undefined,
@@ -8303,6 +8343,7 @@ async function clone({
8303
8343
  onAuth,
8304
8344
  onAuthSuccess,
8305
8345
  onAuthFailure,
8346
+ onPostCheckout,
8306
8347
  dir,
8307
8348
  gitdir,
8308
8349
  url,
@@ -8372,7 +8413,7 @@ async function commit({
8372
8413
  fs: _fs,
8373
8414
  onSign,
8374
8415
  dir,
8375
- gitdir = join(dir, '.git'),
8416
+ gitdir = path.join(dir, '.git'),
8376
8417
  message,
8377
8418
  author: _author,
8378
8419
  committer: _committer,
@@ -8451,7 +8492,7 @@ async function commit({
8451
8492
  async function currentBranch({
8452
8493
  fs,
8453
8494
  dir,
8454
- gitdir = join(dir, '.git'),
8495
+ gitdir = path.join(dir, '.git'),
8455
8496
  fullname = false,
8456
8497
  test = false,
8457
8498
  }) {
@@ -8522,7 +8563,7 @@ async function _deleteBranch({ fs, gitdir, ref }) {
8522
8563
  async function deleteBranch({
8523
8564
  fs,
8524
8565
  dir,
8525
- gitdir = join(dir, '.git'),
8566
+ gitdir = path.join(dir, '.git'),
8526
8567
  ref,
8527
8568
  }) {
8528
8569
  try {
@@ -8557,7 +8598,7 @@ async function deleteBranch({
8557
8598
  * console.log('done')
8558
8599
  *
8559
8600
  */
8560
- async function deleteRef({ fs, dir, gitdir = join(dir, '.git'), ref }) {
8601
+ async function deleteRef({ fs, dir, gitdir = path.join(dir, '.git'), ref }) {
8561
8602
  try {
8562
8603
  assertParameter('fs', fs);
8563
8604
  assertParameter('ref', ref);
@@ -8605,7 +8646,7 @@ async function _deleteRemote({ fs, gitdir, remote }) {
8605
8646
  async function deleteRemote({
8606
8647
  fs,
8607
8648
  dir,
8608
- gitdir = join(dir, '.git'),
8649
+ gitdir = path.join(dir, '.git'),
8609
8650
  remote,
8610
8651
  }) {
8611
8652
  try {
@@ -8662,7 +8703,7 @@ async function _deleteTag({ fs, gitdir, ref }) {
8662
8703
  * console.log('done')
8663
8704
  *
8664
8705
  */
8665
- async function deleteTag({ fs, dir, gitdir = join(dir, '.git'), ref }) {
8706
+ async function deleteTag({ fs, dir, gitdir = path.join(dir, '.git'), ref }) {
8666
8707
  try {
8667
8708
  assertParameter('fs', fs);
8668
8709
  assertParameter('ref', ref);
@@ -8694,7 +8735,7 @@ async function expandOidPacked({
8694
8735
  }) {
8695
8736
  // Iterate through all the .pack files
8696
8737
  const results = [];
8697
- let list = await fs.readdir(join(gitdir, 'objects/pack'));
8738
+ let list = await fs.readdir(path.join(gitdir, 'objects/pack'));
8698
8739
  list = list.filter(x => x.endsWith('.idx'));
8699
8740
  for (const filename of list) {
8700
8741
  const indexFile = `${gitdir}/objects/pack/${filename}`;
@@ -8764,7 +8805,7 @@ async function _expandOid({ fs, cache, gitdir, oid: short }) {
8764
8805
  async function expandOid({
8765
8806
  fs,
8766
8807
  dir,
8767
- gitdir = join(dir, '.git'),
8808
+ gitdir = path.join(dir, '.git'),
8768
8809
  oid,
8769
8810
  cache = {},
8770
8811
  }) {
@@ -8802,7 +8843,7 @@ async function expandOid({
8802
8843
  * console.log(fullRef)
8803
8844
  *
8804
8845
  */
8805
- async function expandRef({ fs, dir, gitdir = join(dir, '.git'), ref }) {
8846
+ async function expandRef({ fs, dir, gitdir = path.join(dir, '.git'), ref }) {
8806
8847
  try {
8807
8848
  assertParameter('fs', fs);
8808
8849
  assertParameter('gitdir', gitdir);
@@ -8942,7 +8983,7 @@ async function mergeTree({
8942
8983
  fs,
8943
8984
  cache,
8944
8985
  dir,
8945
- gitdir = join(dir, '.git'),
8986
+ gitdir = path.join(dir, '.git'),
8946
8987
  index,
8947
8988
  ourOid,
8948
8989
  baseOid,
@@ -9599,7 +9640,7 @@ async function fastForward({
9599
9640
  onAuthSuccess,
9600
9641
  onAuthFailure,
9601
9642
  dir,
9602
- gitdir = join(dir, '.git'),
9643
+ gitdir = path.join(dir, '.git'),
9603
9644
  ref,
9604
9645
  url,
9605
9646
  remote,
@@ -9718,7 +9759,7 @@ async function fetch({
9718
9759
  onAuthSuccess,
9719
9760
  onAuthFailure,
9720
9761
  dir,
9721
- gitdir = join(dir, '.git'),
9762
+ gitdir = path.join(dir, '.git'),
9722
9763
  ref,
9723
9764
  remote,
9724
9765
  remoteRef,
@@ -9787,7 +9828,7 @@ async function fetch({
9787
9828
  async function findMergeBase({
9788
9829
  fs,
9789
9830
  dir,
9790
- gitdir = join(dir, '.git'),
9831
+ gitdir = path.join(dir, '.git'),
9791
9832
  oids,
9792
9833
  cache = {},
9793
9834
  }) {
@@ -9822,7 +9863,7 @@ async function findMergeBase({
9822
9863
  * @returns {Promise<string>} Resolves successfully with a root git directory path
9823
9864
  */
9824
9865
  async function _findRoot({ fs, filepath }) {
9825
- if (await fs.exists(join(filepath, '.git'))) {
9866
+ if (await fs.exists(path.join(filepath, '.git'))) {
9826
9867
  return filepath
9827
9868
  } else {
9828
9869
  const parent = dirname(filepath);
@@ -9894,16 +9935,16 @@ async function findRoot({ fs, filepath }) {
9894
9935
  * console.log(value)
9895
9936
  *
9896
9937
  */
9897
- async function getConfig({ fs, dir, gitdir = join(dir, '.git'), path }) {
9938
+ async function getConfig({ fs, dir, gitdir = path.join(dir, '.git'), path: path$1 }) {
9898
9939
  try {
9899
9940
  assertParameter('fs', fs);
9900
9941
  assertParameter('gitdir', gitdir);
9901
- assertParameter('path', path);
9942
+ assertParameter('path', path$1);
9902
9943
 
9903
9944
  return await _getConfig({
9904
9945
  fs: new FileSystem(fs),
9905
9946
  gitdir,
9906
- path,
9947
+ path: path$1,
9907
9948
  })
9908
9949
  } catch (err) {
9909
9950
  err.caller = 'git.getConfig';
@@ -9948,18 +9989,18 @@ async function _getConfigAll({ fs, gitdir, path }) {
9948
9989
  async function getConfigAll({
9949
9990
  fs,
9950
9991
  dir,
9951
- gitdir = join(dir, '.git'),
9952
- path,
9992
+ gitdir = path.join(dir, '.git'),
9993
+ path: path$1,
9953
9994
  }) {
9954
9995
  try {
9955
9996
  assertParameter('fs', fs);
9956
9997
  assertParameter('gitdir', gitdir);
9957
- assertParameter('path', path);
9998
+ assertParameter('path', path$1);
9958
9999
 
9959
10000
  return await _getConfigAll({
9960
10001
  fs: new FileSystem(fs),
9961
10002
  gitdir,
9962
- path,
10003
+ path: path$1,
9963
10004
  })
9964
10005
  } catch (err) {
9965
10006
  err.caller = 'git.getConfigAll';
@@ -10313,7 +10354,7 @@ async function _indexPack({
10313
10354
  filepath,
10314
10355
  }) {
10315
10356
  try {
10316
- filepath = join(dir, filepath);
10357
+ filepath = path.join(dir, filepath);
10317
10358
  const pack = await fs.read(filepath);
10318
10359
  const getExternalRefDelta = oid => _readObject({ fs, cache, gitdir, oid });
10319
10360
  const idx = await GitPackIndex.fromPack({
@@ -10366,7 +10407,7 @@ async function indexPack({
10366
10407
  fs,
10367
10408
  onProgress,
10368
10409
  dir,
10369
- gitdir = join(dir, '.git'),
10410
+ gitdir = path.join(dir, '.git'),
10370
10411
  filepath,
10371
10412
  cache = {},
10372
10413
  }) {
@@ -10412,7 +10453,7 @@ async function init({
10412
10453
  fs,
10413
10454
  bare = false,
10414
10455
  dir,
10415
- gitdir = bare ? dir : join(dir, '.git'),
10456
+ gitdir = bare ? dir : path.join(dir, '.git'),
10416
10457
  defaultBranch = 'master',
10417
10458
  }) {
10418
10459
  try {
@@ -10533,7 +10574,7 @@ async function _isDescendent({
10533
10574
  async function isDescendent({
10534
10575
  fs,
10535
10576
  dir,
10536
- gitdir = join(dir, '.git'),
10577
+ gitdir = path.join(dir, '.git'),
10537
10578
  oid,
10538
10579
  ancestor,
10539
10580
  depth = -1,
@@ -10579,7 +10620,7 @@ async function isDescendent({
10579
10620
  async function isIgnored({
10580
10621
  fs,
10581
10622
  dir,
10582
- gitdir = join(dir, '.git'),
10623
+ gitdir = path.join(dir, '.git'),
10583
10624
  filepath,
10584
10625
  }) {
10585
10626
  try {
@@ -10632,7 +10673,7 @@ async function isIgnored({
10632
10673
  async function listBranches({
10633
10674
  fs,
10634
10675
  dir,
10635
- gitdir = join(dir, '.git'),
10676
+ gitdir = path.join(dir, '.git'),
10636
10677
  remote,
10637
10678
  }) {
10638
10679
  try {
@@ -10701,10 +10742,10 @@ async function accumulateFilesFromOid({
10701
10742
  gitdir,
10702
10743
  oid: entry.oid,
10703
10744
  filenames,
10704
- prefix: join(prefix, entry.path),
10745
+ prefix: path.join(prefix, entry.path),
10705
10746
  });
10706
10747
  } else {
10707
- filenames.push(join(prefix, entry.path));
10748
+ filenames.push(path.join(prefix, entry.path));
10708
10749
  }
10709
10750
  }
10710
10751
  }
@@ -10738,7 +10779,7 @@ async function accumulateFilesFromOid({
10738
10779
  async function listFiles({
10739
10780
  fs,
10740
10781
  dir,
10741
- gitdir = join(dir, '.git'),
10782
+ gitdir = path.join(dir, '.git'),
10742
10783
  ref,
10743
10784
  cache = {},
10744
10785
  }) {
@@ -10817,7 +10858,7 @@ async function _listNotes({ fs, cache, gitdir, ref }) {
10817
10858
  async function listNotes({
10818
10859
  fs,
10819
10860
  dir,
10820
- gitdir = join(dir, '.git'),
10861
+ gitdir = path.join(dir, '.git'),
10821
10862
  ref = 'refs/notes/commits',
10822
10863
  cache = {},
10823
10864
  }) {
@@ -10876,7 +10917,7 @@ async function _listRemotes({ fs, gitdir }) {
10876
10917
  * console.log(remotes)
10877
10918
  *
10878
10919
  */
10879
- async function listRemotes({ fs, dir, gitdir = join(dir, '.git') }) {
10920
+ async function listRemotes({ fs, dir, gitdir = path.join(dir, '.git') }) {
10880
10921
  try {
10881
10922
  assertParameter('fs', fs);
10882
10923
  assertParameter('gitdir', gitdir);
@@ -11120,7 +11161,7 @@ async function listServerRefs({
11120
11161
  * console.log(tags)
11121
11162
  *
11122
11163
  */
11123
- async function listTags({ fs, dir, gitdir = join(dir, '.git') }) {
11164
+ async function listTags({ fs, dir, gitdir = path.join(dir, '.git') }) {
11124
11165
  try {
11125
11166
  assertParameter('fs', fs);
11126
11167
  assertParameter('gitdir', gitdir);
@@ -11221,7 +11262,7 @@ async function _resolveFileId({
11221
11262
  const walks = tree.entries().map(function(entry) {
11222
11263
  let result;
11223
11264
  if (entry.oid === fileId) {
11224
- result = join(parentPath, entry.path);
11265
+ result = path.join(parentPath, entry.path);
11225
11266
  filepaths.push(result);
11226
11267
  } else if (entry.type === 'tree') {
11227
11268
  result = _readObject({
@@ -11238,7 +11279,7 @@ async function _resolveFileId({
11238
11279
  fileId,
11239
11280
  oid,
11240
11281
  filepaths,
11241
- parentPath: join(parentPath, entry.path),
11282
+ parentPath: path.join(parentPath, entry.path),
11242
11283
  })
11243
11284
  });
11244
11285
  }
@@ -11448,7 +11489,7 @@ async function _log({
11448
11489
  async function log({
11449
11490
  fs,
11450
11491
  dir,
11451
- gitdir = join(dir, '.git'),
11492
+ gitdir = path.join(dir, '.git'),
11452
11493
  filepath,
11453
11494
  ref = 'HEAD',
11454
11495
  depth,
@@ -11596,7 +11637,7 @@ async function merge({
11596
11637
  fs: _fs,
11597
11638
  onSign,
11598
11639
  dir,
11599
- gitdir = join(dir, '.git'),
11640
+ gitdir = path.join(dir, '.git'),
11600
11641
  ours,
11601
11642
  theirs,
11602
11643
  fastForward = true,
@@ -11682,7 +11723,7 @@ async function _pack({
11682
11723
  fs,
11683
11724
  cache,
11684
11725
  dir,
11685
- gitdir = join(dir, '.git'),
11726
+ gitdir = path.join(dir, '.git'),
11686
11727
  oids,
11687
11728
  }) {
11688
11729
  const hash = new Hash();
@@ -11758,7 +11799,7 @@ async function _packObjects({ fs, cache, gitdir, oids, write }) {
11758
11799
  const packfileSha = packfile.slice(-20).toString('hex');
11759
11800
  const filename = `pack-${packfileSha}.pack`;
11760
11801
  if (write) {
11761
- await fs.write(join(gitdir, `objects/pack/${filename}`), packfile);
11802
+ await fs.write(path.join(gitdir, `objects/pack/${filename}`), packfile);
11762
11803
  return { filename }
11763
11804
  }
11764
11805
  return {
@@ -11803,7 +11844,7 @@ async function _packObjects({ fs, cache, gitdir, oids, write }) {
11803
11844
  async function packObjects({
11804
11845
  fs,
11805
11846
  dir,
11806
- gitdir = join(dir, '.git'),
11847
+ gitdir = path.join(dir, '.git'),
11807
11848
  oids,
11808
11849
  write = false,
11809
11850
  cache = {},
@@ -11887,7 +11928,7 @@ async function pull({
11887
11928
  onAuthSuccess,
11888
11929
  onAuthFailure,
11889
11930
  dir,
11890
- gitdir = join(dir, '.git'),
11931
+ gitdir = path.join(dir, '.git'),
11891
11932
  ref,
11892
11933
  url,
11893
11934
  remote,
@@ -11967,7 +12008,7 @@ async function listCommitsAndTags({
11967
12008
  fs,
11968
12009
  cache,
11969
12010
  dir,
11970
- gitdir = join(dir, '.git'),
12011
+ gitdir = path.join(dir, '.git'),
11971
12012
  start,
11972
12013
  finish,
11973
12014
  }) {
@@ -12030,7 +12071,7 @@ async function listObjects({
12030
12071
  fs,
12031
12072
  cache,
12032
12073
  dir,
12033
- gitdir = join(dir, '.git'),
12074
+ gitdir = path.join(dir, '.git'),
12034
12075
  oids,
12035
12076
  }) {
12036
12077
  const visited = new Set();
@@ -12139,6 +12180,7 @@ async function writeReceivePackRequest({
12139
12180
  * @param {AuthCallback} [args.onAuth]
12140
12181
  * @param {AuthFailureCallback} [args.onAuthFailure]
12141
12182
  * @param {AuthSuccessCallback} [args.onAuthSuccess]
12183
+ * @param {PrePushCallback} [args.onPrePush]
12142
12184
  * @param {string} args.gitdir
12143
12185
  * @param {string} [args.ref]
12144
12186
  * @param {string} [args.remoteRef]
@@ -12160,6 +12202,7 @@ async function _push({
12160
12202
  onAuth,
12161
12203
  onAuthSuccess,
12162
12204
  onAuthFailure,
12205
+ onPrePush,
12163
12206
  gitdir,
12164
12207
  ref: _ref,
12165
12208
  remoteRef: _remoteRef,
@@ -12244,6 +12287,16 @@ async function _push({
12244
12287
  httpRemote.refs.get(fullRemoteRef) ||
12245
12288
  '0000000000000000000000000000000000000000';
12246
12289
 
12290
+ if (onPrePush) {
12291
+ const hookCancel = await onPrePush({
12292
+ remote,
12293
+ url,
12294
+ localRef: { ref: _delete ? '(delete)' : fullRef, oid: oid },
12295
+ remoteRef: { ref: fullRemoteRef, oid: oldoid },
12296
+ });
12297
+ if (!hookCancel) throw new UserCanceledError()
12298
+ }
12299
+
12247
12300
  // Remotes can always accept thin-packs UNLESS they specify the 'no-thin' capability
12248
12301
  const thinPack = !httpRemote.capabilities.has('no-thin');
12249
12302
 
@@ -12421,6 +12474,7 @@ async function _push({
12421
12474
  * @param {AuthCallback} [args.onAuth] - optional auth fill callback
12422
12475
  * @param {AuthFailureCallback} [args.onAuthFailure] - optional auth rejected callback
12423
12476
  * @param {AuthSuccessCallback} [args.onAuthSuccess] - optional auth approved callback
12477
+ * @param {PrePushCallback} [args.onPrePush] - optional pre-push hook callback
12424
12478
  * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
12425
12479
  * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
12426
12480
  * @param {string} [args.ref] - Which branch to push. By default this is the currently checked out branch.
@@ -12457,8 +12511,9 @@ async function push({
12457
12511
  onAuth,
12458
12512
  onAuthSuccess,
12459
12513
  onAuthFailure,
12514
+ onPrePush,
12460
12515
  dir,
12461
- gitdir = join(dir, '.git'),
12516
+ gitdir = path.join(dir, '.git'),
12462
12517
  ref,
12463
12518
  remoteRef,
12464
12519
  remote = 'origin',
@@ -12483,6 +12538,7 @@ async function push({
12483
12538
  onAuth,
12484
12539
  onAuthSuccess,
12485
12540
  onAuthFailure,
12541
+ onPrePush,
12486
12542
  gitdir,
12487
12543
  ref,
12488
12544
  remoteRef,
@@ -12592,7 +12648,7 @@ async function _readBlob({
12592
12648
  async function readBlob({
12593
12649
  fs,
12594
12650
  dir,
12595
- gitdir = join(dir, '.git'),
12651
+ gitdir = path.join(dir, '.git'),
12596
12652
  oid,
12597
12653
  filepath,
12598
12654
  cache = {},
@@ -12642,7 +12698,7 @@ async function readBlob({
12642
12698
  async function readCommit({
12643
12699
  fs,
12644
12700
  dir,
12645
- gitdir = join(dir, '.git'),
12701
+ gitdir = path.join(dir, '.git'),
12646
12702
  oid,
12647
12703
  cache = {},
12648
12704
  }) {
@@ -12716,7 +12772,7 @@ async function _readNote({
12716
12772
  async function readNote({
12717
12773
  fs,
12718
12774
  dir,
12719
- gitdir = join(dir, '.git'),
12775
+ gitdir = path.join(dir, '.git'),
12720
12776
  ref = 'refs/notes/commits',
12721
12777
  oid,
12722
12778
  cache = {},
@@ -12933,7 +12989,7 @@ async function readNote({
12933
12989
  async function readObject({
12934
12990
  fs: _fs,
12935
12991
  dir,
12936
- gitdir = join(dir, '.git'),
12992
+ gitdir = path.join(dir, '.git'),
12937
12993
  oid,
12938
12994
  format = 'parsed',
12939
12995
  filepath = undefined,
@@ -13070,7 +13126,7 @@ async function _readTag({ fs, cache, gitdir, oid }) {
13070
13126
  async function readTag({
13071
13127
  fs,
13072
13128
  dir,
13073
- gitdir = join(dir, '.git'),
13129
+ gitdir = path.join(dir, '.git'),
13074
13130
  oid,
13075
13131
  cache = {},
13076
13132
  }) {
@@ -13120,7 +13176,7 @@ async function readTag({
13120
13176
  async function readTree({
13121
13177
  fs,
13122
13178
  dir,
13123
- gitdir = join(dir, '.git'),
13179
+ gitdir = path.join(dir, '.git'),
13124
13180
  oid,
13125
13181
  filepath = undefined,
13126
13182
  cache = {},
@@ -13167,7 +13223,7 @@ async function readTree({
13167
13223
  async function remove({
13168
13224
  fs: _fs,
13169
13225
  dir,
13170
- gitdir = join(dir, '.git'),
13226
+ gitdir = path.join(dir, '.git'),
13171
13227
  filepath,
13172
13228
  cache = {},
13173
13229
  }) {
@@ -13303,7 +13359,7 @@ async function removeNote({
13303
13359
  fs: _fs,
13304
13360
  onSign,
13305
13361
  dir,
13306
- gitdir = join(dir, '.git'),
13362
+ gitdir = path.join(dir, '.git'),
13307
13363
  ref = 'refs/notes/commits',
13308
13364
  oid,
13309
13365
  author: _author,
@@ -13435,7 +13491,7 @@ async function _renameBranch({
13435
13491
  async function renameBranch({
13436
13492
  fs,
13437
13493
  dir,
13438
- gitdir = join(dir, '.git'),
13494
+ gitdir = path.join(dir, '.git'),
13439
13495
  ref,
13440
13496
  oldref,
13441
13497
  checkout = false,
@@ -13487,7 +13543,7 @@ async function hashObject$1({ gitdir, type, object }) {
13487
13543
  async function resetIndex({
13488
13544
  fs: _fs,
13489
13545
  dir,
13490
- gitdir = join(dir, '.git'),
13546
+ gitdir = path.join(dir, '.git'),
13491
13547
  filepath,
13492
13548
  ref,
13493
13549
  cache = {},
@@ -13542,7 +13598,7 @@ async function resetIndex({
13542
13598
  size: 0,
13543
13599
  };
13544
13600
  // If the file exists in the workdir...
13545
- const object = dir && (await fs.read(join(dir, filepath)));
13601
+ const object = dir && (await fs.read(path.join(dir, filepath)));
13546
13602
  if (object) {
13547
13603
  // ... and has the same hash as the desired state...
13548
13604
  workdirOid = await hashObject$1({
@@ -13552,7 +13608,7 @@ async function resetIndex({
13552
13608
  });
13553
13609
  if (oid === workdirOid) {
13554
13610
  // ... use the workdir Stats object
13555
- stats = await fs.lstat(join(dir, filepath));
13611
+ stats = await fs.lstat(path.join(dir, filepath));
13556
13612
  }
13557
13613
  }
13558
13614
  await GitIndexManager.acquire({ fs, gitdir, cache }, async function(index) {
@@ -13591,7 +13647,7 @@ async function resetIndex({
13591
13647
  async function resolveRef({
13592
13648
  fs,
13593
13649
  dir,
13594
- gitdir = join(dir, '.git'),
13650
+ gitdir = path.join(dir, '.git'),
13595
13651
  ref,
13596
13652
  depth,
13597
13653
  }) {
@@ -13660,23 +13716,23 @@ async function resolveRef({
13660
13716
  async function setConfig({
13661
13717
  fs: _fs,
13662
13718
  dir,
13663
- gitdir = join(dir, '.git'),
13664
- path,
13719
+ gitdir = path.join(dir, '.git'),
13720
+ path: path$1,
13665
13721
  value,
13666
13722
  append = false,
13667
13723
  }) {
13668
13724
  try {
13669
13725
  assertParameter('fs', _fs);
13670
13726
  assertParameter('gitdir', gitdir);
13671
- assertParameter('path', path);
13727
+ assertParameter('path', path$1);
13672
13728
  // assertParameter('value', value) // We actually allow 'undefined' as a value to unset/delete
13673
13729
 
13674
13730
  const fs = new FileSystem(_fs);
13675
13731
  const config = await GitConfigManager.get({ fs, gitdir });
13676
13732
  if (append) {
13677
- await config.append(path, value);
13733
+ await config.append(path$1, value);
13678
13734
  } else {
13679
- await config.set(path, value);
13735
+ await config.set(path$1, value);
13680
13736
  }
13681
13737
  await GitConfigManager.save({ fs, gitdir, config });
13682
13738
  } catch (err) {
@@ -13725,7 +13781,7 @@ async function setConfig({
13725
13781
  async function status({
13726
13782
  fs: _fs,
13727
13783
  dir,
13728
- gitdir = join(dir, '.git'),
13784
+ gitdir = path.join(dir, '.git'),
13729
13785
  filepath,
13730
13786
  cache = {},
13731
13787
  }) {
@@ -13761,7 +13817,7 @@ async function status({
13761
13817
  return null
13762
13818
  }
13763
13819
  );
13764
- const stats = await fs.lstat(join(dir, filepath));
13820
+ const stats = await fs.lstat(path.join(dir, filepath));
13765
13821
 
13766
13822
  const H = treeOid !== null; // head
13767
13823
  const I = indexEntry !== null; // index
@@ -13771,7 +13827,7 @@ async function status({
13771
13827
  if (I && !compareStats(indexEntry, stats)) {
13772
13828
  return indexEntry.oid
13773
13829
  } else {
13774
- const object = await fs.read(join(dir, filepath));
13830
+ const object = await fs.read(path.join(dir, filepath));
13775
13831
  const workdirOid = await hashObject$1({
13776
13832
  gitdir,
13777
13833
  type: 'blob',
@@ -14033,7 +14089,7 @@ async function getHeadTree({ fs, cache, gitdir }) {
14033
14089
  async function statusMatrix({
14034
14090
  fs: _fs,
14035
14091
  dir,
14036
- gitdir = join(dir, '.git'),
14092
+ gitdir = path.join(dir, '.git'),
14037
14093
  ref = 'HEAD',
14038
14094
  filepaths = ['.'],
14039
14095
  filter,
@@ -14143,7 +14199,7 @@ async function statusMatrix({
14143
14199
  async function tag({
14144
14200
  fs: _fs,
14145
14201
  dir,
14146
- gitdir = join(dir, '.git'),
14202
+ gitdir = path.join(dir, '.git'),
14147
14203
  ref,
14148
14204
  object,
14149
14205
  force = false,
@@ -14225,7 +14281,7 @@ async function tag({
14225
14281
  async function updateIndex({
14226
14282
  fs: _fs,
14227
14283
  dir,
14228
- gitdir = join(dir, '.git'),
14284
+ gitdir = path.join(dir, '.git'),
14229
14285
  cache = {},
14230
14286
  filepath,
14231
14287
  oid,
@@ -14249,7 +14305,7 @@ async function updateIndex({
14249
14305
 
14250
14306
  if (!force) {
14251
14307
  // Check if the file is still present in the working directory
14252
- fileStats = await fs.lstat(join(dir, filepath));
14308
+ fileStats = await fs.lstat(path.join(dir, filepath));
14253
14309
 
14254
14310
  if (fileStats) {
14255
14311
  if (fileStats.isDirectory()) {
@@ -14276,7 +14332,7 @@ async function updateIndex({
14276
14332
  let fileStats;
14277
14333
 
14278
14334
  if (!oid) {
14279
- fileStats = await fs.lstat(join(dir, filepath));
14335
+ fileStats = await fs.lstat(path.join(dir, filepath));
14280
14336
 
14281
14337
  if (!fileStats) {
14282
14338
  throw new NotFoundError(
@@ -14316,8 +14372,8 @@ async function updateIndex({
14316
14372
 
14317
14373
  // Write the file to the object database
14318
14374
  const object = stats.isSymbolicLink()
14319
- ? await fs.readlink(join(dir, filepath))
14320
- : await fs.read(join(dir, filepath));
14375
+ ? await fs.readlink(path.join(dir, filepath))
14376
+ : await fs.read(path.join(dir, filepath));
14321
14377
 
14322
14378
  oid = await _writeObject({
14323
14379
  fs,
@@ -14615,7 +14671,7 @@ function version() {
14615
14671
  async function walk({
14616
14672
  fs,
14617
14673
  dir,
14618
- gitdir = join(dir, '.git'),
14674
+ gitdir = path.join(dir, '.git'),
14619
14675
  trees,
14620
14676
  map,
14621
14677
  reduce,
@@ -14667,7 +14723,7 @@ async function walk({
14667
14723
  * console.log('oid', oid) // should be 'e69de29bb2d1d6434b8b29ae775ad8c2e48c5391'
14668
14724
  *
14669
14725
  */
14670
- async function writeBlob({ fs, dir, gitdir = join(dir, '.git'), blob }) {
14726
+ async function writeBlob({ fs, dir, gitdir = path.join(dir, '.git'), blob }) {
14671
14727
  try {
14672
14728
  assertParameter('fs', fs);
14673
14729
  assertParameter('gitdir', gitdir);
@@ -14729,7 +14785,7 @@ async function _writeCommit({ fs, gitdir, commit }) {
14729
14785
  async function writeCommit({
14730
14786
  fs,
14731
14787
  dir,
14732
- gitdir = join(dir, '.git'),
14788
+ gitdir = path.join(dir, '.git'),
14733
14789
  commit,
14734
14790
  }) {
14735
14791
  try {
@@ -14818,7 +14874,7 @@ async function writeCommit({
14818
14874
  async function writeObject({
14819
14875
  fs: _fs,
14820
14876
  dir,
14821
- gitdir = join(dir, '.git'),
14877
+ gitdir = path.join(dir, '.git'),
14822
14878
  type,
14823
14879
  object,
14824
14880
  format = 'parsed',
@@ -14900,7 +14956,7 @@ async function writeObject({
14900
14956
  async function writeRef({
14901
14957
  fs: _fs,
14902
14958
  dir,
14903
- gitdir = join(dir, '.git'),
14959
+ gitdir = path.join(dir, '.git'),
14904
14960
  ref,
14905
14961
  value,
14906
14962
  force = false,
@@ -15010,7 +15066,7 @@ async function _writeTag({ fs, gitdir, tag }) {
15010
15066
  * console.log('tag', oid)
15011
15067
  *
15012
15068
  */
15013
- async function writeTag({ fs, dir, gitdir = join(dir, '.git'), tag }) {
15069
+ async function writeTag({ fs, dir, gitdir = path.join(dir, '.git'), tag }) {
15014
15070
  try {
15015
15071
  assertParameter('fs', fs);
15016
15072
  assertParameter('gitdir', gitdir);
@@ -15043,7 +15099,7 @@ async function writeTag({ fs, dir, gitdir = join(dir, '.git'), tag }) {
15043
15099
  * @see TreeEntry
15044
15100
  *
15045
15101
  */
15046
- async function writeTree({ fs, dir, gitdir = join(dir, '.git'), tree }) {
15102
+ async function writeTree({ fs, dir, gitdir = path.join(dir, '.git'), tree }) {
15047
15103
  try {
15048
15104
  assertParameter('fs', fs);
15049
15105
  assertParameter('gitdir', gitdir);