repo_description: A pure JavaScript implementation of git for node and browsers!
repo_topics: browser git hacktoberfest isomorphic-javascript javascript nodejs vcs
code: // @ts-check
  import '../typedefs.js'
  
  import { _pull } from '../commands/pull.js'
  import { FileSystem } from '../models/FileSystem.js'
  import { assertParameter } from '../utils/assertParameter.js'
  import { discoverGitdir } from '../utils/discoverGitdir.js'
  import { join } from '../utils/join.js'
  
  /**
   * Like `pull`, but hard-coded with `fastForward: true` so there is no need for an `author` parameter.
   *
   * @param {object} args
   * @param {FsClient} args.fs - a file system client
   * @param {HttpClient} args.http - an HTTP client
   * @param {ProgressCallback} [args.onProgress] - optional progress event callback
   * @param {MessageCallback} [args.onMessage] - optional message event callback
   * @param {AuthCallback} [args.onAuth] - optional auth fill callback
   * @param {AuthFailureCallback} [args.onAuthFailure] - optional auth rejected callback
   * @param {AuthSuccessCallback} [args.onAuthSuccess] - optional auth approved callback
   * @param {string} args.dir] - The [working tree](dir-vs-gitdir.md) directory path
   * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
   * @param {string} [args.ref] - Which branch to merge into. By default this is the currently checked out branch.
   * @param {string} [args.url] - (Added in 1.1.0) The URL of the remote repository. The default is the value set in the git config for that remote.
   * @param {string} [args.remote] - (Added in 1.1.0) If URL is not specified, determines which remote to use.
   * @param {string} [args.remoteRef] - (Added in 1.1.0) The name of the branch on the remote to fetch. By default this is the configured remote tracking branch.
   * @param {string} [args.corsProxy] - Optional [CORS proxy](https://www.npmjs.com/%40isomorphic-git/cors-proxy). Overrides value in repo config.
   * @param {boolean} [args.singleBranch = false] - Instead of the default behavior of fetching all the branches, only fetch a single branch.
   * @param {Object<string, string>} [args.headers] - Additional headers to include in HTTP requests, similar to git's `extraHeader` config
   * @param {object} [args.cache] - a [cache](cache.md) object
   *
   * @returns {Promise<void>} Resolves successfully when pull operation completes
   *
   * @example
   * await git.fastForward({
   *   fs,
   *   http,
   *   dir: '/tutorial',
   *   ref: 'main',
   *   singleBranch: true
   * })
   * console.log('done')
   *
   */
  export async function fastForward({
    fs,
    http,
    onProgress,
    onMessage,
    onAuth,
    onAuthSuccess,
    onAuthFailure,
    dir,
    gitdir = join(dir, '.git'),
    ref,
    url,
    remote,
    remoteRef,
    corsProxy,
    singleBranch,
    headers = {},
    cache = {},
  }) {
    try {
      assertParameter('fs', fs)
      assertParameter('http', http)
      assertParameter('gitdir', gitdir)
  
      const thisWillNotBeUsed = {
        name: '',
        email: '',
        timestamp: Date.now(),
        timezoneOffset: 0,
      }
  
      const fsp = new FileSystem(fs)
      const updatedGitdir = await discoverGitdir({ fsp, dotgit: gitdir })
      return await _pull({
        fs: fsp,
        cache,
        http,
        onProgress,
        onMessage,
        onAuth,
        onAuthSuccess,
        onAuthFailure,
        dir,
        gitdir: updatedGitdir,
        ref,
        url,
        remote,
        remoteRef,
        fastForwardOnly: true,
        corsProxy,
        singleBranch,
        headers,
        author: thisWillNotBeUsed,
        committer: thisWillNotBeUsed,
      })
    } catch (err) {
      err.caller = 'git.fastForward'
      throw err
    }
  }
  